Class: Feed::Google::MerchantApi::ProductInputBuilder
- Inherits:
-
Object
- Object
- Feed::Google::MerchantApi::ProductInputBuilder
- Defined in:
- app/services/feed/google/merchant_api/product_input_builder.rb
Overview
Maps a GoogleProductPresenter to a Merchant API v1
ProductInput hash, field-for-field with what the now-removed legacy XML feed
emitted, so the API push was a drop-in replacement: the offerId is the same
g:id the XML feed used, so listings were not duplicated on cutover.
Standard Google attributes go in productAttributes; the two non-standard
fields the fetch feed surfaced as custom attributes (suggested retail price,
ships from country) are preserved in customAttributes.
Feed is an ActiveRecord model, so this uses the compact class Feed::Google::…
form rather than reopening module Feed.
Instance Method Summary collapse
-
#as_json ⇒ Hash
A Merchant API ProductInput.
-
#initialize(presenter) ⇒ ProductInputBuilder
constructor
A new instance of ProductInputBuilder.
Constructor Details
#initialize(presenter) ⇒ ProductInputBuilder
Returns a new instance of ProductInputBuilder.
16 17 18 |
# File 'app/services/feed/google/merchant_api/product_input_builder.rb', line 16 def initialize(presenter) @p = presenter end |
Instance Method Details
#as_json ⇒ Hash
Returns a Merchant API ProductInput.
21 22 23 24 25 26 27 28 29 |
# File 'app/services/feed/google/merchant_api/product_input_builder.rb', line 21 def as_json { offerId: @p.id.to_s, contentLanguage: 'en', feedLabel: feed_label, productAttributes: product_attributes, customAttributes: custom_attributes } end |