Module: Epages::REST::Products

Includes:
Utils
Included in:
Product, API
Defined in:
lib/epages/rest/products.rb

Overview

Instance Method Summary collapse

Methods included from Utils

#epages_id, #format_date, #format_dates_options, #parse_legal_info, #parse_links, #parse_price_info, #parse_product_lowest_price, #parse_product_variations, #parse_suggestions_to_products, #parse_variation_object, #parse_variations, #perform_delete_request, #perform_delete_with_object, #perform_get_request, #perform_get_with_key_and_objects, #perform_get_with_object, #perform_get_with_objects, #perform_multipart_post_with_objects, #perform_patch_with_object, #perform_post_request, #perform_post_with_key_and_objects, #perform_post_with_object, #perform_post_with_objects, #perform_put_request, #perform_put_with_object, #perform_request, #perform_request_with_key_and_objects, #perform_request_with_object, #perform_request_with_objects, #process_thread

Instance Method Details

#assign_categories(options = {}) ⇒ Object

implements the call developer.epages.com/apps/api-reference/post-shops-shopid-product-category-assignments.html Same as Epages::REST::Categories#‘assign_products`



154
155
156
# File 'lib/epages/rest/products.rb', line 154

def assign_categories(options = {})
  perform_post_request('/product-category-assignments', options)
end

#create_product(data, options = {}) ⇒ Object

call the API to create a new product wit hte data provided and return the product created as Epages::Product implements the call developer.epages.com/apps/api-reference/post-shops-shopid-products.html

Parameters:

  • data (Hash)
  • options (Hash) (defaults to: {})


32
33
34
# File 'lib/epages/rest/products.rb', line 32

def create_product(data, options = {})
  perform_post_with_object("/products#{to_query_options(options)}", data, Epages::Product)
end

#delete_from_categories(options = {}) ⇒ Object

implements the call developer.epages.com/apps/api-reference/delete-shops-shopid-product-category-assignments.html Same as Epages::REST::Categories#‘delete_products`



160
161
162
# File 'lib/epages/rest/products.rb', line 160

def delete_from_categories(options = {})
  perform_delete_request('/product-category-assignments', options)
end

#export_products(options = {}) ⇒ Object

call the API and return a CSV with the proper data of the products implements the call developer.epages.com/apps/api-reference/get-shops-shopid-products-export.html

Parameters:

  • options (Hash) (defaults to: {})


140
141
142
# File 'lib/epages/rest/products.rb', line 140

def export_products(options = {})
  perform_get_request('/products/export', options)
end

#product(product, options = {}) ⇒ Object

call the API and return a Epages::Product implements the call developer.epages.com/apps/api-reference/get-shops-shopid-products-productid.html

Parameters:

  • product (String)

    , [Epages::Product]

  • options (Hash) (defaults to: {})


22
23
24
25
# File 'lib/epages/rest/products.rb', line 22

def product(product, options = {})
  id = epages_id(product)
  perform_get_with_object("/products/#{id}", options, Epages::Product)
end

#product_add_slideshow_image(product, image) ⇒ Object

call the API to post a new image to the slideshow of a product and return an array of Epages::ImageSize (slides) of the product implements the call developer.epages.com/apps/api-reference/post-shops-shopid-products-productid-slideshow.html

Parameters:

  • product (String)

    , [Epages::Product]

  • image (String)


71
72
73
74
# File 'lib/epages/rest/products.rb', line 71

def product_add_slideshow_image(product, image)
  id = epages_id(product)
  perform_multipart_post_with_objects("/products/#{id}/slideshow", image, Epages::ImageSize)
end

#product_custom_attributes(product, options = {}) ⇒ Object

call the API and return an array of Epages::CustomAttribute of the product implements the call developer.epages.com/apps/api-reference/get-shops-shopid-products-productid-custom-attributes.html

Parameters:

  • product (String)

    , [Epages::Product]

  • options (Hash) (defaults to: {})


110
111
112
113
# File 'lib/epages/rest/products.rb', line 110

def product_custom_attributes(product, options = {})
  id = epages_id(product)
  perform_get_with_key_and_objects("/products/#{id}/custom-attributes", options, :items, Epages::CustomAttribute)
end

#product_delete_slideshow_image(product, image) ⇒ Object

call the API to delete an image from the slideshow of a product implements the call developer.epages.com/apps/api-reference/delete-shops-shopid-products-productid-slideshow-imagename.html

Parameters:

  • product (String)

    , [Epages::Product]

  • image (String)


81
82
83
84
# File 'lib/epages/rest/products.rb', line 81

def product_delete_slideshow_image(product, image)
  id = epages_id(product)
  perform_delete_request("/products/#{id}/slideshow/#{image}")
end

#product_lowest_price(product, options = {}) ⇒ Object

call the API and return a hash with the lowest price of the product and the respective link implements the call developer.epages.com/apps/api-reference/get-shops-shopid-products-productid-lowest-price.html

Parameters:

  • product (String)

    , [Epages::Product]

  • options (Hash) (defaults to: {})


120
121
122
123
124
# File 'lib/epages/rest/products.rb', line 120

def product_lowest_price(product, options = {})
  id = epages_id(product)
  response = perform_get_request("/products/#{id}/lowest-price", options)
  parse_product_lowest_price(response)
end

#product_slideshow(product) ⇒ Object

call the API and return an array of Epages::ImageSize (slides) of the product implements the call developer.epages.com/apps/api-reference/get-shops-shopid-products-productid-slideshow.html

Parameters:

  • product (String)

    , [Epages::Product]



61
62
63
64
# File 'lib/epages/rest/products.rb', line 61

def product_slideshow(product)
  id = epages_id(product)
  perform_get_with_key_and_objects("/products/#{id}/slideshow", {}, :items, Epages::ImageSize)
end

#product_slideshow_sequence(product) ⇒ Object

call the API to get the slideshow sequence of a product implements the call developer.epages.com/apps/api-reference/get-shops-shopid-products-productid-slideshow-sequence.html

Parameters:

  • product (String)

    , [Epages::Product]



90
91
92
93
# File 'lib/epages/rest/products.rb', line 90

def product_slideshow_sequence(product)
  id = epages_id(product)
  perform_get_request("/products/#{id}/slideshow/sequence", {})
end

#product_update_slideshow_sequence(product, data) ⇒ Object

call the API to update the slideshow sequence of a product implements the call developer.epages.com/apps/api-reference/put-shops-shopid-products-productid-slideshow-sequence.html

Parameters:

  • product (String)

    , [Epages::Product]

  • data (Array)


100
101
102
103
# File 'lib/epages/rest/products.rb', line 100

def product_update_slideshow_sequence(product, data)
  id = epages_id(product)
  perform_put_request("/products/#{id}/slideshow/sequence", data)
end

#product_variations(product, options = {}) ⇒ Object

call the API and return a Hash with the respective variation_attributes and the variation products implements the call developer.epages.com/apps/api-reference/get-shops-shopid-products-productid-variations.html

Parameters:

  • product (String)

    , [Epages::Product]

  • options (Hash) (defaults to: {})


51
52
53
54
55
# File 'lib/epages/rest/products.rb', line 51

def product_variations(product, options = {})
  id = epages_id(product)
  response = perform_get_request("/products/#{id}/variations", options)
  parse_product_variations(response)
end

#products(options = {}) ⇒ Object

call the API and return an array of Epages::Product implements the call developer.epages.com/apps/api-reference/get-shops-shopid-products.html

Parameters:

  • options (Hash) (defaults to: {})


13
14
15
# File 'lib/epages/rest/products.rb', line 13

def products(options = {})
  perform_get_with_object('/products', options, Epages::ProductsResponse)
end

#update_product(product, options = {}) ⇒ Object

call the API and return a Epages::Product implements the call developer.epages.com/apps/api-reference/patch-shops-shopid-products-productid.html

Parameters:

  • product (String)

    , [Epages::Product]

  • options (Hash) (defaults to: {})


41
42
43
44
# File 'lib/epages/rest/products.rb', line 41

def update_product(product, options = {})
  id = epages_id(product)
  perform_patch_with_object("/products/#{id}", options, Epages::Product)
end

#updated_products_by_property(property, options = {}) ⇒ Object

call the API and return an array of Epages::Product with updated attribute implements the call developer.epages.com/apps/api-reference/get-shops-shopid-products-updated-productproperty.html

Parameters:

  • property (String)

    , [Symbol]

  • options (Hash) (defaults to: {})


131
132
133
134
# File 'lib/epages/rest/products.rb', line 131

def updated_products_by_property(property, options = {})
  res = perform_get_request("/products/updated/#{property.to_s.camelize(:lower)}", options)
  res[:items].collect { |i| Epages::Product.new(i[:item]) }
end

#watched_products(options = {}) ⇒ Object

call the API and returns the list of all watched products. Watched products refers to items currently out of stock and therefore can be watched by online shop customers. implements the call developer.epages.com/apps/api-reference/get-shops-shopid-watched-products.html

Parameters:

  • options (Hash) (defaults to: {})


148
149
150
# File 'lib/epages/rest/products.rb', line 148

def watched_products(options = {})
  perform_get_with_key_and_objects('/watched-products', options, :items, Epages::Product)
end