Class: AboutYou::SDK::Model::ProductsEansResult
- Inherits:
-
Object
- Object
- AboutYou::SDK::Model::ProductsEansResult
- Defined in:
- lib/AboutYou/Model/products_eans_result.rb
Overview
this class represents a products ean result model
Instance Attribute Summary collapse
-
#eans_not_found ⇒ Object
Array of not found eans.
-
#errors ⇒ Object
Array of errors.
-
#page_hash ⇒ Object
String page hash.
-
#products ⇒ Object
Array of instances of AboutYou::SDK::Model::Product.
Class Method Summary collapse
-
.create_from_json(json_object, factory) ⇒ Object
This method is used for creating an instance of this class by a json_object.
Instance Attribute Details
#eans_not_found ⇒ Object
Array of not found eans
9 10 11 |
# File 'lib/AboutYou/Model/products_eans_result.rb', line 9 def eans_not_found @eans_not_found end |
#errors ⇒ Object
Array of errors
13 14 15 |
# File 'lib/AboutYou/Model/products_eans_result.rb', line 13 def errors @errors end |
#page_hash ⇒ Object
String page hash
11 12 13 |
# File 'lib/AboutYou/Model/products_eans_result.rb', line 11 def page_hash @page_hash end |
#products ⇒ Object
Array of instances of AboutYou::SDK::Model::Product
15 16 17 |
# File 'lib/AboutYou/Model/products_eans_result.rb', line 15 def products @products end |
Class Method Details
.create_from_json(json_object, factory) ⇒ Object
This method is used for creating an instance of this class by a json_object.
-
Args :
-
json_object-> the json_object received from the api -
factory-> instance of AboutYou::SDK::Factory::DefaultModelFactory
-
-
Returns :
-
Instance of AboutYou::SDK::Model::ProductsEansResult
-
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/AboutYou/Model/products_eans_result.rb', line 27 def self.create_from_json(json_object, factory) products_ean_result = new products_ean_result.products = [] products_ean_result.eans_not_found = [] products_ean_result.errors = [] products_ean_result.page_hash = json_object['page_hash'] ? json_object['page_hash'] : nil json_object['eans'].each do |json_product| if json_product['error_code'] products_ean_result.errors.push(json_product) products_ean_result.eans_not_found.push(json_product['ean']) next end products_ean_result.products.push(factory.create_product(json_product)) end if json_object['eans'] products_ean_result end |