Class: Cryptopay::Invoice
- Inherits:
-
Object
- Object
- Cryptopay::Invoice
- Defined in:
- lib/cryptopay/models/invoice.rb
Class Method Summary collapse
-
.build_from_hash(data) ⇒ Cryptopay::Invoice
Builds the object from hash.
Instance Method Summary collapse
-
#address ⇒ Object
Invoice cryptocurrency address.
-
#created_at ⇒ Object
Invoice creation date and time.
-
#custom_id ⇒ Object
Invoice reference ID in your system.
-
#customer_id ⇒ Object
The internal ID of your customer that the invoice relates to.
-
#description ⇒ Object
Invoice description.
- #exchange ⇒ Object
-
#expires_at ⇒ Object
Invoice expiration date and time.
-
#fee ⇒ Object
Processing fee.
-
#fee_currency ⇒ Object
Processing fee currency.
-
#hosted_page_url ⇒ Object
Invoice hosted page that renders invoice details.
-
#id ⇒ Object
Invoice ID.
-
#initialize(attributes = {}) ⇒ Invoice
constructor
Initializes the object.
- #inspect ⇒ Object
-
#invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#metadata ⇒ Object
Key-value data.
-
#name ⇒ Object
Invoice name.
-
#network ⇒ Object
Cryptocurrency network.
-
#paid_amount ⇒ Object
which amount already paid.
-
#pay_amount ⇒ Object
Cryptocurrency amount to pay.
-
#pay_currency ⇒ Object
Cryptocurrency type.
-
#price_amount ⇒ Object
Invoice amount.
-
#price_currency ⇒ Object
Invoice amount currency.
- #status ⇒ Object
- #status_context ⇒ Object
- #subscription_id ⇒ Object
-
#success_redirect_url ⇒ Object
URL that a customer will be redirected to upon transaction confirmation.
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
- #transactions ⇒ Object
- #unsuccess_redirect_url ⇒ Object
-
#uri ⇒ Object
Invoice URI.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ Invoice
Initializes the object
90 91 92 |
# File 'lib/cryptopay/models/invoice.rb', line 90 def initialize(attributes = {}) @attributes = ENCODER.sanitize(attributes) end |
Class Method Details
.build_from_hash(data) ⇒ Cryptopay::Invoice
Builds the object from hash
83 84 85 86 |
# File 'lib/cryptopay/models/invoice.rb', line 83 def self.build_from_hash(data) attributes = ENCODER.build_from_hash(data) new(attributes) end |
Instance Method Details
#address ⇒ Object
Invoice cryptocurrency address
122 123 124 |
# File 'lib/cryptopay/models/invoice.rb', line 122 def address @attributes[:address] end |
#created_at ⇒ Object
Invoice creation date and time
209 210 211 |
# File 'lib/cryptopay/models/invoice.rb', line 209 def created_at @attributes[:created_at] end |
#custom_id ⇒ Object
Invoice reference ID in your system
100 101 102 |
# File 'lib/cryptopay/models/invoice.rb', line 100 def custom_id @attributes[:custom_id] end |
#customer_id ⇒ Object
The internal ID of your customer that the invoice relates to
105 106 107 |
# File 'lib/cryptopay/models/invoice.rb', line 105 def customer_id @attributes[:customer_id] end |
#description ⇒ Object
Invoice description
185 186 187 |
# File 'lib/cryptopay/models/invoice.rb', line 185 def description @attributes[:description] end |
#exchange ⇒ Object
171 172 173 |
# File 'lib/cryptopay/models/invoice.rb', line 171 def exchange @attributes[:exchange] end |
#expires_at ⇒ Object
Invoice expiration date and time
214 215 216 |
# File 'lib/cryptopay/models/invoice.rb', line 214 def expires_at @attributes[:expires_at] end |
#fee ⇒ Object
Processing fee
147 148 149 |
# File 'lib/cryptopay/models/invoice.rb', line 147 def fee @attributes[:fee] end |
#fee_currency ⇒ Object
Processing fee currency
152 153 154 |
# File 'lib/cryptopay/models/invoice.rb', line 152 def fee_currency @attributes[:fee_currency] end |
#hosted_page_url ⇒ Object
Invoice hosted page that renders invoice details
204 205 206 |
# File 'lib/cryptopay/models/invoice.rb', line 204 def hosted_page_url @attributes[:hosted_page_url] end |
#id ⇒ Object
Invoice ID
95 96 97 |
# File 'lib/cryptopay/models/invoice.rb', line 95 def id @attributes[:id] end |
#inspect ⇒ Object
288 289 290 |
# File 'lib/cryptopay/models/invoice.rb', line 288 def inspect "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash) end |
#invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
# File 'lib/cryptopay/models/invoice.rb', line 220 def invalid_properties properties = [] properties.push('invalid value for "id", id cannot be nil.') if id.nil? properties.push('invalid value for "status", status cannot be nil.') if status.nil? if !status.nil? && !%w[new completed unresolved refunded cancelled].include?(status) properties.push('invalid value for status, must be one of "new", "completed", "unresolved", "refunded", "cancelled"') end if !status_context.nil? && !%w[overpaid underpaid paid_late illicit_resource].include?(status_context) properties.push('invalid value for status_context, must be one of "overpaid", "underpaid", "paid_late", "illicit_resource"') end properties.push('invalid value for "address", address cannot be nil.') if address.nil? properties.push('invalid value for "network", network cannot be nil.') if network.nil? properties.push('invalid value for "uri", uri cannot be nil.') if uri.nil? 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 "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 "pay_amount", pay_amount cannot be nil.') if pay_amount.nil? properties.push('invalid value for "pay_currency", pay_currency cannot be nil.') if pay_currency.nil? properties.push('invalid value for "paid_amount", paid_amount cannot be nil.') if paid_amount.nil? exchange&.invalid_properties&.each do |prop| properties.push("invalid value for \"exchange\": #{prop}") end properties.push('invalid value for "transactions", transactions cannot be nil.') if transactions.nil? transactions&.each_with_index do |item, index| item.invalid_properties.each do |prop| properties.push("invalid value for \"transactions.#{index}\": #{prop}") end end properties.push('invalid value for "hosted_page_url", hosted_page_url cannot be nil.') if hosted_page_url.nil? properties.push('invalid value for "created_at", created_at cannot be nil.') if created_at.nil? properties.push('invalid value for "expires_at", expires_at cannot be nil.') if expires_at.nil? properties end |
#metadata ⇒ Object
Key-value data
190 191 192 |
# File 'lib/cryptopay/models/invoice.rb', line 190 def @attributes[:metadata] end |
#name ⇒ Object
Invoice name
180 181 182 |
# File 'lib/cryptopay/models/invoice.rb', line 180 def name @attributes[:name] end |
#network ⇒ Object
Cryptocurrency network
127 128 129 |
# File 'lib/cryptopay/models/invoice.rb', line 127 def network @attributes[:network] end |
#paid_amount ⇒ Object
which amount already paid
167 168 169 |
# File 'lib/cryptopay/models/invoice.rb', line 167 def paid_amount @attributes[:paid_amount] end |
#pay_amount ⇒ Object
Cryptocurrency amount to pay
157 158 159 |
# File 'lib/cryptopay/models/invoice.rb', line 157 def pay_amount @attributes[:pay_amount] end |
#pay_currency ⇒ Object
Cryptocurrency type
162 163 164 |
# File 'lib/cryptopay/models/invoice.rb', line 162 def pay_currency @attributes[:pay_currency] end |
#price_amount ⇒ Object
Invoice amount
137 138 139 |
# File 'lib/cryptopay/models/invoice.rb', line 137 def price_amount @attributes[:price_amount] end |
#price_currency ⇒ Object
Invoice amount currency
142 143 144 |
# File 'lib/cryptopay/models/invoice.rb', line 142 def price_currency @attributes[:price_currency] end |
#status ⇒ Object
113 114 115 |
# File 'lib/cryptopay/models/invoice.rb', line 113 def status @attributes[:status] end |
#status_context ⇒ Object
117 118 119 |
# File 'lib/cryptopay/models/invoice.rb', line 117 def status_context @attributes[:status_context] end |
#subscription_id ⇒ Object
109 110 111 |
# File 'lib/cryptopay/models/invoice.rb', line 109 def subscription_id @attributes[:subscription_id] end |
#success_redirect_url ⇒ Object
URL that a customer will be redirected to upon transaction confirmation
195 196 197 |
# File 'lib/cryptopay/models/invoice.rb', line 195 def success_redirect_url @attributes[:success_redirect_url] end |
#to_hash ⇒ Hash
Returns the object in the form of hash
284 285 286 |
# File 'lib/cryptopay/models/invoice.rb', line 284 def to_hash ENCODER.to_hash(@attributes) end |
#transactions ⇒ Object
175 176 177 |
# File 'lib/cryptopay/models/invoice.rb', line 175 def transactions @attributes[:transactions] end |
#unsuccess_redirect_url ⇒ Object
199 200 201 |
# File 'lib/cryptopay/models/invoice.rb', line 199 def unsuccess_redirect_url @attributes[:unsuccess_redirect_url] end |
#uri ⇒ Object
Invoice URI. May be used for generating a QR code
132 133 134 |
# File 'lib/cryptopay/models/invoice.rb', line 132 def uri @attributes[:uri] end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
278 279 280 |
# File 'lib/cryptopay/models/invoice.rb', line 278 def valid? invalid_properties.empty? end |