Class: AdvancedBilling::Offer
- Defined in:
- lib/advanced_billing/models/offer.rb
Overview
Offer Model.
Instance Attribute Summary collapse
-
#archived_at ⇒ String
TODO: Write general description for this method.
-
#created_at ⇒ String
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 ⇒ String
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
Methods inherited from BaseModel
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) ⇒ Offer
Returns a new instance of Offer.
145 146 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 |
# File 'lib/advanced_billing/models/offer.rb', line 145 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) @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 ⇒ String
TODO: Write general description for this method
58 59 60 |
# File 'lib/advanced_billing/models/offer.rb', line 58 def archived_at @archived_at end |
#created_at ⇒ String
TODO: Write general description for this method
50 51 52 |
# File 'lib/advanced_billing/models/offer.rb', line 50 def created_at @created_at end |
#description ⇒ String
TODO: Write general description for this method
46 47 48 |
# File 'lib/advanced_billing/models/offer.rb', line 46 def description @description end |
#handle ⇒ String
TODO: Write general description for this method
42 43 44 |
# File 'lib/advanced_billing/models/offer.rb', line 42 def handle @handle end |
#id ⇒ Integer
TODO: Write general description for this method
14 15 16 |
# File 'lib/advanced_billing/models/offer.rb', line 14 def id @id end |
#name ⇒ String
TODO: Write general description for this method
38 39 40 |
# File 'lib/advanced_billing/models/offer.rb', line 38 def name @name end |
#offer_discounts ⇒ Array[OfferDiscount]
TODO: Write general description for this method
66 67 68 |
# File 'lib/advanced_billing/models/offer.rb', line 66 def offer_discounts @offer_discounts end |
#offer_items ⇒ Array[OfferItem]
TODO: Write general description for this method
62 63 64 |
# File 'lib/advanced_billing/models/offer.rb', line 62 def offer_items @offer_items end |
#offer_signup_pages ⇒ Array[OfferSignupPage]
TODO: Write general description for this method
86 87 88 |
# File 'lib/advanced_billing/models/offer.rb', line 86 def offer_signup_pages @offer_signup_pages end |
#product_family_id ⇒ Integer
TODO: Write general description for this method
22 23 24 |
# File 'lib/advanced_billing/models/offer.rb', line 22 def product_family_id @product_family_id end |
#product_family_name ⇒ String
TODO: Write general description for this method
70 71 72 |
# File 'lib/advanced_billing/models/offer.rb', line 70 def product_family_name @product_family_name end |
#product_id ⇒ Integer
TODO: Write general description for this method
26 27 28 |
# File 'lib/advanced_billing/models/offer.rb', line 26 def product_id @product_id end |
#product_name ⇒ String
TODO: Write general description for this method
74 75 76 |
# File 'lib/advanced_billing/models/offer.rb', line 74 def product_name @product_name end |
#product_price_in_cents ⇒ Integer
TODO: Write general description for this method
82 83 84 |
# File 'lib/advanced_billing/models/offer.rb', line 82 def product_price_in_cents @product_price_in_cents end |
#product_price_point_id ⇒ Integer
TODO: Write general description for this method
30 31 32 |
# File 'lib/advanced_billing/models/offer.rb', line 30 def product_price_point_id @product_price_point_id end |
#product_price_point_name ⇒ String
TODO: Write general description for this method
78 79 80 |
# File 'lib/advanced_billing/models/offer.rb', line 78 def product_price_point_name @product_price_point_name end |
#product_revisable_number ⇒ Integer
TODO: Write general description for this method
34 35 36 |
# File 'lib/advanced_billing/models/offer.rb', line 34 def product_revisable_number @product_revisable_number end |
#site_id ⇒ Integer
TODO: Write general description for this method
18 19 20 |
# File 'lib/advanced_billing/models/offer.rb', line 18 def site_id @site_id end |
#updated_at ⇒ String
TODO: Write general description for this method
54 55 56 |
# File 'lib/advanced_billing/models/offer.rb', line 54 def updated_at @updated_at end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
175 176 177 178 179 180 181 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 |
# File 'lib/advanced_billing/models/offer.rb', line 175 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 = hash.key?('created_at') ? hash['created_at'] : SKIP updated_at = hash.key?('updated_at') ? hash['updated_at'] : SKIP archived_at = hash.key?('archived_at') ? hash['archived_at'] : SKIP # 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') # Create object from extracted values. Offer.new(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 |
.names ⇒ Object
A mapping from model property names to API property names.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/advanced_billing/models/offer.rb', line 89 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
139 140 141 142 143 |
# File 'lib/advanced_billing/models/offer.rb', line 139 def self.nullables %w[ archived_at ] end |
.optionals ⇒ Object
An array for optional fields
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/advanced_billing/models/offer.rb', line 114 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 |