Class: BadBill::InvoicePayment

Inherits:
BaseResource show all
Defined in:
lib/badbill/invoice_payment.rb

Overview

The InvoicePayment resource handles all invoice payments.

See www.billomat.com/en/api/invoices/payments/

Instance Attribute Summary

Attributes inherited from BaseResource

#data, #id

Class Method Summary collapse

Methods inherited from BaseResource

all, #delete, #error, find, #initialize, #save

Methods included from Resource

#call, #delete, #get, #post, #put

Methods included from ForwardMethods

#method_missing, #respond_to?

Constructor Details

This class inherits a constructor from BadBill::BaseResource

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class BadBill::ForwardMethods

Class Method Details

.create(invoice_id, amount, is_paid = false, params = {}) ⇒ InvoicePayment, Hashie::Mash

Create a new invoice payment.

Parameters:

  • invoice_id (String, )

    The ID of the invoice

  • amount (String, Numeric)

    The paid amount

  • is_paid (Boolean) (defaults to: false)

    Wether the invoice should be marked as paid or not

Returns:

  • (InvoicePayment, Hashie::Mash)

    New payment with id and data set or hash if any error happened



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/badbill/invoice_payment.rb', line 16

def self.create invoice_id, amount, is_paid=false, params={}
  params['invoice_id']           = invoice_id
  params['amount']               = amount
  params['mark_invoice_as_paid'] = is_paid

  res = post(resource_name, {resource_name_singular => params})
  return res if res.error

  res_data = res.__send__(resource_name_singular)
  new res_data.id.to_i, res_data
end