Class: Bitodeme::Resource::Invoice

Inherits:
Base
  • Object
show all
Defined in:
lib/bitodeme/resources/invoice.rb

Overview

Invoice resource

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Base

#to_h

Instance Attribute Details

#account_idObject (readonly)

Account identifier



8
9
10
# File 'lib/bitodeme/resources/invoice.rb', line 8

def 
  @account_id
end

#addressObject (readonly)

Fund address



11
12
13
# File 'lib/bitodeme/resources/invoice.rb', line 11

def address
  @address
end

#amountObject (readonly)

Amount



14
15
16
# File 'lib/bitodeme/resources/invoice.rb', line 14

def amount
  @amount
end

#cancel_return_urlObject (readonly)

Cancellation return url



17
18
19
# File 'lib/bitodeme/resources/invoice.rb', line 17

def cancel_return_url
  @cancel_return_url
end

#created_atObject (readonly)

Created at in milliseconds



20
21
22
# File 'lib/bitodeme/resources/invoice.rb', line 20

def created_at
  @created_at
end

#currency_codeObject (readonly)

Currency code



23
24
25
# File 'lib/bitodeme/resources/invoice.rb', line 23

def currency_code
  @currency_code
end

#current_statusObject (readonly)

Current status



26
27
28
# File 'lib/bitodeme/resources/invoice.rb', line 26

def current_status
  @current_status
end

#deleted_atObject (readonly)

Deleted at in milliseconds



29
30
31
# File 'lib/bitodeme/resources/invoice.rb', line 29

def deleted_at
  @deleted_at
end

#descriptionObject (readonly)

Description



32
33
34
# File 'lib/bitodeme/resources/invoice.rb', line 32

def description
  @description
end

#external_idObject (readonly)

External unique identifier



35
36
37
# File 'lib/bitodeme/resources/invoice.rb', line 35

def external_id
  @external_id
end

#idObject (readonly)

Unique identifier



38
39
40
# File 'lib/bitodeme/resources/invoice.rb', line 38

def id
  @id
end

#nameObject (readonly)

Name/title



41
42
43
# File 'lib/bitodeme/resources/invoice.rb', line 41

def name
  @name
end

#notify_urlObject (readonly)

Notify url



44
45
46
# File 'lib/bitodeme/resources/invoice.rb', line 44

def notify_url
  @notify_url
end

#original_amountObject (readonly)

Original amount



47
48
49
# File 'lib/bitodeme/resources/invoice.rb', line 47

def original_amount
  @original_amount
end

#original_currency_codeObject (readonly)

Original currency code



50
51
52
# File 'lib/bitodeme/resources/invoice.rb', line 50

def original_currency_code
  @original_currency_code
end

#purchasableObject (readonly)

Is it purchasable



53
54
55
# File 'lib/bitodeme/resources/invoice.rb', line 53

def purchasable
  @purchasable
end

#return_urlObject (readonly)

Successful payment return url



56
57
58
# File 'lib/bitodeme/resources/invoice.rb', line 56

def return_url
  @return_url
end

#updated_atObject (readonly)

Updated at in milliseconds



59
60
61
# File 'lib/bitodeme/resources/invoice.rb', line 59

def updated_at
  @updated_at
end

Class Method Details

.build(params) ⇒ Object

Build an invoice

Example:

>> invoice =
>>   Bitodeme::Resource::Invoice.build(
>>     name:                   'Virtual game gold',
>>     description:            'Buy a game gold',
>>     original_amount:        16.7,
>>     original_currency_code: 'USD',
>>     external_id:            'SomeUniqId',
>>     purchasable:            {}
>>   )

Arguments:

params: (Hash)


77
78
79
# File 'lib/bitodeme/resources/invoice.rb', line 77

def build(params)
  new(params).send(:validate)
end

.create(invoice) ⇒ Object

Craete a new invoice

Example:

>> invoice =
>>   Bitodeme.build_invoice(
>>     name:                   'Virtual game gold',
>>     description:            'Buy a game gold',
>>     original_amount:        16.7,
>>     original_currency_code: 'USD',
>>     external_id:            'SomeUniqId',
>>     purchasable:            {}
>>   )

>> invoice = Bitodeme.create_invoice(invoice)

Arguments:

invoice: (Bitodeme::Resource::Invoice)


106
107
108
109
# File 'lib/bitodeme/resources/invoice.rb', line 106

def create(invoice)
  raise_for('invoice', invoice) unless invoice.is_a?(Invoice)
  _create('invoices', 'invoice', invoice: invoice.to_h)
end

.find(id) ⇒ Object

Find an invoice

Arguments:

id: (UUID)


85
86
87
# File 'lib/bitodeme/resources/invoice.rb', line 85

def find(id)
  _find('invoices', 'invoice', id)
end