Class: TinyBuilder::WoocommerceQuantity
- Inherits:
-
Object
- Object
- TinyBuilder::WoocommerceQuantity
- Includes:
- ApigatewayHelper
- Defined in:
- lib/tiny_builder/woocommerce_quantity.rb
Instance Attribute Summary collapse
-
#credential ⇒ Object
readonly
Returns the value of attribute credential.
-
#listings ⇒ Object
readonly
Returns the value of attribute listings.
Instance Method Summary collapse
- #assign_location_id(listing) ⇒ Object
-
#initialize(credential, listings) ⇒ WoocommerceQuantity
constructor
A new instance of WoocommerceQuantity.
- #perform ⇒ Object
Methods included from ApigatewayHelper
#apigateway_url, #headers, #inventory_item_payload, #location_payload, #rest_client, #shopify_inventory_item_url, #shopify_location_url, #woocommerce_item_payload, #woocommerce_product_url, #zalora_stock_payload, #zalora_stock_url
Constructor Details
#initialize(credential, listings) ⇒ WoocommerceQuantity
Returns a new instance of WoocommerceQuantity.
10 11 12 13 |
# File 'lib/tiny_builder/woocommerce_quantity.rb', line 10 def initialize(credential, listings) @credential = credential @listings = listings end |
Instance Attribute Details
#credential ⇒ Object (readonly)
Returns the value of attribute credential.
7 8 9 |
# File 'lib/tiny_builder/woocommerce_quantity.rb', line 7 def credential @credential end |
#listings ⇒ Object (readonly)
Returns the value of attribute listings.
8 9 10 |
# File 'lib/tiny_builder/woocommerce_quantity.rb', line 8 def listings @listings end |
Instance Method Details
#assign_location_id(listing) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/tiny_builder/woocommerce_quantity.rb', line 22 def assign_location_id(listing) return unless listing[:meta_location_id].blank? begin listing[:meta_location_id] = (listing) rescue listing[:wocommerce_last_log] = "Error when getting woocommerce location_id" end end |
#perform ⇒ Object
15 16 17 18 19 20 |
# File 'lib/tiny_builder/woocommerce_quantity.rb', line 15 def perform listings.each do |listing| assign_location_id(listing) listing.save end end |