Class: Raas::BrandModel

Inherits:
BaseModel show all
Defined in:
lib/raas/models/brand_model.rb

Overview

Represents a Brand

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(brand_key = nil, brand_name = nil, disclaimer = nil, description = nil, short_description = nil, terms = nil, created_date = nil, last_update_date = nil, image_urls = nil, status = nil, items = nil) ⇒ BrandModel

Returns a new instance of BrandModel.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/raas/models/brand_model.rb', line 69

def initialize(brand_key = nil,
               brand_name = nil,
               disclaimer = nil,
               description = nil,
               short_description = nil,
               terms = nil,
               created_date = nil,
               last_update_date = nil,
               image_urls = nil,
               status = nil,
               items = nil)
  @brand_key = brand_key
  @brand_name = brand_name
  @disclaimer = disclaimer
  @description = description
  @short_description = short_description
  @terms = terms
  @created_date = created_date
  @last_update_date = last_update_date
  @image_urls = image_urls
  @status = status
  @items = items
end

Instance Attribute Details

#brand_keyString

The brand key

Returns:



10
11
12
# File 'lib/raas/models/brand_model.rb', line 10

def brand_key
  @brand_key
end

#brand_nameString

The brand name

Returns:



14
15
16
# File 'lib/raas/models/brand_model.rb', line 14

def brand_name
  @brand_name
end

#created_dateDateTime

The date the brand was created

Returns:

  • (DateTime)


34
35
36
# File 'lib/raas/models/brand_model.rb', line 34

def created_date
  @created_date
end

#descriptionString

The brand’s description

Returns:



22
23
24
# File 'lib/raas/models/brand_model.rb', line 22

def description
  @description
end

#disclaimerString

The brand’s disclaimer

Returns:



18
19
20
# File 'lib/raas/models/brand_model.rb', line 18

def disclaimer
  @disclaimer
end

#image_urlsArray<String, String>

A map of Image URLs

Returns:



42
43
44
# File 'lib/raas/models/brand_model.rb', line 42

def image_urls
  @image_urls
end

#itemsList of ItemModel

An array of Item objects

Returns:



50
51
52
# File 'lib/raas/models/brand_model.rb', line 50

def items
  @items
end

#last_update_dateDateTime

The date the brand was last updated

Returns:

  • (DateTime)


38
39
40
# File 'lib/raas/models/brand_model.rb', line 38

def last_update_date
  @last_update_date
end

#short_descriptionString

The brand’s short description

Returns:



26
27
28
# File 'lib/raas/models/brand_model.rb', line 26

def short_description
  @short_description
end

#statusString

The brand’s status

Returns:



46
47
48
# File 'lib/raas/models/brand_model.rb', line 46

def status
  @status
end

#termsString

The brand’s terms

Returns:



30
31
32
# File 'lib/raas/models/brand_model.rb', line 30

def terms
  @terms
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/raas/models/brand_model.rb', line 94

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  brand_key = hash['brandKey']
  brand_name = hash['brandName']
  disclaimer = hash['disclaimer']
  description = hash['description']
  short_description = hash['shortDescription']
  terms = hash['terms']
  created_date = APIHelper.rfc3339(hash['createdDate']) if
    hash['createdDate']
  last_update_date = APIHelper.rfc3339(hash['lastUpdateDate']) if
    hash['lastUpdateDate']
  image_urls = hash['imageUrls']
  status = hash['status']
  # Parameter is an array, so we need to iterate through it
  items = nil
  unless hash['items'].nil?
    items = []
    hash['items'].each do |structure|
      items << (ItemModel.from_hash(structure) if structure)
    end
  end

  # Create object from extracted values.
  BrandModel.new(brand_key,
                 brand_name,
                 disclaimer,
                 description,
                 short_description,
                 terms,
                 created_date,
                 last_update_date,
                 image_urls,
                 status,
                 items)
end

.namesObject

A mapping from model property names to API property names.



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/raas/models/brand_model.rb', line 53

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['brand_key'] = 'brandKey'
  @_hash['brand_name'] = 'brandName'
  @_hash['disclaimer'] = 'disclaimer'
  @_hash['description'] = 'description'
  @_hash['short_description'] = 'shortDescription'
  @_hash['terms'] = 'terms'
  @_hash['created_date'] = 'createdDate'
  @_hash['last_update_date'] = 'lastUpdateDate'
  @_hash['image_urls'] = 'imageUrls'
  @_hash['status'] = 'status'
  @_hash['items'] = 'items'
  @_hash
end