Class: Cryptopay::ChannelParams

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ ChannelParams

Initializes the object

Parameters:

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

    Model attributes in the form of hash



42
43
44
# File 'lib/cryptopay/models/channel_params.rb', line 42

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

Class Method Details

.build_from_hash(data) ⇒ Cryptopay::ChannelParams

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:



35
36
37
38
# File 'lib/cryptopay/models/channel_params.rb', line 35

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

Instance Method Details

#custom_idObject

The payment reference ID in your system



72
73
74
# File 'lib/cryptopay/models/channel_params.rb', line 72

def custom_id
  @attributes[:custom_id]
end

#customer_idObject

The internal ID of your customer that the channel relates to



77
78
79
# File 'lib/cryptopay/models/channel_params.rb', line 77

def customer_id
  @attributes[:customer_id]
end

#descriptionObject

Channel description



52
53
54
# File 'lib/cryptopay/models/channel_params.rb', line 52

def description
  @attributes[:description]
end

#inspectObject



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

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



83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/cryptopay/models/channel_params.rb', line 83

def invalid_properties
  properties = []

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

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

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

  properties
end

#nameObject

Channel name



47
48
49
# File 'lib/cryptopay/models/channel_params.rb', line 47

def name
  @attributes[:name]
end

#networkObject

Cryptocurrency network



62
63
64
# File 'lib/cryptopay/models/channel_params.rb', line 62

def network
  @attributes[:network]
end

#pay_currencyObject

The cryptocurrency which you want to accept



57
58
59
# File 'lib/cryptopay/models/channel_params.rb', line 57

def pay_currency
  @attributes[:pay_currency]
end

#receiver_currencyObject

The currency which all incoming transactions will be converted to



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

def receiver_currency
  @attributes[:receiver_currency]
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



105
106
107
# File 'lib/cryptopay/models/channel_params.rb', line 105

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



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

def valid?
  invalid_properties.empty?
end