Class: PostfinancecheckoutRubySdk::SubscriptionCharge

Inherits:
Object
  • Object
show all
Defined in:
lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb

Overview

The subscription charge represents a single charge carried out for a particular subscription.

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ SubscriptionCharge

Initializes the object



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
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 174

def initialize(attributes = {})
  unless attributes.is_a?(Hash)
    fail ArgumentError, "The input argument (attributes) must be a hash in `PostfinancecheckoutRubySdk::SubscriptionCharge` 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|
    unless self.class.attribute_map.key?(k.to_sym)
      fail ArgumentError, "`#{k}` is not a valid attribute in `PostfinancecheckoutRubySdk::SubscriptionCharge`. 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?(:'discarded_on')
    self.discarded_on = attributes[:'discarded_on']
  end

  if attributes.key?(:'planned_execution_date')
    self.planned_execution_date = attributes[:'planned_execution_date']
  end

  if attributes.key?(:'processing_type')
    self.processing_type = attributes[:'processing_type']
  end

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

  if attributes.key?(:'discarded_by')
    self.discarded_by = attributes[:'discarded_by']
  end

  if attributes.key?(:'planned_purge_date')
    self.planned_purge_date = attributes[:'planned_purge_date']
  end

  if attributes.key?(:'external_id')
    self.external_id = attributes[:'external_id']
  end

  if attributes.key?(:'success_url')
    self.success_url = attributes[:'success_url']
  end

  if attributes.key?(:'language')
    self.language = attributes[:'language']
  end

  if attributes.key?(:'subscription')
    self.subscription = attributes[:'subscription']
  end

  if attributes.key?(:'type')
    self.type = attributes[:'type']
  end

  if attributes.key?(:'created_on')
    self.created_on = attributes[:'created_on']
  end

  if attributes.key?(:'version')
    self.version = attributes[:'version']
  end

  if attributes.key?(:'reference')
    self.reference = attributes[:'reference']
  end

  if attributes.key?(:'linked_space_id')
    self.linked_space_id = attributes[:'linked_space_id']
  end

  if attributes.key?(:'id')
    self.id = attributes[:'id']
  end

  if attributes.key?(:'state')
    self.state = attributes[:'state']
  end

  if attributes.key?(:'failed_on')
    self.failed_on = attributes[:'failed_on']
  end

  if attributes.key?(:'transaction')
    self.transaction = attributes[:'transaction']
  end

  if attributes.key?(:'failed_url')
    self.failed_url = attributes[:'failed_url']
  end

  if attributes.key?(:'succeed_on')
    self.succeed_on = attributes[:'succeed_on']
  end
end

Instance Attribute Details

#created_onObject

The date and time when the charge was created.



58
59
60
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 58

def created_on
  @created_on
end

#discarded_byObject

The ID of the user the charge was discarded by.



39
40
41
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 39

def discarded_by
  @discarded_by
end

#discarded_onObject

The date and time when the charge was discarded.



28
29
30
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 28

def discarded_on
  @discarded_on
end

#external_idObject

A client-generated nonce which uniquely identifies some action to be executed. Subsequent requests with the same external ID do not execute the action again, but return the original result.



45
46
47
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 45

def external_id
  @external_id
end

#failed_onObject

The date and time when the charge failed.



75
76
77
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 75

def failed_on
  @failed_on
end

#failed_urlObject

The URL to redirect the customer back to after they canceled or failed to authenticated their payment.



80
81
82
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 80

def failed_url
  @failed_url
end

#idObject

A unique identifier for the object.



70
71
72
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 70

def id
  @id
end

#languageObject

The language that is linked to the object.



51
52
53
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 51

def language
  @language
end

#ledger_entriesObject

The ledger entries that belong to the charge.



36
37
38
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 36

def ledger_entries
  @ledger_entries
end

#linked_space_idObject

The ID of the space this object belongs to.



67
68
69
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 67

def linked_space_id
  @linked_space_id
end

#planned_execution_dateObject

The date and time when the execution of the charge is planned.



31
32
33
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 31

def planned_execution_date
  @planned_execution_date
end

#planned_purge_dateObject

The date and time when the object is planned to be permanently removed. If the value is empty, the object will not be removed.



42
43
44
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 42

def planned_purge_date
  @planned_purge_date
end

#processing_typeObject

Returns the value of attribute processing_type.



33
34
35
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 33

def processing_type
  @processing_type
end

#referenceObject

The merchant’s reference used to identify the charge.



64
65
66
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 64

def reference
  @reference
end

#stateObject

Returns the value of attribute state.



72
73
74
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 72

def state
  @state
end

#subscriptionObject

Returns the value of attribute subscription.



53
54
55
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 53

def subscription
  @subscription
end

#succeed_onObject

The date and time when the charge succeeded.



83
84
85
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 83

def succeed_on
  @succeed_on
end

#success_urlObject

The URL to redirect the customer back to after they successfully authenticated their payment.



48
49
50
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 48

def success_url
  @success_url
end

#transactionObject

Returns the value of attribute transaction.



77
78
79
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 77

def transaction
  @transaction
end

#typeObject

Returns the value of attribute type.



55
56
57
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 55

def type
  @type
end

#versionObject

The version is used for optimistic locking and incremented whenever the object is updated.



61
62
63
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 61

def version
  @version
end

Class Method Details

._deserialize(type, value) ⇒ Object

Deserializes the data based on type



451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 451

def self._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 = PostfinancecheckoutRubySdk.const_get(type)
    klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
  end
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



135
136
137
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 135

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

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



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 108

def self.attribute_map
  {
    :'discarded_on' => :'discardedOn',
    :'planned_execution_date' => :'plannedExecutionDate',
    :'processing_type' => :'processingType',
    :'ledger_entries' => :'ledgerEntries',
    :'discarded_by' => :'discardedBy',
    :'planned_purge_date' => :'plannedPurgeDate',
    :'external_id' => :'externalId',
    :'success_url' => :'successUrl',
    :'language' => :'language',
    :'subscription' => :'subscription',
    :'type' => :'type',
    :'created_on' => :'createdOn',
    :'version' => :'version',
    :'reference' => :'reference',
    :'linked_space_id' => :'linkedSpaceId',
    :'id' => :'id',
    :'state' => :'state',
    :'failed_on' => :'failedOn',
    :'transaction' => :'transaction',
    :'failed_url' => :'failedUrl',
    :'succeed_on' => :'succeedOn'
  }
end

.build_from_hash(attributes) ⇒ Object



427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 427

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{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[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



167
168
169
170
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 167

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 140

def self.openapi_types
  {
    :'discarded_on' => :'Time',
    :'planned_execution_date' => :'Time',
    :'processing_type' => :'SubscriptionChargeProcessingType',
    :'ledger_entries' => :'Array<SubscriptionLedgerEntry>',
    :'discarded_by' => :'Integer',
    :'planned_purge_date' => :'Time',
    :'external_id' => :'String',
    :'success_url' => :'String',
    :'language' => :'String',
    :'subscription' => :'Subscription',
    :'type' => :'SubscriptionChargeType',
    :'created_on' => :'Time',
    :'version' => :'Integer',
    :'reference' => :'String',
    :'linked_space_id' => :'Integer',
    :'id' => :'Integer',
    :'state' => :'SubscriptionChargeState',
    :'failed_on' => :'Time',
    :'transaction' => :'Transaction',
    :'failed_url' => :'String',
    :'succeed_on' => :'Time'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.



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
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 388

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      discarded_on == o.discarded_on &&
      planned_execution_date == o.planned_execution_date &&
      processing_type == o.processing_type &&
      ledger_entries == o.ledger_entries &&
      discarded_by == o.discarded_by &&
      planned_purge_date == o.planned_purge_date &&
      external_id == o.external_id &&
      success_url == o.success_url &&
      language == o.language &&
      subscription == o.subscription &&
      type == o.type &&
      created_on == o.created_on &&
      version == o.version &&
      reference == o.reference &&
      linked_space_id == o.linked_space_id &&
      id == o.id &&
      state == o.state &&
      failed_on == o.failed_on &&
      transaction == o.transaction &&
      failed_url == o.failed_url &&
      succeed_on == o.succeed_on
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value



522
523
524
525
526
527
528
529
530
531
532
533
534
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 522

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

#eql?(o) ⇒ Boolean

See Also:

  • `==` method


416
417
418
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 416

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.



422
423
424
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 422

def hash
  [discarded_on, planned_execution_date, processing_type, ledger_entries, discarded_by, planned_purge_date, external_id, success_url, language, subscription, type, created_on, version, reference, linked_space_id, id, state, failed_on, transaction, failed_url, succeed_on].hash
end

#list_invalid_propertiesObject

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



276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 276

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if !@success_url.nil? && @success_url.to_s.length > 500
    invalid_properties.push('invalid value for "success_url", the character length must be smaller than or equal to 500.')
  end

  if !@success_url.nil? && @success_url.to_s.length < 9
    invalid_properties.push('invalid value for "success_url", the character length must be greater than or equal to 9.')
  end

  if !@reference.nil? && @reference.to_s.length > 100
    invalid_properties.push('invalid value for "reference", the character length must be smaller than or equal to 100.')
  end

  pattern = Regexp.new(/[	\x20-\x7e]*/)
  if !@reference.nil? && @reference !~ pattern
    invalid_properties.push("invalid value for \"reference\", must conform to the pattern #{pattern}.")
  end

  if !@failed_url.nil? && @failed_url.to_s.length > 500
    invalid_properties.push('invalid value for "failed_url", the character length must be smaller than or equal to 500.')
  end

  if !@failed_url.nil? && @failed_url.to_s.length < 9
    invalid_properties.push('invalid value for "failed_url", the character length must be greater than or equal to 9.')
  end

  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)



498
499
500
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 498

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash



504
505
506
507
508
509
510
511
512
513
514
515
516
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 504

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_sString

Returns the string representation of the object



492
493
494
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 492

def to_s
  to_hash.to_s
end

#valid?Boolean

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



309
310
311
312
313
314
315
316
317
318
319
# File 'lib/postfinancecheckout-ruby-sdk/models/subscription_charge.rb', line 309

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if !@success_url.nil? && @success_url.to_s.length > 500
  return false if !@success_url.nil? && @success_url.to_s.length < 9
  return false if !@reference.nil? && @reference.to_s.length > 100
  pattern = Regexp.new(/[	\x20-\x7e]*/)
  return false if !@reference.nil? && @reference !~ pattern
  return false if !@failed_url.nil? && @failed_url.to_s.length > 500
  return false if !@failed_url.nil? && @failed_url.to_s.length < 9
  true
end