Class: Cryptopay::ChannelPayment

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ ChannelPayment

Initializes the object

Parameters:

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

    Model attributes in the form of hash



74
75
76
# File 'lib/cryptopay/models/channel_payment.rb', line 74

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

Class Method Details

.build_from_hash(data) ⇒ Cryptopay::ChannelPayment

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:



67
68
69
70
# File 'lib/cryptopay/models/channel_payment.rb', line 67

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

Instance Method Details

#addressObject

Channel cryptocurrency address



158
159
160
# File 'lib/cryptopay/models/channel_payment.rb', line 158

def address
  @attributes[:address]
end

#channel_idObject

Channel ID



84
85
86
# File 'lib/cryptopay/models/channel_payment.rb', line 84

def channel_id
  @attributes[:channel_id]
end

#coin_withdrawal_idObject



143
144
145
# File 'lib/cryptopay/models/channel_payment.rb', line 143

def coin_withdrawal_id
  @attributes[:coin_withdrawal_id]
end

#created_atObject

Channel payment creation date and time



168
169
170
# File 'lib/cryptopay/models/channel_payment.rb', line 168

def created_at
  @attributes[:created_at]
end

#custom_idObject

Channel payment custom_id value inherited from its parent channel



148
149
150
# File 'lib/cryptopay/models/channel_payment.rb', line 148

def custom_id
  @attributes[:custom_id]
end

#customer_idObject

The reference ID of your customer



153
154
155
# File 'lib/cryptopay/models/channel_payment.rb', line 153

def customer_id
  @attributes[:customer_id]
end

#exchangeObject



123
124
125
# File 'lib/cryptopay/models/channel_payment.rb', line 123

def exchange
  @attributes[:exchange]
end

#feeObject

Processing fee



109
110
111
# File 'lib/cryptopay/models/channel_payment.rb', line 109

def fee
  @attributes[:fee]
end

#fee_currencyObject

Processing fee currency



114
115
116
# File 'lib/cryptopay/models/channel_payment.rb', line 114

def fee_currency
  @attributes[:fee_currency]
end

#idObject

Channel payment ID



79
80
81
# File 'lib/cryptopay/models/channel_payment.rb', line 79

def id
  @attributes[:id]
end

#inspectObject



232
233
234
# File 'lib/cryptopay/models/channel_payment.rb', line 232

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



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

def invalid_properties
  properties = []

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

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

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

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

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

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

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

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

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

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

  if !status.nil? && !%w[pending on_hold completed refunded cancelled].include?(status)
    properties.push('invalid value for status, must be one of "pending", "on_hold", "completed", "refunded", "cancelled"')
  end

  if !status_context.nil? && !%w[illicit_resource channel_disabled].include?(status_context)
    properties.push('invalid value for status_context, must be one of "illicit_resource", "channel_disabled"')
  end

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

  properties
end

#networkObject

Cryptocurrency network



163
164
165
# File 'lib/cryptopay/models/channel_payment.rb', line 163

def network
  @attributes[:network]
end

Cryptocurrency transaction amount that was received



89
90
91
# File 'lib/cryptopay/models/channel_payment.rb', line 89

def paid_amount
  @attributes[:paid_amount]
end

Cryptocurrency type



94
95
96
# File 'lib/cryptopay/models/channel_payment.rb', line 94

def paid_currency
  @attributes[:paid_currency]
end

#received_amountObject

Amount credited to your Cryptopay account



99
100
101
# File 'lib/cryptopay/models/channel_payment.rb', line 99

def received_amount
  @attributes[:received_amount]
end

#received_currencyObject

Account currency



104
105
106
# File 'lib/cryptopay/models/channel_payment.rb', line 104

def received_currency
  @attributes[:received_currency]
end

#refund_addressObject



139
140
141
# File 'lib/cryptopay/models/channel_payment.rb', line 139

def refund_address
  @attributes[:refund_address]
end

#riskObject



127
128
129
# File 'lib/cryptopay/models/channel_payment.rb', line 127

def risk
  @attributes[:risk]
end

#statusObject



131
132
133
# File 'lib/cryptopay/models/channel_payment.rb', line 131

def status
  @attributes[:status]
end

#status_contextObject



135
136
137
# File 'lib/cryptopay/models/channel_payment.rb', line 135

def status_context
  @attributes[:status_context]
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



228
229
230
# File 'lib/cryptopay/models/channel_payment.rb', line 228

def to_hash
  ENCODER.to_hash(@attributes)
end

#txidObject

Cryptocurrency transaction ID on the blockchain



119
120
121
# File 'lib/cryptopay/models/channel_payment.rb', line 119

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



222
223
224
# File 'lib/cryptopay/models/channel_payment.rb', line 222

def valid?
  invalid_properties.empty?
end