Class: Cryptopay::InvoiceParams

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ InvoiceParams

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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

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

Class Method Details

.build_from_hash(data) ⇒ Cryptopay::InvoiceParams

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:



45
46
47
48
# File 'lib/cryptopay/models/invoice_params.rb', line 45

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



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

def custom_id
  @attributes[:custom_id]
end

#customer_idObject

The internal ID of your customer that the invoice relates to. See Customers for more information



82
83
84
# File 'lib/cryptopay/models/invoice_params.rb', line 82

def customer_id
  @attributes[:customer_id]
end

#descriptionObject

The invoice description



92
93
94
# File 'lib/cryptopay/models/invoice_params.rb', line 92

def description
  @attributes[:description]
end

#inspectObject



141
142
143
# File 'lib/cryptopay/models/invoice_params.rb', line 141

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



117
118
119
120
121
122
123
124
125
126
127
# File 'lib/cryptopay/models/invoice_params.rb', line 117

def invalid_properties
  properties = []

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

  properties
end

#metadataObject

Custom key-valued data



97
98
99
# File 'lib/cryptopay/models/invoice_params.rb', line 97

def 
  @attributes[:metadata]
end

#nameObject

The invoice name



87
88
89
# File 'lib/cryptopay/models/invoice_params.rb', line 87

def name
  @attributes[:name]
end

#networkObject

Cryptocurrency network



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

def network
  @attributes[:network]
end

#pay_currencyObject

The cryptocurrency that the invoice must be paid in



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

def pay_currency
  @attributes[:pay_currency]
end

#payer_emailObject

Email of payer



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

def payer_email
  @attributes[:payer_email]
end

#price_amountObject

The invoice amount



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

def price_amount
  @attributes[:price_amount]
end

#price_currencyObject

The invoice amount currency



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

def price_currency
  @attributes[:price_currency]
end

#success_redirect_urlObject

The URL that the customer will be redirected to upon transaction confirmation



102
103
104
# File 'lib/cryptopay/models/invoice_params.rb', line 102

def success_redirect_url
  @attributes[:success_redirect_url]
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



137
138
139
# File 'lib/cryptopay/models/invoice_params.rb', line 137

def to_hash
  ENCODER.to_hash(@attributes)
end

#unsuccess_redirect_urlObject



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

def unsuccess_redirect_url
  @attributes[:unsuccess_redirect_url]
end

#valid?Boolean

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

Returns:

  • (Boolean)

    true if the model is valid



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

def valid?
  invalid_properties.empty?
end