Class: Raas::BrandModel
- Defined in:
- lib/raas/models/brand_model.rb
Overview
Represents a Brand
Instance Attribute Summary collapse
-
#brand_key ⇒ String
The brand key.
-
#brand_name ⇒ String
The brand name.
-
#created_date ⇒ DateTime
The date the brand was created.
-
#description ⇒ String
The brand’s description.
-
#disclaimer ⇒ String
The brand’s disclaimer.
-
#image_urls ⇒ Array<String, String>
A map of Image URLs.
-
#items ⇒ List of ItemModel
An array of Item objects.
-
#last_update_date ⇒ DateTime
The date the brand was last updated.
-
#short_description ⇒ String
The brand’s short description.
-
#status ⇒ String
The brand’s status.
-
#terms ⇒ String
The brand’s terms.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
Instance Method Summary collapse
-
#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
constructor
A new instance of BrandModel.
Methods inherited from BaseModel
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_key ⇒ String
The brand key
10 11 12 |
# File 'lib/raas/models/brand_model.rb', line 10 def brand_key @brand_key end |
#brand_name ⇒ String
The brand name
14 15 16 |
# File 'lib/raas/models/brand_model.rb', line 14 def brand_name @brand_name end |
#created_date ⇒ DateTime
The date the brand was created
34 35 36 |
# File 'lib/raas/models/brand_model.rb', line 34 def created_date @created_date end |
#description ⇒ String
The brand’s description
22 23 24 |
# File 'lib/raas/models/brand_model.rb', line 22 def description @description end |
#disclaimer ⇒ String
The brand’s disclaimer
18 19 20 |
# File 'lib/raas/models/brand_model.rb', line 18 def disclaimer @disclaimer end |
#image_urls ⇒ Array<String, String>
A map of Image URLs
42 43 44 |
# File 'lib/raas/models/brand_model.rb', line 42 def image_urls @image_urls end |
#items ⇒ List of ItemModel
An array of Item objects
50 51 52 |
# File 'lib/raas/models/brand_model.rb', line 50 def items @items end |
#last_update_date ⇒ DateTime
The date the brand was last updated
38 39 40 |
# File 'lib/raas/models/brand_model.rb', line 38 def last_update_date @last_update_date end |
#short_description ⇒ String
The brand’s short description
26 27 28 |
# File 'lib/raas/models/brand_model.rb', line 26 def short_description @short_description end |
#status ⇒ String
The brand’s status
46 47 48 |
# File 'lib/raas/models/brand_model.rb', line 46 def status @status end |
#terms ⇒ String
The brand’s terms
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 |
.names ⇒ Object
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 |