Class: UltracartClient::Cart

Inherits:
Object
  • Object
show all
Defined in:
lib/ultracart_api/models/cart.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Cart

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



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
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
# File 'lib/ultracart_api/models/cart.rb', line 146

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }

  if attributes.has_key?(:'affiliate')
    self.affiliate = attributes[:'affiliate']
  end

  if attributes.has_key?(:'affiliate_network_pixel_oid')
    self.affiliate_network_pixel_oid = attributes[:'affiliate_network_pixel_oid']
  end

  if attributes.has_key?(:'base_currency_code')
    self.base_currency_code = attributes[:'base_currency_code']
  end

  if attributes.has_key?(:'billing')
    self.billing = attributes[:'billing']
  end

  if attributes.has_key?(:'buysafe')
    self.buysafe = attributes[:'buysafe']
  end

  if attributes.has_key?(:'cart_id')
    self.cart_id = attributes[:'cart_id']
  end

  if attributes.has_key?(:'checkout')
    self.checkout = attributes[:'checkout']
  end

  if attributes.has_key?(:'coupons')
    if (value = attributes[:'coupons']).is_a?(Array)
      self.coupons = value
    end
  end

  if attributes.has_key?(:'currency_code')
    self.currency_code = attributes[:'currency_code']
  end

  if attributes.has_key?(:'currency_conversion')
    self.currency_conversion = attributes[:'currency_conversion']
  end

  if attributes.has_key?(:'customer_profile')
    self.customer_profile = attributes[:'customer_profile']
  end

  if attributes.has_key?(:'exchange_rate')
    self.exchange_rate = attributes[:'exchange_rate']
  end

  if attributes.has_key?(:'gift')
    self.gift = attributes[:'gift']
  end

  if attributes.has_key?(:'gift_certificate')
    self.gift_certificate = attributes[:'gift_certificate']
  end

  if attributes.has_key?(:'items')
    if (value = attributes[:'items']).is_a?(Array)
      self.items = value
    end
  end

  if attributes.has_key?(:'language_iso_code')
    self.language_iso_code = attributes[:'language_iso_code']
  end

  if attributes.has_key?(:'logged_in')
    self.logged_in = attributes[:'logged_in']
  end

  if attributes.has_key?(:'marketing')
    self.marketing = attributes[:'marketing']
  end

  if attributes.has_key?(:'merchant_id')
    self.merchant_id = attributes[:'merchant_id']
  end

  if attributes.has_key?(:'payment')
    self.payment = attributes[:'payment']
  end

  if attributes.has_key?(:'properties')
    if (value = attributes[:'properties']).is_a?(Array)
      self.properties = value
    end
  end

  if attributes.has_key?(:'settings')
    self.settings = attributes[:'settings']
  end

  if attributes.has_key?(:'shipping')
    self.shipping = attributes[:'shipping']
  end

  if attributes.has_key?(:'summary')
    self.summary = attributes[:'summary']
  end

  if attributes.has_key?(:'taxes')
    self.taxes = attributes[:'taxes']
  end

  if attributes.has_key?(:'upsell_after')
    self.upsell_after = attributes[:'upsell_after']
  end
end

Instance Attribute Details

#affiliateObject

Returns the value of attribute affiliate.



17
18
19
# File 'lib/ultracart_api/models/cart.rb', line 17

def affiliate
  @affiliate
end

#affiliate_network_pixel_oidObject

The affiliate network pixel identifier associated with the cart



20
21
22
# File 'lib/ultracart_api/models/cart.rb', line 20

def affiliate_network_pixel_oid
  @affiliate_network_pixel_oid
end

#base_currency_codeObject

The ISO-4217 three letter base currency code of the account



23
24
25
# File 'lib/ultracart_api/models/cart.rb', line 23

def base_currency_code
  @base_currency_code
end

#billingObject

Returns the value of attribute billing.



25
26
27
# File 'lib/ultracart_api/models/cart.rb', line 25

def billing
  @billing
end

#buysafeObject

Returns the value of attribute buysafe.



27
28
29
# File 'lib/ultracart_api/models/cart.rb', line 27

def buysafe
  @buysafe
end

#cart_idObject

Unique identifier for this cart



30
31
32
# File 'lib/ultracart_api/models/cart.rb', line 30

def cart_id
  @cart_id
end

#checkoutObject

Returns the value of attribute checkout.



32
33
34
# File 'lib/ultracart_api/models/cart.rb', line 32

def checkout
  @checkout
end

#couponsObject

Coupons



35
36
37
# File 'lib/ultracart_api/models/cart.rb', line 35

def coupons
  @coupons
end

#currency_codeObject

The ISO-4217 three letter currency code the customer is viewing prices in



38
39
40
# File 'lib/ultracart_api/models/cart.rb', line 38

def currency_code
  @currency_code
end

#currency_conversionObject

Returns the value of attribute currency_conversion.



40
41
42
# File 'lib/ultracart_api/models/cart.rb', line 40

def currency_conversion
  @currency_conversion
end

#customer_profileObject

Returns the value of attribute customer_profile.



42
43
44
# File 'lib/ultracart_api/models/cart.rb', line 42

def customer_profile
  @customer_profile
end

#exchange_rateObject

The exchange rate if the customer is viewing a different currency than the base



45
46
47
# File 'lib/ultracart_api/models/cart.rb', line 45

def exchange_rate
  @exchange_rate
end

#giftObject

Returns the value of attribute gift.



47
48
49
# File 'lib/ultracart_api/models/cart.rb', line 47

def gift
  @gift
end

#gift_certificateObject

Returns the value of attribute gift_certificate.



49
50
51
# File 'lib/ultracart_api/models/cart.rb', line 49

def gift_certificate
  @gift_certificate
end

#itemsObject

Items



52
53
54
# File 'lib/ultracart_api/models/cart.rb', line 52

def items
  @items
end

#language_iso_codeObject

The ISO-631 three letter code the customer would like to checkout with



55
56
57
# File 'lib/ultracart_api/models/cart.rb', line 55

def language_iso_code
  @language_iso_code
end

#logged_inObject

True if the customer is logged into their profile



58
59
60
# File 'lib/ultracart_api/models/cart.rb', line 58

def logged_in
  @logged_in
end

#marketingObject

Returns the value of attribute marketing.



60
61
62
# File 'lib/ultracart_api/models/cart.rb', line 60

def marketing
  @marketing
end

#merchant_idObject

Merchant ID this cart is associated with



63
64
65
# File 'lib/ultracart_api/models/cart.rb', line 63

def merchant_id
  @merchant_id
end

#paymentObject

Returns the value of attribute payment.



65
66
67
# File 'lib/ultracart_api/models/cart.rb', line 65

def payment
  @payment
end

#propertiesObject

Properties associated with the cart



68
69
70
# File 'lib/ultracart_api/models/cart.rb', line 68

def properties
  @properties
end

#settingsObject

Returns the value of attribute settings.



70
71
72
# File 'lib/ultracart_api/models/cart.rb', line 70

def settings
  @settings
end

#shippingObject

Returns the value of attribute shipping.



72
73
74
# File 'lib/ultracart_api/models/cart.rb', line 72

def shipping
  @shipping
end

#summaryObject

Returns the value of attribute summary.



74
75
76
# File 'lib/ultracart_api/models/cart.rb', line 74

def summary
  @summary
end

#taxesObject

Returns the value of attribute taxes.



76
77
78
# File 'lib/ultracart_api/models/cart.rb', line 76

def taxes
  @taxes
end

#upsell_afterObject

Returns the value of attribute upsell_after.



78
79
80
# File 'lib/ultracart_api/models/cart.rb', line 78

def upsell_after
  @upsell_after
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



81
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
# File 'lib/ultracart_api/models/cart.rb', line 81

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

.swagger_typesObject

Attribute type mapping.



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/ultracart_api/models/cart.rb', line 113

def self.swagger_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.

Parameters:

  • Object (Object)

    to be compared



323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
# File 'lib/ultracart_api/models/cart.rb', line 323

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

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
# File 'lib/ultracart_api/models/cart.rb', line 390

def _deserialize(type, value)
  case type.to_sym
  when :DateTime
    DateTime.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
    temp_model = UltracartClient.const_get(type).new
    temp_model.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

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



456
457
458
459
460
461
462
463
464
465
466
467
468
# File 'lib/ultracart_api/models/cart.rb', line 456

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

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
# File 'lib/ultracart_api/models/cart.rb', line 369

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.swagger_types.each_pair do |key, type|
    if 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 # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


356
357
358
# File 'lib/ultracart_api/models/cart.rb', line 356

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



362
363
364
# File 'lib/ultracart_api/models/cart.rb', line 362

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_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
# File 'lib/ultracart_api/models/cart.rb', line 265

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_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



436
437
438
# File 'lib/ultracart_api/models/cart.rb', line 436

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



442
443
444
445
446
447
448
449
450
# File 'lib/ultracart_api/models/cart.rb', line 442

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    next if value.nil?
    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



430
431
432
# File 'lib/ultracart_api/models/cart.rb', line 430

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



284
285
286
287
288
289
# File 'lib/ultracart_api/models/cart.rb', line 284

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