Class: MonoMerchant::Invoice::Create
- Inherits:
-
ApiRequest
- Object
- ApiRequest
- MonoMerchant::Invoice::Create
- Defined in:
- lib/mono-merchant/invoice/create.rb
Overview
Create invoice
Constant Summary
Constants inherited from ApiRequest
ApiRequest::API_URL, ApiRequest::DEFAULT_CURRENCY
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#comment ⇒ Object
readonly
Returns the value of attribute comment.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#customer_emails ⇒ Object
readonly
Returns the value of attribute customer_emails.
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#payment_type ⇒ Object
readonly
Returns the value of attribute payment_type.
-
#redirect_url ⇒ Object
readonly
Returns the value of attribute redirect_url.
-
#reference ⇒ Object
readonly
Returns the value of attribute reference.
-
#webhook_url ⇒ Object
readonly
Returns the value of attribute webhook_url.
Attributes inherited from ApiRequest
Instance Method Summary collapse
-
#initialize(amount, currency: DEFAULT_CURRENCY, items: [], hold: false, reference: nil, redirect_url: nil, webhook_url: nil, email: nil, destination: nil, comment: nil) ⇒ Create
constructor
A new instance of Create.
Methods inherited from ApiRequest
Constructor Details
#initialize(amount, currency: DEFAULT_CURRENCY, items: [], hold: false, reference: nil, redirect_url: nil, webhook_url: nil, email: nil, destination: nil, comment: nil) ⇒ Create
Returns a new instance of Create.
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mono-merchant/invoice/create.rb', line 19 def initialize(amount, currency: DEFAULT_CURRENCY, items: [], hold: false, reference: nil, redirect_url: nil, webhook_url: nil, email: nil, destination: nil, comment: nil) @amount = convert_to_cents(amount) @destination = destination @reference = reference @comment = comment @customer_emails = [email] if email @redirect_url = redirect_url @webhook_url = webhook_url @currency = Money::Currency.new(currency) @items = items.map { |i| Item.new(i).to_hash.presence } @payment_type = hold ? 'hold' : 'debit' super() end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class MonoMerchant::ApiRequest
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
7 8 9 |
# File 'lib/mono-merchant/invoice/create.rb', line 7 def amount @amount end |
#comment ⇒ Object (readonly)
Returns the value of attribute comment.
7 8 9 |
# File 'lib/mono-merchant/invoice/create.rb', line 7 def comment @comment end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
7 8 9 |
# File 'lib/mono-merchant/invoice/create.rb', line 7 def currency @currency end |
#customer_emails ⇒ Object (readonly)
Returns the value of attribute customer_emails.
7 8 9 |
# File 'lib/mono-merchant/invoice/create.rb', line 7 def customer_emails @customer_emails end |
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
7 8 9 |
# File 'lib/mono-merchant/invoice/create.rb', line 7 def destination @destination end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
7 8 9 |
# File 'lib/mono-merchant/invoice/create.rb', line 7 def items @items end |
#payment_type ⇒ Object (readonly)
Returns the value of attribute payment_type.
7 8 9 |
# File 'lib/mono-merchant/invoice/create.rb', line 7 def payment_type @payment_type end |
#redirect_url ⇒ Object (readonly)
Returns the value of attribute redirect_url.
7 8 9 |
# File 'lib/mono-merchant/invoice/create.rb', line 7 def redirect_url @redirect_url end |
#reference ⇒ Object (readonly)
Returns the value of attribute reference.
7 8 9 |
# File 'lib/mono-merchant/invoice/create.rb', line 7 def reference @reference end |
#webhook_url ⇒ Object (readonly)
Returns the value of attribute webhook_url.
7 8 9 |
# File 'lib/mono-merchant/invoice/create.rb', line 7 def webhook_url @webhook_url end |