Class: AdvancedBilling::Offer
- Defined in:
- lib/advanced_billing/models/offer.rb
Overview
Offer Model.
Instance Attribute Summary collapse
-
#archived_at ⇒ DateTime
TODO: Write general description for this method.
-
#created_at ⇒ DateTime
TODO: Write general description for this method.
-
#description ⇒ String
TODO: Write general description for this method.
-
#handle ⇒ String
TODO: Write general description for this method.
-
#id ⇒ Integer
TODO: Write general description for this method.
-
#name ⇒ String
TODO: Write general description for this method.
-
#offer_discounts ⇒ Array[OfferDiscount]
TODO: Write general description for this method.
-
#offer_items ⇒ Array[OfferItem]
TODO: Write general description for this method.
-
#offer_signup_pages ⇒ Array[OfferSignupPage]
TODO: Write general description for this method.
-
#product_family_id ⇒ Integer
TODO: Write general description for this method.
-
#product_family_name ⇒ String
TODO: Write general description for this method.
-
#product_id ⇒ Integer
TODO: Write general description for this method.
-
#product_name ⇒ String
TODO: Write general description for this method.
-
#product_price_in_cents ⇒ Integer
TODO: Write general description for this method.
-
#product_price_point_id ⇒ Integer
TODO: Write general description for this method.
-
#product_price_point_name ⇒ String
TODO: Write general description for this method.
-
#product_revisable_number ⇒ Integer
TODO: Write general description for this method.
-
#site_id ⇒ Integer
TODO: Write general description for this method.
-
#updated_at ⇒ DateTime
TODO: Write general description for this method.
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.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(id: SKIP, site_id: SKIP, product_family_id: SKIP, product_id: SKIP, product_price_point_id: SKIP, product_revisable_number: SKIP, name: SKIP, handle: SKIP, description: SKIP, created_at: SKIP, updated_at: SKIP, archived_at: SKIP, offer_items: SKIP, offer_discounts: SKIP, product_family_name: SKIP, product_name: SKIP, product_price_point_name: SKIP, product_price_in_cents: SKIP, offer_signup_pages: SKIP, additional_properties: {}) ⇒ Offer
constructor
A new instance of Offer.
- #to_custom_archived_at ⇒ Object
- #to_custom_created_at ⇒ Object
- #to_custom_updated_at ⇒ Object
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(id: SKIP, site_id: SKIP, product_family_id: SKIP, product_id: SKIP, product_price_point_id: SKIP, product_revisable_number: SKIP, name: SKIP, handle: SKIP, description: SKIP, created_at: SKIP, updated_at: SKIP, archived_at: SKIP, offer_items: SKIP, offer_discounts: SKIP, product_family_name: SKIP, product_name: SKIP, product_price_point_name: SKIP, product_price_in_cents: SKIP, offer_signup_pages: SKIP, additional_properties: {}) ⇒ Offer
Returns a new instance of Offer.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/advanced_billing/models/offer.rb', line 147 def initialize(id: SKIP, site_id: SKIP, product_family_id: SKIP, product_id: SKIP, product_price_point_id: SKIP, product_revisable_number: SKIP, name: SKIP, handle: SKIP, description: SKIP, created_at: SKIP, updated_at: SKIP, archived_at: SKIP, offer_items: SKIP, offer_discounts: SKIP, product_family_name: SKIP, product_name: SKIP, product_price_point_name: SKIP, product_price_in_cents: SKIP, offer_signup_pages: SKIP, additional_properties: {}) # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end @id = id unless id == SKIP @site_id = site_id unless site_id == SKIP @product_family_id = product_family_id unless product_family_id == SKIP @product_id = product_id unless product_id == SKIP @product_price_point_id = product_price_point_id unless product_price_point_id == SKIP @product_revisable_number = product_revisable_number unless product_revisable_number == SKIP @name = name unless name == SKIP @handle = handle unless handle == SKIP @description = description unless description == SKIP @created_at = created_at unless created_at == SKIP @updated_at = updated_at unless updated_at == SKIP @archived_at = archived_at unless archived_at == SKIP @offer_items = offer_items unless offer_items == SKIP @offer_discounts = offer_discounts unless offer_discounts == SKIP @product_family_name = product_family_name unless product_family_name == SKIP @product_name = product_name unless product_name == SKIP @product_price_point_name = product_price_point_name unless product_price_point_name == SKIP @product_price_in_cents = product_price_in_cents unless product_price_in_cents == SKIP @offer_signup_pages = offer_signup_pages unless offer_signup_pages == SKIP end |
Instance Attribute Details
#archived_at ⇒ DateTime
TODO: Write general description for this method
59 60 61 |
# File 'lib/advanced_billing/models/offer.rb', line 59 def archived_at @archived_at end |
#created_at ⇒ DateTime
TODO: Write general description for this method
51 52 53 |
# File 'lib/advanced_billing/models/offer.rb', line 51 def created_at @created_at end |
#description ⇒ String
TODO: Write general description for this method
47 48 49 |
# File 'lib/advanced_billing/models/offer.rb', line 47 def description @description end |
#handle ⇒ String
TODO: Write general description for this method
43 44 45 |
# File 'lib/advanced_billing/models/offer.rb', line 43 def handle @handle end |
#id ⇒ Integer
TODO: Write general description for this method
15 16 17 |
# File 'lib/advanced_billing/models/offer.rb', line 15 def id @id end |
#name ⇒ String
TODO: Write general description for this method
39 40 41 |
# File 'lib/advanced_billing/models/offer.rb', line 39 def name @name end |
#offer_discounts ⇒ Array[OfferDiscount]
TODO: Write general description for this method
67 68 69 |
# File 'lib/advanced_billing/models/offer.rb', line 67 def offer_discounts @offer_discounts end |
#offer_items ⇒ Array[OfferItem]
TODO: Write general description for this method
63 64 65 |
# File 'lib/advanced_billing/models/offer.rb', line 63 def offer_items @offer_items end |
#offer_signup_pages ⇒ Array[OfferSignupPage]
TODO: Write general description for this method
87 88 89 |
# File 'lib/advanced_billing/models/offer.rb', line 87 def offer_signup_pages @offer_signup_pages end |
#product_family_id ⇒ Integer
TODO: Write general description for this method
23 24 25 |
# File 'lib/advanced_billing/models/offer.rb', line 23 def product_family_id @product_family_id end |
#product_family_name ⇒ String
TODO: Write general description for this method
71 72 73 |
# File 'lib/advanced_billing/models/offer.rb', line 71 def product_family_name @product_family_name end |
#product_id ⇒ Integer
TODO: Write general description for this method
27 28 29 |
# File 'lib/advanced_billing/models/offer.rb', line 27 def product_id @product_id end |
#product_name ⇒ String
TODO: Write general description for this method
75 76 77 |
# File 'lib/advanced_billing/models/offer.rb', line 75 def product_name @product_name end |
#product_price_in_cents ⇒ Integer
TODO: Write general description for this method
83 84 85 |
# File 'lib/advanced_billing/models/offer.rb', line 83 def product_price_in_cents @product_price_in_cents end |
#product_price_point_id ⇒ Integer
TODO: Write general description for this method
31 32 33 |
# File 'lib/advanced_billing/models/offer.rb', line 31 def product_price_point_id @product_price_point_id end |
#product_price_point_name ⇒ String
TODO: Write general description for this method
79 80 81 |
# File 'lib/advanced_billing/models/offer.rb', line 79 def product_price_point_name @product_price_point_name end |
#product_revisable_number ⇒ Integer
TODO: Write general description for this method
35 36 37 |
# File 'lib/advanced_billing/models/offer.rb', line 35 def product_revisable_number @product_revisable_number end |
#site_id ⇒ Integer
TODO: Write general description for this method
19 20 21 |
# File 'lib/advanced_billing/models/offer.rb', line 19 def site_id @site_id end |
#updated_at ⇒ DateTime
TODO: Write general description for this method
55 56 57 |
# File 'lib/advanced_billing/models/offer.rb', line 55 def updated_at @updated_at end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/advanced_billing/models/offer.rb', line 182 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : SKIP site_id = hash.key?('site_id') ? hash['site_id'] : SKIP product_family_id = hash.key?('product_family_id') ? hash['product_family_id'] : SKIP product_id = hash.key?('product_id') ? hash['product_id'] : SKIP product_price_point_id = hash.key?('product_price_point_id') ? hash['product_price_point_id'] : SKIP product_revisable_number = hash.key?('product_revisable_number') ? hash['product_revisable_number'] : SKIP name = hash.key?('name') ? hash['name'] : SKIP handle = hash.key?('handle') ? hash['handle'] : SKIP description = hash.key?('description') ? hash['description'] : SKIP created_at = if hash.key?('created_at') (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at']) else SKIP end updated_at = if hash.key?('updated_at') (DateTimeHelper.from_rfc3339(hash['updated_at']) if hash['updated_at']) else SKIP end archived_at = if hash.key?('archived_at') (DateTimeHelper.from_rfc3339(hash['archived_at']) if hash['archived_at']) else SKIP end # Parameter is an array, so we need to iterate through it offer_items = nil unless hash['offer_items'].nil? offer_items = [] hash['offer_items'].each do |structure| offer_items << (OfferItem.from_hash(structure) if structure) end end offer_items = SKIP unless hash.key?('offer_items') # Parameter is an array, so we need to iterate through it offer_discounts = nil unless hash['offer_discounts'].nil? offer_discounts = [] hash['offer_discounts'].each do |structure| offer_discounts << (OfferDiscount.from_hash(structure) if structure) end end offer_discounts = SKIP unless hash.key?('offer_discounts') product_family_name = hash.key?('product_family_name') ? hash['product_family_name'] : SKIP product_name = hash.key?('product_name') ? hash['product_name'] : SKIP product_price_point_name = hash.key?('product_price_point_name') ? hash['product_price_point_name'] : SKIP product_price_in_cents = hash.key?('product_price_in_cents') ? hash['product_price_in_cents'] : SKIP # Parameter is an array, so we need to iterate through it offer_signup_pages = nil unless hash['offer_signup_pages'].nil? offer_signup_pages = [] hash['offer_signup_pages'].each do |structure| offer_signup_pages << (OfferSignupPage.from_hash(structure) if structure) end end offer_signup_pages = SKIP unless hash.key?('offer_signup_pages') # Clean out expected properties from Hash. additional_properties = hash.reject { |k, _| names.value?(k) } # Create object from extracted values. Offer.new(id: id, site_id: site_id, product_family_id: product_family_id, product_id: product_id, product_price_point_id: product_price_point_id, product_revisable_number: product_revisable_number, name: name, handle: handle, description: description, created_at: created_at, updated_at: updated_at, archived_at: archived_at, offer_items: offer_items, offer_discounts: offer_discounts, product_family_name: product_family_name, product_name: product_name, product_price_point_name: product_price_point_name, product_price_in_cents: product_price_in_cents, offer_signup_pages: offer_signup_pages, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/advanced_billing/models/offer.rb', line 90 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['site_id'] = 'site_id' @_hash['product_family_id'] = 'product_family_id' @_hash['product_id'] = 'product_id' @_hash['product_price_point_id'] = 'product_price_point_id' @_hash['product_revisable_number'] = 'product_revisable_number' @_hash['name'] = 'name' @_hash['handle'] = 'handle' @_hash['description'] = 'description' @_hash['created_at'] = 'created_at' @_hash['updated_at'] = 'updated_at' @_hash['archived_at'] = 'archived_at' @_hash['offer_items'] = 'offer_items' @_hash['offer_discounts'] = 'offer_discounts' @_hash['product_family_name'] = 'product_family_name' @_hash['product_name'] = 'product_name' @_hash['product_price_point_name'] = 'product_price_point_name' @_hash['product_price_in_cents'] = 'product_price_in_cents' @_hash['offer_signup_pages'] = 'offer_signup_pages' @_hash end |
.nullables ⇒ Object
An array for nullable fields
140 141 142 143 144 145 |
# File 'lib/advanced_billing/models/offer.rb', line 140 def self.nullables %w[ description archived_at ] end |
.optionals ⇒ Object
An array for optional fields
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/advanced_billing/models/offer.rb', line 115 def self.optionals %w[ id site_id product_family_id product_id product_price_point_id product_revisable_number name handle description created_at updated_at archived_at offer_items offer_discounts product_family_name product_name product_price_point_name product_price_in_cents offer_signup_pages ] end |
Instance Method Details
#to_custom_archived_at ⇒ Object
285 286 287 |
# File 'lib/advanced_billing/models/offer.rb', line 285 def to_custom_archived_at DateTimeHelper.to_rfc3339(archived_at) end |
#to_custom_created_at ⇒ Object
277 278 279 |
# File 'lib/advanced_billing/models/offer.rb', line 277 def to_custom_created_at DateTimeHelper.to_rfc3339(created_at) end |
#to_custom_updated_at ⇒ Object
281 282 283 |
# File 'lib/advanced_billing/models/offer.rb', line 281 def to_custom_updated_at DateTimeHelper.to_rfc3339(updated_at) end |