Class: Cryptopay::ExchangeTransfer

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ ExchangeTransfer

Initializes the object

Parameters:

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

    Model attributes in the form of hash



44
45
46
# File 'lib/cryptopay/models/exchange_transfer.rb', line 44

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

Class Method Details

.build_from_hash(data) ⇒ Cryptopay::ExchangeTransfer

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:



37
38
39
40
# File 'lib/cryptopay/models/exchange_transfer.rb', line 37

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

Instance Method Details

#charged_amountObject

Amount converted



54
55
56
# File 'lib/cryptopay/models/exchange_transfer.rb', line 54

def charged_amount
  @attributes[:charged_amount]
end

#charged_currencyObject

Account currency the funds converted from



59
60
61
# File 'lib/cryptopay/models/exchange_transfer.rb', line 59

def charged_currency
  @attributes[:charged_currency]
end

#custom_idObject

Exchange transaction reference ID in your system



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

def custom_id
  @attributes[:custom_id]
end

#exchangeObject



78
79
80
# File 'lib/cryptopay/models/exchange_transfer.rb', line 78

def exchange
  @attributes[:exchange]
end

#idObject

Exchange transaction ID



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

def id
  @attributes[:id]
end

#inspectObject



118
119
120
# File 'lib/cryptopay/models/exchange_transfer.rb', line 118

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



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/cryptopay/models/exchange_transfer.rb', line 84

def invalid_properties
  properties = []

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

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

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

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

  properties
end

#received_amountObject

Amount to be received upon exchange execution



64
65
66
# File 'lib/cryptopay/models/exchange_transfer.rb', line 64

def received_amount
  @attributes[:received_amount]
end

#received_currencyObject

Account currency the funds converted to



69
70
71
# File 'lib/cryptopay/models/exchange_transfer.rb', line 69

def received_currency
  @attributes[:received_currency]
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



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

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



108
109
110
# File 'lib/cryptopay/models/exchange_transfer.rb', line 108

def valid?
  invalid_properties.empty?
end