Class: Amazon::RecordSalesRanks
- Inherits:
-
Object
- Object
- Amazon::RecordSalesRanks
- Includes:
- Service
- Defined in:
- app/services/amazon/record_sales_ranks.rb
Overview
Extracts category-specific sales ranks from Amazon SP-API payloads and writes
their daily time-series projection. The three supported payloads use
different casing and nesting, so normalization lives here rather than in
each ingestion path.
Defined Under Namespace
Instance Attribute Summary collapse
- #catalog_item ⇒ Object readonly
- #source ⇒ Object readonly
Instance Method Summary collapse
-
#call ⇒ Result
Normalized rankings and number of rows inserted/updated.
Methods included from Service
#attributes_used, #build_result, call, #logger
Methods included from Service::Initializer
Instance Attribute Details
#catalog_item ⇒ Object (readonly)
24 |
# File 'app/services/amazon/record_sales_ranks.rb', line 24 validates :catalog_item, :source, presence: true |
#source ⇒ Object (readonly)
24 |
# File 'app/services/amazon/record_sales_ranks.rb', line 24 validates :catalog_item, :source, presence: true |
Instance Method Details
#call ⇒ Result
Returns normalized rankings and number of rows inserted/updated.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/services/amazon/record_sales_ranks.rb', line 28 def call raise ArgumentError, errors..to_sentence unless valid? extracted_rankings = rankings recorded_count = AmazonSalesRankDataPoint.record_all!( catalog_item:, rankings: extracted_rankings, observed_at:, source:, source_batch_id: ) Result.new(recorded_count:, rankings: extracted_rankings) end |