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



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

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?(:'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

#base_currency_codeObject

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



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

def base_currency_code
  @base_currency_code
end

#billingObject

Returns the value of attribute billing.



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

def billing
  @billing
end

#buysafeObject

Returns the value of attribute buysafe.



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

def buysafe
  @buysafe
end

#cart_idObject

Unique identifier for this cart



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

def cart_id
  @cart_id
end

#checkoutObject

Returns the value of attribute checkout.



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

def checkout
  @checkout
end

#couponsObject

Coupons



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

def coupons
  @coupons
end

#currency_codeObject

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



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

def currency_code
  @currency_code
end

#currency_conversionObject

Returns the value of attribute currency_conversion.



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

def currency_conversion
  @currency_conversion
end

#customer_profileObject

Returns the value of attribute customer_profile.



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

def customer_profile
  @customer_profile
end

#exchange_rateObject

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



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

def exchange_rate
  @exchange_rate
end

#giftObject

Returns the value of attribute gift.



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

def gift
  @gift
end

#gift_certificateObject

Returns the value of attribute gift_certificate.



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

def gift_certificate
  @gift_certificate
end

#itemsObject

Items



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

def items
  @items
end

#language_iso_codeObject

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



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

def language_iso_code
  @language_iso_code
end

#logged_inObject

True if the customer is logged into their profile



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

def logged_in
  @logged_in
end

#marketingObject

Returns the value of attribute marketing.



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

def marketing
  @marketing
end

#merchant_idObject

Merchant ID this cart is associated with



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

def merchant_id
  @merchant_id
end

#paymentObject

Returns the value of attribute payment.



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

def payment
  @payment
end

#propertiesObject

Properties associated with the cart



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

def properties
  @properties
end

#settingsObject

Returns the value of attribute settings.



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

def settings
  @settings
end

#shippingObject

Returns the value of attribute shipping.



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

def shipping
  @shipping
end

#summaryObject

Returns the value of attribute summary.



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

def summary
  @summary
end

#taxesObject

Returns the value of attribute taxes.



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

def taxes
  @taxes
end

#upsell_afterObject

Returns the value of attribute upsell_after.



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

def upsell_after
  @upsell_after
end

Class Method Details

.attribute_mapObject

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



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

def self.attribute_map
  {
    :'affiliate' => :'affiliate',
    :'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.



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

def self.swagger_types
  {
    :'affiliate' => :'CartAffiliate',
    :'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



314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
# File 'lib/ultracart_api/models/cart.rb', line 314

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      affiliate == o.affiliate &&
      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



380
381
382
383
384
385
386
387
388
389
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
# File 'lib/ultracart_api/models/cart.rb', line 380

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



446
447
448
449
450
451
452
453
454
455
456
457
458
# File 'lib/ultracart_api/models/cart.rb', line 446

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



359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
# File 'lib/ultracart_api/models/cart.rb', line 359

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


346
347
348
# File 'lib/ultracart_api/models/cart.rb', line 346

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



352
353
354
# File 'lib/ultracart_api/models/cart.rb', line 352

def hash
  [affiliate, 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



256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# File 'lib/ultracart_api/models/cart.rb', line 256

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



426
427
428
# File 'lib/ultracart_api/models/cart.rb', line 426

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



432
433
434
435
436
437
438
439
440
# File 'lib/ultracart_api/models/cart.rb', line 432

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



420
421
422
# File 'lib/ultracart_api/models/cart.rb', line 420

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



275
276
277
278
279
280
# File 'lib/ultracart_api/models/cart.rb', line 275

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