Class: Asdawqw::ImageUrlList

Inherits:
BaseModel show all
Defined in:
lib/asdawqw/models/image_url_list.rb

Overview

Model with list of URLs for one property

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(product_id = nil, images = nil) ⇒ ImageUrlList

Returns a new instance of ImageUrlList.



25
26
27
28
29
# File 'lib/asdawqw/models/image_url_list.rb', line 25

def initialize(product_id = nil,
               images = nil)
  @product_id = product_id
  @images = images
end

Instance Attribute Details

#imagesList of Image

Images for property

Returns:



15
16
17
# File 'lib/asdawqw/models/image_url_list.rb', line 15

def images
  @images
end

#product_idInteger

Id of the product

Returns:

  • (Integer)


11
12
13
# File 'lib/asdawqw/models/image_url_list.rb', line 11

def product_id
  @product_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/asdawqw/models/image_url_list.rb', line 32

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  product_id = hash['productId']
  # Parameter is an array, so we need to iterate through it
  images = nil
  unless hash['images'].nil?
    images = []
    hash['images'].each do |structure|
      images << (Image.from_hash(structure) if structure)
    end
  end

  # Create object from extracted values.
  ImageUrlList.new(product_id,
                   images)
end

.namesObject

A mapping from model property names to API property names.



18
19
20
21
22
23
# File 'lib/asdawqw/models/image_url_list.rb', line 18

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['product_id'] = 'productId'
  @_hash['images'] = 'images'
  @_hash
end