Class: AboutYou::SDK::Model::ProductsResult

Inherits:
Object
  • Object
show all
Includes:
AbstractModel
Defined in:
lib/AboutYou/Model/products_result.rb

Overview

This class represents a products result model

Instance Attribute Summary collapse

Attributes included from AbstractModel

#shop_api

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#errorsObject

Returns the value of attribute errors.



14
15
16
# File 'lib/AboutYou/Model/products_result.rb', line 14

def errors
  @errors
end

#ids_not_foundObject

Returns the value of attribute ids_not_found.



12
13
14
# File 'lib/AboutYou/Model/products_result.rb', line 12

def ids_not_found
  @ids_not_found
end

#page_hashObject

Returns the value of attribute page_hash.



13
14
15
# File 'lib/AboutYou/Model/products_result.rb', line 13

def page_hash
  @page_hash
end

#productsObject

Returns the value of attribute products.



15
16
17
# File 'lib/AboutYou/Model/products_result.rb', line 15

def products
  @products
end

Class Method Details

.create_from_json(json_object, factory) ⇒ Object

Returns static.

Parameters:

  • \stdClass

    $json_object

  • ModelFactoryInterface

    $factory

Returns:

  • static



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/AboutYou/Model/products_result.rb', line 23

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

Instance Method Details

#products_not_foundObject

Returns integer[] array of product ids.

Returns:

  • integer[] array of product ids



50
51
52
# File 'lib/AboutYou/Model/products_result.rb', line 50

def products_not_found
  ids_not_found
end