Class: Cryptopay::InvoiceRecalculation

Inherits:
Object
  • Object
show all
Defined in:
lib/cryptopay/models/invoice_recalculation.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ InvoiceRecalculation

Initializes the object

Parameters:

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

    Model attributes in the form of hash



56
57
58
# File 'lib/cryptopay/models/invoice_recalculation.rb', line 56

def initialize(attributes = {})
  @attributes = ENCODER.sanitize(attributes)
end

Class Method Details

.build_from_hash(data) ⇒ Cryptopay::InvoiceRecalculation

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:



49
50
51
52
# File 'lib/cryptopay/models/invoice_recalculation.rb', line 49

def self.build_from_hash(data)
  attributes = ENCODER.build_from_hash(data)
  new(attributes)
end

Instance Method Details

#created_atObject

Recalculation creation date and time



120
121
122
# File 'lib/cryptopay/models/invoice_recalculation.rb', line 120

def created_at
  @attributes[:created_at]
end

#exchangeObject



115
116
117
# File 'lib/cryptopay/models/invoice_recalculation.rb', line 115

def exchange
  @attributes[:exchange]
end

#feeObject

Processing fee



91
92
93
# File 'lib/cryptopay/models/invoice_recalculation.rb', line 91

def fee
  @attributes[:fee]
end

#fee_currencyObject

Processing fee currency



96
97
98
# File 'lib/cryptopay/models/invoice_recalculation.rb', line 96

def fee_currency
  @attributes[:fee_currency]
end

#idObject

Recalculation ID



61
62
63
# File 'lib/cryptopay/models/invoice_recalculation.rb', line 61

def id
  @attributes[:id]
end

#inspectObject



174
175
176
# File 'lib/cryptopay/models/invoice_recalculation.rb', line 174

def inspect
  "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash)
end

#invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/cryptopay/models/invoice_recalculation.rb', line 126

def invalid_properties
  properties = []

  properties.push('invalid value for "id", id cannot be nil.') if id.nil?

  properties.push('invalid value for "invoice_id", invoice_id cannot be nil.') if invoice_id.nil?

  properties.push('invalid value for "pay_amount", pay_amount cannot be nil.') if pay_amount.nil?

  properties.push('invalid value for "pay_currency", pay_currency cannot be nil.') if pay_currency.nil?

  properties.push('invalid value for "price_amount", price_amount cannot be nil.') if price_amount.nil?

  properties.push('invalid value for "price_currency", price_currency cannot be nil.') if price_currency.nil?

  properties.push('invalid value for "fee", fee cannot be nil.') if fee.nil?

  properties.push('invalid value for "fee_currency", fee_currency cannot be nil.') if fee_currency.nil?

  if previous_pay_amount.nil?
    properties.push('invalid value for "previous_pay_amount", previous_pay_amount cannot be nil.')
  end

  if previous_price_amount.nil?
    properties.push('invalid value for "previous_price_amount", previous_price_amount cannot be nil.')
  end

  exchange&.invalid_properties&.each do |prop|
    properties.push("invalid value for \"exchange\": #{prop}")
  end

  properties.push('invalid value for "created_at", created_at cannot be nil.') if created_at.nil?

  properties
end

#invoice_idObject

Invoice ID



66
67
68
# File 'lib/cryptopay/models/invoice_recalculation.rb', line 66

def invoice_id
  @attributes[:invoice_id]
end

#pay_amountObject

Cryptocurrency amount received



71
72
73
# File 'lib/cryptopay/models/invoice_recalculation.rb', line 71

def pay_amount
  @attributes[:pay_amount]
end

#pay_currencyObject

Cryptocurrency type



76
77
78
# File 'lib/cryptopay/models/invoice_recalculation.rb', line 76

def pay_currency
  @attributes[:pay_currency]
end

#previous_exchange_rateObject

Previous exchange rate



111
112
113
# File 'lib/cryptopay/models/invoice_recalculation.rb', line 111

def previous_exchange_rate
  @attributes[:previous_exchange_rate]
end

#previous_pay_amountObject

Previous amount to pay



101
102
103
# File 'lib/cryptopay/models/invoice_recalculation.rb', line 101

def previous_pay_amount
  @attributes[:previous_pay_amount]
end

#previous_price_amountObject

Previous invoice amount



106
107
108
# File 'lib/cryptopay/models/invoice_recalculation.rb', line 106

def previous_price_amount
  @attributes[:previous_price_amount]
end

#price_amountObject

New invoice amount



81
82
83
# File 'lib/cryptopay/models/invoice_recalculation.rb', line 81

def price_amount
  @attributes[:price_amount]
end

#price_currencyObject

Invoice amount currency



86
87
88
# File 'lib/cryptopay/models/invoice_recalculation.rb', line 86

def price_currency
  @attributes[:price_currency]
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



170
171
172
# File 'lib/cryptopay/models/invoice_recalculation.rb', line 170

def to_hash
  ENCODER.to_hash(@attributes)
end

#valid?Boolean

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

Returns:

  • (Boolean)

    true if the model is valid



164
165
166
# File 'lib/cryptopay/models/invoice_recalculation.rb', line 164

def valid?
  invalid_properties.empty?
end