class AboutYou::SDK::Model::ProductsResult
This class represents a products result model
Attributes
errors[RW]
Array of errors
ids_not_found[RW]
Array of not found product ids
page_hash[RW]
String page hash
products[RW]
Array of instances of AboutYou::SDK::Model::Product
Public Class Methods
create_from_json(json_object, factory)
click to toggle source
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 ofAboutYou::SDK::Factory::DefaultModelFactory
-
-
Returns :
-
Instance of
AboutYou::SDK::Model::ProductsResult
-
# File lib/AboutYou/Model/products_result.rb, line 29 def self.create_from_json(json_object, factory) products_result = new products_result.page_hash = json_object['page_hash'] ? json_object['page_hash'] : nil products_result.errors = [] products_result.ids_not_found = [] products_result.products = {} if json_object['ids'] json_object['ids'].each do |key, json_product| if json_product['error_code'] products_result.ids_not_found.push(key) products_result.errors.push(json_product) next end products_result.products[Integer(key)] = factory.create_product( json_product ) end end products_result end