Class: UltracartClient::Cart
- Inherits:
-
Object
- Object
- UltracartClient::Cart
- Defined in:
- lib/ultracart_api/models/cart.rb
Instance Attribute Summary collapse
-
#affiliate ⇒ Object
Returns the value of attribute affiliate.
-
#affiliate_network_pixel_oid ⇒ Object
The affiliate network pixel identifier associated with the cart.
-
#base_currency_code ⇒ Object
The ISO-4217 three letter base currency code of the account.
-
#billing ⇒ Object
Returns the value of attribute billing.
-
#buysafe ⇒ Object
Returns the value of attribute buysafe.
-
#cart_id ⇒ Object
Unique identifier for this cart.
-
#checkout ⇒ Object
Returns the value of attribute checkout.
-
#coupons ⇒ Object
Coupons.
-
#currency_code ⇒ Object
The ISO-4217 three letter currency code the customer is viewing prices in.
-
#currency_conversion ⇒ Object
Returns the value of attribute currency_conversion.
-
#customer_profile ⇒ Object
Returns the value of attribute customer_profile.
-
#exchange_rate ⇒ Object
The exchange rate if the customer is viewing a different currency than the base.
-
#gift ⇒ Object
Returns the value of attribute gift.
-
#gift_certificate ⇒ Object
Returns the value of attribute gift_certificate.
-
#items ⇒ Object
Items.
-
#language_iso_code ⇒ Object
The ISO-631 three letter code the customer would like to checkout with.
-
#logged_in ⇒ Object
True if the customer is logged into their profile.
-
#marketing ⇒ Object
Returns the value of attribute marketing.
-
#merchant_id ⇒ Object
Merchant ID this cart is associated with.
-
#payment ⇒ Object
Returns the value of attribute payment.
-
#properties ⇒ Object
Properties associated with the cart.
-
#settings ⇒ Object
Returns the value of attribute settings.
-
#shipping ⇒ Object
Returns the value of attribute shipping.
-
#summary ⇒ Object
Returns the value of attribute summary.
-
#taxes ⇒ Object
Returns the value of attribute taxes.
-
#upsell_after ⇒ Object
Returns the value of attribute upsell_after.
Class Method Summary collapse
-
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about.
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.build_from_hash(attributes) ⇒ Object
Builds the object from hash.
-
.openapi_nullable ⇒ Object
List of attributes with nullable: true.
-
.openapi_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
-
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type.
-
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash.
-
#build_from_hash(attributes) ⇒ Object
Builds the object from hash.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ Cart
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility).
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#to_s ⇒ String
Returns the string representation of the object.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ Cart
Initializes the object
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 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 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
# File 'lib/ultracart_api/models/cart.rb', line 158 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::Cart` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::Cart`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'affiliate') self.affiliate = attributes[:'affiliate'] end if attributes.key?(:'affiliate_network_pixel_oid') self.affiliate_network_pixel_oid = attributes[:'affiliate_network_pixel_oid'] end if attributes.key?(:'base_currency_code') self.base_currency_code = attributes[:'base_currency_code'] end if attributes.key?(:'billing') self.billing = attributes[:'billing'] end if attributes.key?(:'buysafe') self.buysafe = attributes[:'buysafe'] end if attributes.key?(:'cart_id') self.cart_id = attributes[:'cart_id'] end if attributes.key?(:'checkout') self.checkout = attributes[:'checkout'] end if attributes.key?(:'coupons') if (value = attributes[:'coupons']).is_a?(Array) self.coupons = value end end if attributes.key?(:'currency_code') self.currency_code = attributes[:'currency_code'] end if attributes.key?(:'currency_conversion') self.currency_conversion = attributes[:'currency_conversion'] end if attributes.key?(:'customer_profile') self.customer_profile = attributes[:'customer_profile'] end if attributes.key?(:'exchange_rate') self.exchange_rate = attributes[:'exchange_rate'] end if attributes.key?(:'gift') self.gift = attributes[:'gift'] end if attributes.key?(:'gift_certificate') self.gift_certificate = attributes[:'gift_certificate'] end if attributes.key?(:'items') if (value = attributes[:'items']).is_a?(Array) self.items = value end end if attributes.key?(:'language_iso_code') self.language_iso_code = attributes[:'language_iso_code'] end if attributes.key?(:'logged_in') self.logged_in = attributes[:'logged_in'] end if attributes.key?(:'marketing') self.marketing = attributes[:'marketing'] end if attributes.key?(:'merchant_id') self.merchant_id = attributes[:'merchant_id'] end if attributes.key?(:'payment') self.payment = attributes[:'payment'] end if attributes.key?(:'properties') if (value = attributes[:'properties']).is_a?(Array) self.properties = value end end if attributes.key?(:'settings') self.settings = attributes[:'settings'] end if attributes.key?(:'shipping') self.shipping = attributes[:'shipping'] end if attributes.key?(:'summary') self.summary = attributes[:'summary'] end if attributes.key?(:'taxes') self.taxes = attributes[:'taxes'] end if attributes.key?(:'upsell_after') self.upsell_after = attributes[:'upsell_after'] end end |
Instance Attribute Details
#affiliate ⇒ Object
Returns the value of attribute affiliate.
18 19 20 |
# File 'lib/ultracart_api/models/cart.rb', line 18 def affiliate @affiliate end |
#affiliate_network_pixel_oid ⇒ Object
The affiliate network pixel identifier associated with the cart
21 22 23 |
# File 'lib/ultracart_api/models/cart.rb', line 21 def affiliate_network_pixel_oid @affiliate_network_pixel_oid end |
#base_currency_code ⇒ Object
The ISO-4217 three letter base currency code of the account
24 25 26 |
# File 'lib/ultracart_api/models/cart.rb', line 24 def base_currency_code @base_currency_code end |
#billing ⇒ Object
Returns the value of attribute billing.
26 27 28 |
# File 'lib/ultracart_api/models/cart.rb', line 26 def billing @billing end |
#buysafe ⇒ Object
Returns the value of attribute buysafe.
28 29 30 |
# File 'lib/ultracart_api/models/cart.rb', line 28 def buysafe @buysafe end |
#cart_id ⇒ Object
Unique identifier for this cart
31 32 33 |
# File 'lib/ultracart_api/models/cart.rb', line 31 def cart_id @cart_id end |
#checkout ⇒ Object
Returns the value of attribute checkout.
33 34 35 |
# File 'lib/ultracart_api/models/cart.rb', line 33 def checkout @checkout end |
#coupons ⇒ Object
Coupons
36 37 38 |
# File 'lib/ultracart_api/models/cart.rb', line 36 def coupons @coupons end |
#currency_code ⇒ Object
The ISO-4217 three letter currency code the customer is viewing prices in
39 40 41 |
# File 'lib/ultracart_api/models/cart.rb', line 39 def currency_code @currency_code end |
#currency_conversion ⇒ Object
Returns the value of attribute currency_conversion.
41 42 43 |
# File 'lib/ultracart_api/models/cart.rb', line 41 def currency_conversion @currency_conversion end |
#customer_profile ⇒ Object
Returns the value of attribute customer_profile.
43 44 45 |
# File 'lib/ultracart_api/models/cart.rb', line 43 def customer_profile @customer_profile end |
#exchange_rate ⇒ Object
The exchange rate if the customer is viewing a different currency than the base
46 47 48 |
# File 'lib/ultracart_api/models/cart.rb', line 46 def exchange_rate @exchange_rate end |
#gift ⇒ Object
Returns the value of attribute gift.
48 49 50 |
# File 'lib/ultracart_api/models/cart.rb', line 48 def gift @gift end |
#gift_certificate ⇒ Object
Returns the value of attribute gift_certificate.
50 51 52 |
# File 'lib/ultracart_api/models/cart.rb', line 50 def gift_certificate @gift_certificate end |
#items ⇒ Object
Items
53 54 55 |
# File 'lib/ultracart_api/models/cart.rb', line 53 def items @items end |
#language_iso_code ⇒ Object
The ISO-631 three letter code the customer would like to checkout with
56 57 58 |
# File 'lib/ultracart_api/models/cart.rb', line 56 def language_iso_code @language_iso_code end |
#logged_in ⇒ Object
True if the customer is logged into their profile
59 60 61 |
# File 'lib/ultracart_api/models/cart.rb', line 59 def logged_in @logged_in end |
#marketing ⇒ Object
Returns the value of attribute marketing.
61 62 63 |
# File 'lib/ultracart_api/models/cart.rb', line 61 def marketing @marketing end |
#merchant_id ⇒ Object
Merchant ID this cart is associated with
64 65 66 |
# File 'lib/ultracart_api/models/cart.rb', line 64 def merchant_id @merchant_id end |
#payment ⇒ Object
Returns the value of attribute payment.
66 67 68 |
# File 'lib/ultracart_api/models/cart.rb', line 66 def payment @payment end |
#properties ⇒ Object
Properties associated with the cart
69 70 71 |
# File 'lib/ultracart_api/models/cart.rb', line 69 def properties @properties end |
#settings ⇒ Object
Returns the value of attribute settings.
71 72 73 |
# File 'lib/ultracart_api/models/cart.rb', line 71 def settings @settings end |
#shipping ⇒ Object
Returns the value of attribute shipping.
73 74 75 |
# File 'lib/ultracart_api/models/cart.rb', line 73 def shipping @shipping end |
#summary ⇒ Object
Returns the value of attribute summary.
75 76 77 |
# File 'lib/ultracart_api/models/cart.rb', line 75 def summary @summary end |
#taxes ⇒ Object
Returns the value of attribute taxes.
77 78 79 |
# File 'lib/ultracart_api/models/cart.rb', line 77 def taxes @taxes end |
#upsell_after ⇒ Object
Returns the value of attribute upsell_after.
79 80 81 |
# File 'lib/ultracart_api/models/cart.rb', line 79 def upsell_after @upsell_after end |
Class Method Details
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
114 115 116 |
# File 'lib/ultracart_api/models/cart.rb', line 114 def self.acceptable_attributes attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
82 83 84 85 86 87 88 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/ultracart_api/models/cart.rb', line 82 def self.attribute_map { :'affiliate' => :'affiliate', :'affiliate_network_pixel_oid' => :'affiliate_network_pixel_oid', :'base_currency_code' => :'base_currency_code', :'billing' => :'billing', :'buysafe' => :'buysafe', :'cart_id' => :'cart_id', :'checkout' => :'checkout', :'coupons' => :'coupons', :'currency_code' => :'currency_code', :'currency_conversion' => :'currency_conversion', :'customer_profile' => :'customer_profile', :'exchange_rate' => :'exchange_rate', :'gift' => :'gift', :'gift_certificate' => :'gift_certificate', :'items' => :'items', :'language_iso_code' => :'language_iso_code', :'logged_in' => :'logged_in', :'marketing' => :'marketing', :'merchant_id' => :'merchant_id', :'payment' => :'payment', :'properties' => :'properties', :'settings' => :'settings', :'shipping' => :'shipping', :'summary' => :'summary', :'taxes' => :'taxes', :'upsell_after' => :'upsell_after' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
388 389 390 |
# File 'lib/ultracart_api/models/cart.rb', line 388 def self.build_from_hash(attributes) new.build_from_hash(attributes) end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
151 152 153 154 |
# File 'lib/ultracart_api/models/cart.rb', line 151 def self.openapi_nullable Set.new([ ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/ultracart_api/models/cart.rb', line 119 def self.openapi_types { :'affiliate' => :'CartAffiliate', :'affiliate_network_pixel_oid' => :'Integer', :'base_currency_code' => :'String', :'billing' => :'CartBilling', :'buysafe' => :'CartBuysafe', :'cart_id' => :'String', :'checkout' => :'CartCheckout', :'coupons' => :'Array<CartCoupon>', :'currency_code' => :'String', :'currency_conversion' => :'CartCurrencyConversion', :'customer_profile' => :'CartCustomerProfile', :'exchange_rate' => :'Float', :'gift' => :'CartGift', :'gift_certificate' => :'CartGiftCertificate', :'items' => :'Array<CartItem>', :'language_iso_code' => :'String', :'logged_in' => :'Boolean', :'marketing' => :'CartMarketing', :'merchant_id' => :'String', :'payment' => :'CartPayment', :'properties' => :'Array<CartProperty>', :'settings' => :'CartSettings', :'shipping' => :'CartShipping', :'summary' => :'CartSummary', :'taxes' => :'CartTaxes', :'upsell_after' => :'CartUpsellAfter' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
# File 'lib/ultracart_api/models/cart.rb', line 342 def ==(o) return true if self.equal?(o) self.class == o.class && affiliate == o.affiliate && affiliate_network_pixel_oid == o.affiliate_network_pixel_oid && base_currency_code == o.base_currency_code && billing == o.billing && buysafe == o.buysafe && cart_id == o.cart_id && checkout == o.checkout && coupons == o.coupons && currency_code == o.currency_code && currency_conversion == o.currency_conversion && customer_profile == o.customer_profile && exchange_rate == o.exchange_rate && gift == o.gift && gift_certificate == o.gift_certificate && items == o.items && language_iso_code == o.language_iso_code && logged_in == o.logged_in && marketing == o.marketing && merchant_id == o.merchant_id && payment == o.payment && properties == o.properties && settings == o.settings && shipping == o.shipping && summary == o.summary && taxes == o.taxes && upsell_after == o.upsell_after end |
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 |
# File 'lib/ultracart_api/models/cart.rb', line 419 def _deserialize(type, value) case type.to_sym when :Time Time.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :Boolean if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model # models (e.g. Pet) or oneOf klass = UltracartClient.const_get(type) klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end |
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value
490 491 492 493 494 495 496 497 498 499 500 501 502 |
# File 'lib/ultracart_api/models/cart.rb', line 490 def _to_hash(value) if value.is_a?(Array) value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end |
#build_from_hash(attributes) ⇒ Object
Builds the object from hash
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 |
# File 'lib/ultracart_api/models/cart.rb', line 395 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) self.class.openapi_types.each_pair do |key, type| if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) self.send("#{key}=", nil) elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end end self end |
#eql?(o) ⇒ Boolean
375 376 377 |
# File 'lib/ultracart_api/models/cart.rb', line 375 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
381 382 383 |
# File 'lib/ultracart_api/models/cart.rb', line 381 def hash [affiliate, affiliate_network_pixel_oid, base_currency_code, billing, buysafe, cart_id, checkout, coupons, currency_code, currency_conversion, customer_profile, exchange_rate, gift, gift_certificate, items, language_iso_code, logged_in, marketing, merchant_id, payment, properties, settings, shipping, summary, taxes, upsell_after].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
# File 'lib/ultracart_api/models/cart.rb', line 284 def list_invalid_properties invalid_properties = Array.new if !@base_currency_code.nil? && @base_currency_code.to_s.length > 3 invalid_properties.push('invalid value for "base_currency_code", the character length must be smaller than or equal to 3.') end if !@currency_code.nil? && @currency_code.to_s.length > 3 invalid_properties.push('invalid value for "currency_code", the character length must be smaller than or equal to 3.') end if !@language_iso_code.nil? && @language_iso_code.to_s.length > 3 invalid_properties.push('invalid value for "language_iso_code", the character length must be smaller than or equal to 3.') end invalid_properties end |
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility)
466 467 468 |
# File 'lib/ultracart_api/models/cart.rb', line 466 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
472 473 474 475 476 477 478 479 480 481 482 483 484 |
# File 'lib/ultracart_api/models/cart.rb', line 472 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end hash[param] = _to_hash(value) end hash end |
#to_s ⇒ String
Returns the string representation of the object
460 461 462 |
# File 'lib/ultracart_api/models/cart.rb', line 460 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
303 304 305 306 307 308 |
# File 'lib/ultracart_api/models/cart.rb', line 303 def valid? return false if !@base_currency_code.nil? && @base_currency_code.to_s.length > 3 return false if !@currency_code.nil? && @currency_code.to_s.length > 3 return false if !@language_iso_code.nil? && @language_iso_code.to_s.length > 3 true end |