Class: TophatterMerchant::Product
- Defined in:
- lib/tophatter_merchant/product.rb
Instance Attribute Summary collapse
- #all_images ⇒ Object
- #available_quantity ⇒ Object
- #brand ⇒ Object
- #buy_now_price ⇒ Object
- #buy_one_get_one_price ⇒ Object
- #category ⇒ Object
- #condition ⇒ Object
- #cost_basis ⇒ Object
- #created_at ⇒ Object
- #days_to_deliver ⇒ Object
- #days_to_fulfill ⇒ Object
- #deleted_at ⇒ Object
- #description ⇒ Object
- #disabled_at ⇒ Object
- #expedited_days_to_deliver ⇒ Object
- #expedited_shipping_price ⇒ Object
- #extra_images ⇒ Object
- #identifier ⇒ Object
- #internal_id ⇒ Object
- #material ⇒ Object
- #primary_image ⇒ Object
- #ratings_average ⇒ Object
- #ratings_count ⇒ Object
- #retail_price ⇒ Object
- #shipping_origin ⇒ Object
- #shipping_price ⇒ Object
- #title ⇒ Object
- #updated_at ⇒ Object
- #variations ⇒ Object
- #weight ⇒ Object
Class Method Summary collapse
-
.all(status: nil, category: nil, health_status: nil, page: 1, per_page: 50, pagination: nil, sort: nil) ⇒ Object
merchant-api.tophatter.com/docs/product-list TophatterMerchant::Product.all(status: ‘in_stock’).
- .create(data) ⇒ Object
-
.disable(id) ⇒ Object
merchant-api.tophatter.com/docs/product-disable TophatterMerchant::Product.disable(‘amazon-fire-7’).disabled_at.
-
.enable(id) ⇒ Object
merchant-api.tophatter.com/docs/product-enable TophatterMerchant::Product.enable(‘amazon-fire-7’).disabled_at.
-
.retrieve(id) ⇒ Object
merchant-api.tophatter.com/docs/product-retrieve TophatterMerchant::Product.retrieve(‘amazon-fire-7’).
-
.search(query:, page: 1, per_page: 50, pagination: nil) ⇒ Object
merchant-api.tophatter.com/docs/product-search TophatterMerchant::Product.search(query: ‘Kindle’).
-
.update(id, data) ⇒ Object
merchant-api.tophatter.com/docs/product-update TophatterMerchant::Product.update(‘amazon-fire-7’, brand: ‘Amazon’).brand.
Methods inherited from Resource
Constructor Details
This class inherits a constructor from TophatterMerchant::Resource
Instance Attribute Details
#all_images ⇒ Object
4 5 6 |
# File 'lib/tophatter_merchant/product.rb', line 4 def all_images @all_images end |
#available_quantity ⇒ Object
4 5 6 |
# File 'lib/tophatter_merchant/product.rb', line 4 def available_quantity @available_quantity end |
#brand ⇒ Object
4 5 6 |
# File 'lib/tophatter_merchant/product.rb', line 4 def brand @brand end |
#buy_now_price ⇒ Object
4 5 6 |
# File 'lib/tophatter_merchant/product.rb', line 4 def buy_now_price @buy_now_price end |
#buy_one_get_one_price ⇒ Object
4 5 6 |
# File 'lib/tophatter_merchant/product.rb', line 4 def buy_one_get_one_price @buy_one_get_one_price end |
#category ⇒ Object
4 5 6 |
# File 'lib/tophatter_merchant/product.rb', line 4 def category @category end |
#condition ⇒ Object
4 5 6 |
# File 'lib/tophatter_merchant/product.rb', line 4 def condition @condition end |
#cost_basis ⇒ Object
4 5 6 |
# File 'lib/tophatter_merchant/product.rb', line 4 def cost_basis @cost_basis end |
#created_at ⇒ Object
4 5 6 |
# File 'lib/tophatter_merchant/product.rb', line 4 def created_at @created_at end |
#days_to_deliver ⇒ Object
4 5 6 |
# File 'lib/tophatter_merchant/product.rb', line 4 def days_to_deliver @days_to_deliver end |
#days_to_fulfill ⇒ Object
4 5 6 |
# File 'lib/tophatter_merchant/product.rb', line 4 def days_to_fulfill @days_to_fulfill end |
#deleted_at ⇒ Object
4 5 6 |
# File 'lib/tophatter_merchant/product.rb', line 4 def deleted_at @deleted_at end |
#description ⇒ Object
4 5 6 |
# File 'lib/tophatter_merchant/product.rb', line 4 def description @description end |
#disabled_at ⇒ Object
4 5 6 |
# File 'lib/tophatter_merchant/product.rb', line 4 def disabled_at @disabled_at end |
#expedited_days_to_deliver ⇒ Object
4 5 6 |
# File 'lib/tophatter_merchant/product.rb', line 4 def expedited_days_to_deliver @expedited_days_to_deliver end |
#expedited_shipping_price ⇒ Object
4 5 6 |
# File 'lib/tophatter_merchant/product.rb', line 4 def expedited_shipping_price @expedited_shipping_price end |
#extra_images ⇒ Object
4 5 6 |
# File 'lib/tophatter_merchant/product.rb', line 4 def extra_images @extra_images end |
#identifier ⇒ Object
4 5 6 |
# File 'lib/tophatter_merchant/product.rb', line 4 def identifier @identifier end |
#internal_id ⇒ Object
4 5 6 |
# File 'lib/tophatter_merchant/product.rb', line 4 def internal_id @internal_id end |
#material ⇒ Object
4 5 6 |
# File 'lib/tophatter_merchant/product.rb', line 4 def material @material end |
#primary_image ⇒ Object
4 5 6 |
# File 'lib/tophatter_merchant/product.rb', line 4 def primary_image @primary_image end |
#ratings_average ⇒ Object
4 5 6 |
# File 'lib/tophatter_merchant/product.rb', line 4 def @ratings_average end |
#ratings_count ⇒ Object
4 5 6 |
# File 'lib/tophatter_merchant/product.rb', line 4 def @ratings_count end |
#retail_price ⇒ Object
4 5 6 |
# File 'lib/tophatter_merchant/product.rb', line 4 def retail_price @retail_price end |
#shipping_origin ⇒ Object
4 5 6 |
# File 'lib/tophatter_merchant/product.rb', line 4 def shipping_origin @shipping_origin end |
#shipping_price ⇒ Object
4 5 6 |
# File 'lib/tophatter_merchant/product.rb', line 4 def shipping_price @shipping_price end |
#title ⇒ Object
4 5 6 |
# File 'lib/tophatter_merchant/product.rb', line 4 def title @title end |
#updated_at ⇒ Object
4 5 6 |
# File 'lib/tophatter_merchant/product.rb', line 4 def updated_at @updated_at end |
#variations ⇒ Object
4 5 6 |
# File 'lib/tophatter_merchant/product.rb', line 4 def variations @variations end |
#weight ⇒ Object
4 5 6 |
# File 'lib/tophatter_merchant/product.rb', line 4 def weight @weight end |
Class Method Details
.all(status: nil, category: nil, health_status: nil, page: 1, per_page: 50, pagination: nil, sort: nil) ⇒ Object
merchant-api.tophatter.com/docs/product-list TophatterMerchant::Product.all(status: ‘in_stock’)
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/tophatter_merchant/product.rb', line 38 def all(status: nil, category: nil, health_status: nil, page: 1, per_page: 50, pagination: nil, sort: nil) result = get(url: "#{path}.json", params: { status: status, category: category, health_status: health_status, page: page, per_page: per_page, pagination: pagination, sort: sort }.reject { |_k, v| v.nil? }) if pagination result['results'] = result['results'].map { |hash| Product.new(hash) } else result = result.map { |hash| Product.new(hash) } end result end |
.create(data) ⇒ Object
71 72 73 |
# File 'lib/tophatter_merchant/product.rb', line 71 def create(data) Product.new post(url: "#{path}.json", params: data) end |
.disable(id) ⇒ Object
merchant-api.tophatter.com/docs/product-disable TophatterMerchant::Product.disable(‘amazon-fire-7’).disabled_at
83 84 85 |
# File 'lib/tophatter_merchant/product.rb', line 83 def disable(id) Product.new post(url: "#{path}/disable.json", params: { identifier: id }) end |
.enable(id) ⇒ Object
merchant-api.tophatter.com/docs/product-enable TophatterMerchant::Product.enable(‘amazon-fire-7’).disabled_at
89 90 91 |
# File 'lib/tophatter_merchant/product.rb', line 89 def enable(id) Product.new post(url: "#{path}/enable.json", params: { identifier: id }) end |
.retrieve(id) ⇒ Object
merchant-api.tophatter.com/docs/product-retrieve TophatterMerchant::Product.retrieve(‘amazon-fire-7’)
66 67 68 |
# File 'lib/tophatter_merchant/product.rb', line 66 def retrieve(id) Product.new get(url: "#{path}/retrieve.json", params: { identifier: id }) end |
.search(query:, page: 1, per_page: 50, pagination: nil) ⇒ Object
merchant-api.tophatter.com/docs/product-search TophatterMerchant::Product.search(query: ‘Kindle’)
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/tophatter_merchant/product.rb', line 52 def search(query:, page: 1, per_page: 50, pagination: nil) result = get(url: "#{path}/search.json", params: { query: query, page: page, per_page: per_page, pagination: pagination }) if pagination result['results'] = result['results'].map { |hash| Product.new(hash) } else result = result.map { |hash| Product.new(hash) } end result end |
.update(id, data) ⇒ Object
merchant-api.tophatter.com/docs/product-update TophatterMerchant::Product.update(‘amazon-fire-7’, brand: ‘Amazon’).brand
77 78 79 |
# File 'lib/tophatter_merchant/product.rb', line 77 def update(id, data) Product.new post(url: "#{path}/update.json", params: data.merge(identifier: id)) end |