Class: UltracartClient::AutoOrderItem

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

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ AutoOrderItem

Initializes the object

Parameters:

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

    Model attributes in the form of 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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'lib/ultracart_api/models/auto_order_item.rb', line 182

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?(:'arbitrary_item_id')
    self.arbitrary_item_id = attributes[:'arbitrary_item_id']
  end

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Instance Attribute Details

#arbitrary_item_idObject

Arbitrary item id that should be rebilled instead of the normal schedule



18
19
20
# File 'lib/ultracart_api/models/auto_order_item.rb', line 18

def arbitrary_item_id
  @arbitrary_item_id
end

#arbitrary_percentage_discountObject

An arbitrary percentage discount to provide on future rebills



21
22
23
# File 'lib/ultracart_api/models/auto_order_item.rb', line 21

def arbitrary_percentage_discount
  @arbitrary_percentage_discount
end

#arbitrary_quantityObject

Arbitrary quantity to rebill



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

def arbitrary_quantity
  @arbitrary_quantity
end

#arbitrary_schedule_daysObject

The number of days to rebill if the frequency is set to an arbitrary number of days



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

def arbitrary_schedule_days
  @arbitrary_schedule_days
end

#arbitrary_unit_costObject

Arbitrary unit cost that rebills of this item should occur at



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

def arbitrary_unit_cost
  @arbitrary_unit_cost
end

#arbitrary_unit_cost_remaining_ordersObject

The number of rebills to give the arbitrary unit cost on before reverting to normal pricing.



33
34
35
# File 'lib/ultracart_api/models/auto_order_item.rb', line 33

def arbitrary_unit_cost_remaining_orders
  @arbitrary_unit_cost_remaining_orders
end

#auto_order_item_oidObject

Primary key of AutoOrderItem



36
37
38
# File 'lib/ultracart_api/models/auto_order_item.rb', line 36

def auto_order_item_oid
  @auto_order_item_oid
end

#first_order_dtsObject

Date/time of the first order of this item. Null if item added to auto order and has not been rebilled yet.



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

def first_order_dts
  @first_order_dts
end

#frequencyObject

Frequency of the rebill if not a fixed schedule



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

def frequency
  @frequency
end

#future_schedulesObject

The future rebill schedule for this item up to the next ten rebills



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

def future_schedules
  @future_schedules
end

#last_order_dtsObject

Date/time of the last order of this item



48
49
50
# File 'lib/ultracart_api/models/auto_order_item.rb', line 48

def last_order_dts
  @last_order_dts
end

#life_time_valueObject

The life time value of this item including the original purchase



51
52
53
# File 'lib/ultracart_api/models/auto_order_item.rb', line 51

def life_time_value
  @life_time_value
end

#next_preshipment_notice_dtsObject

The date/time of when the next pre-shipment notice should be sent



54
55
56
# File 'lib/ultracart_api/models/auto_order_item.rb', line 54

def next_preshipment_notice_dts
  @next_preshipment_notice_dts
end

#next_shipment_dtsObject

Date/time that this item is scheduled to rebill



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

def next_shipment_dts
  @next_shipment_dts
end

#no_order_after_dtsObject

Date/time after which no additional rebills of this item should occur



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

def no_order_after_dts
  @no_order_after_dts
end

#number_of_rebillsObject

The number of times this item has rebilled



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

def number_of_rebills
  @number_of_rebills
end

#optionsObject

Options associated with this item



66
67
68
# File 'lib/ultracart_api/models/auto_order_item.rb', line 66

def options
  @options
end

#original_item_idObject

The original item id purchased. This item controls scheduling. If you wish to modify a schedule, for example, from monthly to yearly, change this item from your monthly item to your yearly item, and then change the next_shipment_dts to your desired date.



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

def original_item_id
  @original_item_id
end

#original_quantityObject

The original quantity purchased



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

def original_quantity
  @original_quantity
end

#pausedObject

True if paused. This field is an object instead of a primitive for backwards compatibility.



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

def paused
  @paused
end

#paypal_payer_idObject

The PayPal Payer ID tied to this item



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

def paypal_payer_id
  @paypal_payer_id
end

#paypal_recurring_payment_profile_idObject

The PayPal Profile ID tied to this item



81
82
83
# File 'lib/ultracart_api/models/auto_order_item.rb', line 81

def paypal_recurring_payment_profile_id
  @paypal_recurring_payment_profile_id
end

#preshipment_notice_sentObject

True if the preshipment notice associated with the next rebill has been sent



84
85
86
# File 'lib/ultracart_api/models/auto_order_item.rb', line 84

def preshipment_notice_sent
  @preshipment_notice_sent
end

#rebill_valueObject

The value of the rebills of this item



87
88
89
# File 'lib/ultracart_api/models/auto_order_item.rb', line 87

def rebill_value
  @rebill_value
end

#remaining_repeat_countObject

The number of rebills remaining before this item is complete



90
91
92
# File 'lib/ultracart_api/models/auto_order_item.rb', line 90

def remaining_repeat_count
  @remaining_repeat_count
end

#simple_scheduleObject

Returns the value of attribute simple_schedule.



92
93
94
# File 'lib/ultracart_api/models/auto_order_item.rb', line 92

def simple_schedule
  @simple_schedule
end

Class Method Details

.attribute_mapObject

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



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
143
144
145
146
# File 'lib/ultracart_api/models/auto_order_item.rb', line 117

def self.attribute_map
  {
    :'arbitrary_item_id' => :'arbitrary_item_id',
    :'arbitrary_percentage_discount' => :'arbitrary_percentage_discount',
    :'arbitrary_quantity' => :'arbitrary_quantity',
    :'arbitrary_schedule_days' => :'arbitrary_schedule_days',
    :'arbitrary_unit_cost' => :'arbitrary_unit_cost',
    :'arbitrary_unit_cost_remaining_orders' => :'arbitrary_unit_cost_remaining_orders',
    :'auto_order_item_oid' => :'auto_order_item_oid',
    :'first_order_dts' => :'first_order_dts',
    :'frequency' => :'frequency',
    :'future_schedules' => :'future_schedules',
    :'last_order_dts' => :'last_order_dts',
    :'life_time_value' => :'life_time_value',
    :'next_preshipment_notice_dts' => :'next_preshipment_notice_dts',
    :'next_shipment_dts' => :'next_shipment_dts',
    :'no_order_after_dts' => :'no_order_after_dts',
    :'number_of_rebills' => :'number_of_rebills',
    :'options' => :'options',
    :'original_item_id' => :'original_item_id',
    :'original_quantity' => :'original_quantity',
    :'paused' => :'paused',
    :'paypal_payer_id' => :'paypal_payer_id',
    :'paypal_recurring_payment_profile_id' => :'paypal_recurring_payment_profile_id',
    :'preshipment_notice_sent' => :'preshipment_notice_sent',
    :'rebill_value' => :'rebill_value',
    :'remaining_repeat_count' => :'remaining_repeat_count',
    :'simple_schedule' => :'simple_schedule'
  }
end

.swagger_typesObject

Attribute type mapping.



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

def self.swagger_types
  {
    :'arbitrary_item_id' => :'String',
    :'arbitrary_percentage_discount' => :'Float',
    :'arbitrary_quantity' => :'Float',
    :'arbitrary_schedule_days' => :'Integer',
    :'arbitrary_unit_cost' => :'Float',
    :'arbitrary_unit_cost_remaining_orders' => :'Integer',
    :'auto_order_item_oid' => :'Integer',
    :'first_order_dts' => :'String',
    :'frequency' => :'String',
    :'future_schedules' => :'Array<AutoOrderItemFutureSchedule>',
    :'last_order_dts' => :'String',
    :'life_time_value' => :'Float',
    :'next_preshipment_notice_dts' => :'String',
    :'next_shipment_dts' => :'String',
    :'no_order_after_dts' => :'String',
    :'number_of_rebills' => :'Integer',
    :'options' => :'Array<AutoOrderItemOption>',
    :'original_item_id' => :'String',
    :'original_quantity' => :'Float',
    :'paused' => :'BOOLEAN',
    :'paypal_payer_id' => :'String',
    :'paypal_recurring_payment_profile_id' => :'String',
    :'preshipment_notice_sent' => :'BOOLEAN',
    :'rebill_value' => :'Float',
    :'remaining_repeat_count' => :'Integer',
    :'simple_schedule' => :'AutoOrderItemSimpleSchedule'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



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
353
# File 'lib/ultracart_api/models/auto_order_item.rb', line 324

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      arbitrary_item_id == o.arbitrary_item_id &&
      arbitrary_percentage_discount == o.arbitrary_percentage_discount &&
      arbitrary_quantity == o.arbitrary_quantity &&
      arbitrary_schedule_days == o.arbitrary_schedule_days &&
      arbitrary_unit_cost == o.arbitrary_unit_cost &&
      arbitrary_unit_cost_remaining_orders == o.arbitrary_unit_cost_remaining_orders &&
      auto_order_item_oid == o.auto_order_item_oid &&
      first_order_dts == o.first_order_dts &&
      frequency == o.frequency &&
      future_schedules == o.future_schedules &&
      last_order_dts == o.last_order_dts &&
      life_time_value == o.life_time_value &&
      next_preshipment_notice_dts == o.next_preshipment_notice_dts &&
      next_shipment_dts == o.next_shipment_dts &&
      no_order_after_dts == o.no_order_after_dts &&
      number_of_rebills == o.number_of_rebills &&
      options == o.options &&
      original_item_id == o.original_item_id &&
      original_quantity == o.original_quantity &&
      paused == o.paused &&
      paypal_payer_id == o.paypal_payer_id &&
      paypal_recurring_payment_profile_id == o.paypal_recurring_payment_profile_id &&
      preshipment_notice_sent == o.preshipment_notice_sent &&
      rebill_value == o.rebill_value &&
      remaining_repeat_count == o.remaining_repeat_count &&
      simple_schedule == o.simple_schedule
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



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
427
# File 'lib/ultracart_api/models/auto_order_item.rb', line 391

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



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

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



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

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


357
358
359
# File 'lib/ultracart_api/models/auto_order_item.rb', line 357

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



363
364
365
# File 'lib/ultracart_api/models/auto_order_item.rb', line 363

def hash
  [arbitrary_item_id, arbitrary_percentage_discount, arbitrary_quantity, arbitrary_schedule_days, arbitrary_unit_cost, arbitrary_unit_cost_remaining_orders, auto_order_item_oid, first_order_dts, frequency, future_schedules, last_order_dts, life_time_value, next_preshipment_notice_dts, next_shipment_dts, no_order_after_dts, number_of_rebills, options, original_item_id, original_quantity, paused, paypal_payer_id, paypal_recurring_payment_profile_id, preshipment_notice_sent, rebill_value, remaining_repeat_count, simple_schedule].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



299
300
301
302
# File 'lib/ultracart_api/models/auto_order_item.rb', line 299

def list_invalid_properties
  invalid_properties = Array.new
  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



437
438
439
# File 'lib/ultracart_api/models/auto_order_item.rb', line 437

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



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

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



431
432
433
# File 'lib/ultracart_api/models/auto_order_item.rb', line 431

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



306
307
308
309
310
# File 'lib/ultracart_api/models/auto_order_item.rb', line 306

def valid?
  frequency_validator = EnumAttributeValidator.new('String', ['Weekly', 'Biweekly', 'Every...', 'Every 10 Days', 'Every 24 Days', 'Every 28 Days', 'Monthly', 'Every 45 Days', 'Every 2 Months', 'Every 3 Months', 'Every 4 Months', 'Every 6 Months', 'Yearly', 'Every 4 Weeks', 'Every 6 Weeks', 'Every 8 Weeks'])
  return false unless frequency_validator.valid?(@frequency)
  true
end