Class: DPay::InvoiceDetails
- Inherits:
-
Object
- Object
- DPay::InvoiceDetails
- Defined in:
- lib/dpay/payment/invoice_details.rb,
sig/dpay/payment/invoice_details.rbs
Constant Summary collapse
- DATE =
/\A\d{4}-\d{2}-\d{2}\z/
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ InvoiceDetails
constructor
A new instance of InvoiceDetails.
- #to_h ⇒ Hash[String, untyped]
- #with_invoice_number(invoice_number) ⇒ self
- #with_payer_name(payer_name) ⇒ self
- #with_payer_nip(payer_nip) ⇒ self
- #with_payment_due_date(payment_due_date) ⇒ self
- #with_vat_amount(vat_amount) ⇒ self
Constructor Details
#initialize ⇒ InvoiceDetails
Returns a new instance of InvoiceDetails.
11 12 13 |
# File 'lib/dpay/payment/invoice_details.rb', line 11 def initialize @data = {} end |
Class Method Details
.create ⇒ InvoiceDetails
7 8 9 |
# File 'lib/dpay/payment/invoice_details.rb', line 7 def self.create new end |
Instance Method Details
#to_h ⇒ Hash[String, untyped]
44 45 46 |
# File 'lib/dpay/payment/invoice_details.rb', line 44 def to_h @data.dup end |
#with_invoice_number(invoice_number) ⇒ self
25 26 27 28 |
# File 'lib/dpay/payment/invoice_details.rb', line 25 def with_invoice_number(invoice_number) @data["invoice_number"] = invoice_number self end |
#with_payer_name(payer_name) ⇒ self
20 21 22 23 |
# File 'lib/dpay/payment/invoice_details.rb', line 20 def with_payer_name(payer_name) @data["payer_name"] = payer_name self end |
#with_payer_nip(payer_nip) ⇒ self
15 16 17 18 |
# File 'lib/dpay/payment/invoice_details.rb', line 15 def with_payer_nip(payer_nip) @data["payer_nip"] = payer_nip self end |
#with_payment_due_date(payment_due_date) ⇒ self
30 31 32 33 34 35 36 37 |
# File 'lib/dpay/payment/invoice_details.rb', line 30 def with_payment_due_date(payment_due_date) unless payment_due_date.is_a?(String) && DATE.match?(payment_due_date) raise InvalidArgumentError, "Payment due date must be in YYYY-MM-DD format" end @data["payment_due_date"] = payment_due_date self end |
#with_vat_amount(vat_amount) ⇒ self
39 40 41 42 |
# File 'lib/dpay/payment/invoice_details.rb', line 39 def with_vat_amount(vat_amount) @data["vat_amount"] = vat_amount.minor self end |