class BillForward::CreditNote

Public Class Methods

get_all(query_params = {}, customClient = nil) click to toggle source
# File lib/bill_forward/entities/credit_note.rb, line 6
def get_all(query_params = {}, customClient = nil)
        raise DenyMethod.new 'Get All support is denied for this entity; '+
          'at the time of writing, no API endpoint exists to support it.'+
          'The entity can be GETted by ID only.'
end
get_by_account_id(id, query_params = {}, custom_client = nil) click to toggle source
# File lib/bill_forward/entities/credit_note.rb, line 24
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/credit_note.rb, line 34
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_remaining_credit_on_account(id, query_params = {}, custom_client = nil) click to toggle source
# File lib/bill_forward/entities/credit_note.rb, line 12
def get_remaining_credit_on_account(id, query_params = {}, custom_client = nil)
        credit_notes = get_by_account_id(id, query_params, custom_client)

        self.count_remaining_credit credit_notes
end
get_remaining_credit_on_subscription(id, query_params = {}, custom_client = nil) click to toggle source
# File lib/bill_forward/entities/credit_note.rb, line 18
def get_remaining_credit_on_subscription(id, query_params = {}, custom_client = nil)
        credit_notes = get_by_subscription_id(id, query_params, custom_client)

        self.count_remaining_credit credit_notes
end

Protected Class Methods

count_remaining_credit(credit_notes) click to toggle source
# File lib/bill_forward/entities/credit_note.rb, line 44
def count_remaining_credit(credit_notes)
        credit_notes.map(&:remainingValue).inject(0, :+)
end