Class: AdvancedBilling::RemovePaymentEventData

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/advanced_billing/models/remove_payment_event_data.rb

Overview

Example schema for an ‘remove_payment` event

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(transaction_id = SKIP, memo = SKIP, original_amount = SKIP, applied_amount = SKIP, transaction_time = SKIP, payment_method = SKIP, prepayment = SKIP) ⇒ RemovePaymentEventData

Returns a new instance of RemovePaymentEventData.



73
74
75
76
77
78
79
80
81
82
83
# File 'lib/advanced_billing/models/remove_payment_event_data.rb', line 73

def initialize(transaction_id = SKIP, memo = SKIP, original_amount = SKIP,
               applied_amount = SKIP, transaction_time = SKIP,
               payment_method = SKIP, prepayment = SKIP)
  @transaction_id = transaction_id unless transaction_id == SKIP
  @memo = memo unless memo == SKIP
  @original_amount = original_amount unless original_amount == SKIP
  @applied_amount = applied_amount unless applied_amount == SKIP
  @transaction_time = transaction_time unless transaction_time == SKIP
  @payment_method = payment_method unless payment_method == SKIP
  @prepayment = prepayment unless prepayment == SKIP
end

Instance Attribute Details

#applied_amountString

Applied amount of the original payment

Returns:

  • (String)


27
28
29
# File 'lib/advanced_billing/models/remove_payment_event_data.rb', line 27

def applied_amount
  @applied_amount
end

#memoString

Memo of the original payment

Returns:

  • (String)


19
20
21
# File 'lib/advanced_billing/models/remove_payment_event_data.rb', line 19

def memo
  @memo
end

#original_amountString

Full amount of the original payment

Returns:

  • (String)


23
24
25
# File 'lib/advanced_billing/models/remove_payment_event_data.rb', line 23

def original_amount
  @original_amount
end

#payment_methodObject

A nested data structure detailing the method of payment

Returns:

  • (Object)


36
37
38
# File 'lib/advanced_billing/models/remove_payment_event_data.rb', line 36

def payment_method
  @payment_method
end

#prepaymentTrueClass | FalseClass

The flag that shows whether the original payment was a prepayment or not

Returns:

  • (TrueClass | FalseClass)


40
41
42
# File 'lib/advanced_billing/models/remove_payment_event_data.rb', line 40

def prepayment
  @prepayment
end

#transaction_idInteger

Transaction ID of the original payment that was removed

Returns:

  • (Integer)


15
16
17
# File 'lib/advanced_billing/models/remove_payment_event_data.rb', line 15

def transaction_id
  @transaction_id
end

#transaction_timeDateTime

Transaction time of the original payment, in ISO 8601 format, i.e. “2019-06-07T17:20:06Z”

Returns:

  • (DateTime)


32
33
34
# File 'lib/advanced_billing/models/remove_payment_event_data.rb', line 32

def transaction_time
  @transaction_time
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
112
113
114
115
# File 'lib/advanced_billing/models/remove_payment_event_data.rb', line 86

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.

  transaction_id =
    hash.key?('transaction_id') ? hash['transaction_id'] : SKIP
  memo = hash.key?('memo') ? hash['memo'] : SKIP
  original_amount =
    hash.key?('original_amount') ? hash['original_amount'] : SKIP
  applied_amount =
    hash.key?('applied_amount') ? hash['applied_amount'] : SKIP
  transaction_time = if hash.key?('transaction_time')
                       (DateTimeHelper.from_rfc3339(hash['transaction_time']) if hash['transaction_time'])
                     else
                       SKIP
                     end
  payment_method = hash.key?('payment_method') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:RemovePaymentEventDataPaymentMethod), hash['payment_method']
  ) : SKIP
  prepayment = hash.key?('prepayment') ? hash['prepayment'] : SKIP

  # Create object from extracted values.

  RemovePaymentEventData.new(transaction_id,
                             memo,
                             original_amount,
                             applied_amount,
                             transaction_time,
                             payment_method,
                             prepayment)
end

.namesObject

A mapping from model property names to API property names.



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/advanced_billing/models/remove_payment_event_data.rb', line 43

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['transaction_id'] = 'transaction_id'
  @_hash['memo'] = 'memo'
  @_hash['original_amount'] = 'original_amount'
  @_hash['applied_amount'] = 'applied_amount'
  @_hash['transaction_time'] = 'transaction_time'
  @_hash['payment_method'] = 'payment_method'
  @_hash['prepayment'] = 'prepayment'
  @_hash
end

.nullablesObject

An array for nullable fields



69
70
71
# File 'lib/advanced_billing/models/remove_payment_event_data.rb', line 69

def self.nullables
  []
end

.optionalsObject

An array for optional fields



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/advanced_billing/models/remove_payment_event_data.rb', line 56

def self.optionals
  %w[
    transaction_id
    memo
    original_amount
    applied_amount
    transaction_time
    payment_method
    prepayment
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



123
124
125
126
127
128
129
# File 'lib/advanced_billing/models/remove_payment_event_data.rb', line 123

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end

Instance Method Details

#to_custom_transaction_timeObject



117
118
119
# File 'lib/advanced_billing/models/remove_payment_event_data.rb', line 117

def to_custom_transaction_time
  DateTimeHelper.to_rfc3339(transaction_time)
end