Class: Cryptopay::InvoiceRefund

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ InvoiceRefund

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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

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

Class Method Details

.build_from_hash(data) ⇒ Cryptopay::InvoiceRefund

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_refund.rb', line 49

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

Instance Method Details

#addressObject

Cryptocurrency address the refund transaction sent to



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

def address
  @attributes[:address]
end

#amountObject

Refund amount



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

def amount
  @attributes[:amount]
end

#amount_currencyObject

Refund currency



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

def amount_currency
  @attributes[:amount_currency]
end

#created_atObject

Refund transaction creation date and time



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

def created_at
  @attributes[:created_at]
end

#custom_idObject

Refund ‘custom_id`. The value is being inherited from the parent invoice



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

def custom_id
  @attributes[:custom_id]
end

#feeObject

Processing fee



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

def fee
  @attributes[:fee]
end

#fee_currencyObject

Processing fee currency



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

def fee_currency
  @attributes[:fee_currency]
end

#idObject

Refund ID



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

def id
  @attributes[:id]
end

#inspectObject



159
160
161
# File 'lib/cryptopay/models/invoice_refund.rb', line 159

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



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
# File 'lib/cryptopay/models/invoice_refund.rb', line 121

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 "amount", amount cannot be nil.') if amount.nil?

  properties.push('invalid value for "amount_currency", amount_currency cannot be nil.') if amount_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?

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

  risk&.invalid_properties&.each do |prop|
    properties.push("invalid value for \"risk\": #{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_refund.rb', line 66

def invoice_id
  @attributes[:invoice_id]
end

#networkObject

Cryptocurrency network



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

def network
  @attributes[:network]
end

#riskObject



110
111
112
# File 'lib/cryptopay/models/invoice_refund.rb', line 110

def risk
  @attributes[:risk]
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



155
156
157
# File 'lib/cryptopay/models/invoice_refund.rb', line 155

def to_hash
  ENCODER.to_hash(@attributes)
end

#txidObject

Cryptocurrency transaction ID on the blockchain



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

def txid
  @attributes[:txid]
end

#valid?Boolean

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

Returns:

  • (Boolean)

    true if the model is valid



149
150
151
# File 'lib/cryptopay/models/invoice_refund.rb', line 149

def valid?
  invalid_properties.empty?
end