class BillForward::Invoice

This entity exposes the following child entities via method_missing:

InvoiceLine[] .invoiceLines TaxLine[] .taxLines InvoicePayment[] .invoicePayments Refund[] .invoiceRefunds CreditNote[] .invoiceCreditNotes SubscriptionCharge[] .charges

Public Class Methods

add_charge(id, request_object = {}, custom_client = nil) click to toggle source
# File lib/bill_forward/entities/invoice.rb, line 77
def add_charge(id, request_object = {}, custom_client = nil)
  raise ArgumentError.new("id cannot be nil") if id.nil?

  endpoint = sprintf('%s/charges',
                     ERB::Util.url_encode(id)
  )

  request_entity = BillForward::GenericEntity.new(
      request_object
  )

  self.request_many_heterotyped(BillForward::SubscriptionCharge, 'post', endpoint, request_entity, nil, custom_client)
end
create(entity = nil) click to toggle source
# File lib/bill_forward/entities/invoice.rb, line 14
def create(entity = nil)
  raise DenyMethod.new 'Create support is denied for this entity; '+
    'Invoices are generated instead by the BillForward Engines.'
end
execute(id, request_object = {}, custom_client = nil) click to toggle source
# File lib/bill_forward/entities/invoice.rb, line 53
def execute(id, request_object = {}, custom_client = nil)
  raise ArgumentError.new("id cannot be nil") if id.nil?

  endpoint = sprintf('%s/execute',
                     ERB::Util.url_encode(id)
  )

  request_entity = BillForward::GenericEntity.new(
      request_object
  )

  self.request_first('post', endpoint, request_entity, nil, custom_client)
end
get_by_account_id(id, query_params = {}, custom_client = nil) click to toggle source
# File lib/bill_forward/entities/invoice.rb, line 29
def get_by_account_id(id, query_params = {}, custom_client = nil)
  raise ArgumentError.new("id cannot be nil") if id.nil?

  endpoint = sprintf('account/%s',
    ERB::Util.url_encode(id)
    )

  self.request_many('get', endpoint, query_params, custom_client)
end
get_by_subscription_id(id, query_params = {}, custom_client = nil) click to toggle source
# File lib/bill_forward/entities/invoice.rb, line 19
def get_by_subscription_id(id, query_params = {}, custom_client = nil)
  raise ArgumentError.new("id cannot be nil") if id.nil?

  endpoint = sprintf('subscription/%s',
    ERB::Util.url_encode(id)
    )

  self.request_many('get', endpoint, query_params, custom_client)
end
get_charges(id, query_params = {}, custom_client = nil) click to toggle source
# File lib/bill_forward/entities/invoice.rb, line 67
def get_charges(id, query_params = {}, custom_client = nil)
  raise ArgumentError.new("id cannot be nil") if id.nil?

  endpoint = sprintf('%s/charges',
                     ERB::Util.url_encode(id)
  )

  self.request_many_heterotyped(BillForward::SubscriptionCharge, 'get', endpoint, query_params, custom_client)
end
recalculate(id, request_object = {}, custom_client = nil) click to toggle source
# File lib/bill_forward/entities/invoice.rb, line 39
def recalculate(id, request_object = {}, custom_client = nil)
  raise ArgumentError.new("id cannot be nil") if id.nil?

  endpoint = sprintf('%s/recalculate',
                     ERB::Util.url_encode(id)
  )

  request_entity = BillForward::GenericEntity.new(
      request_object
  )

  self.request_first('post', endpoint, request_entity, nil, custom_client)
end

Public Instance Methods

add_charge(request_object = {}, custom_client = nil) click to toggle source
# File lib/bill_forward/entities/invoice.rb, line 92
def add_charge(request_object = {}, custom_client = nil)
  self.class.add_charge(self.id, request_object, custom_client)
end

Protected Instance Methods

unserialize_all(hash) click to toggle source
Calls superclass method
# File lib/bill_forward/entities/invoice.rb, line 97
def unserialize_all(hash)
  super
  unserialize_array_of_entities('invoiceLines', InvoiceLine, hash)
  unserialize_array_of_entities('taxLines', TaxLine, hash)
  unserialize_array_of_entities('invoicePayments', InvoicePayment, hash)
  unserialize_array_of_entities('invoiceRefunds', Refund, hash)
  unserialize_array_of_entities('invoiceCreditNotes', CreditNote, hash)
  unserialize_array_of_entities('charges', SubscriptionCharge, hash)
end