Class: BillForward::CreditNote

Inherits:
MutableEntity show all
Defined in:
lib/bill_forward/entities/credit_note.rb

Instance Attribute Summary

Attributes inherited from BillingEntity

#_client

Class Method Summary collapse

Methods inherited from MutableEntity

#delete, #initialize, #save

Methods inherited from InsertableEntity

create, #initialize

Methods inherited from BillingEntity

#[], #[]=, #_dump, _load, build_entity, build_entity_array, #camel_case_lower, get_by_id, #initialize, #method_missing, request_ambiguous, request_first_heterotyped, request_many_heterotyped, #serialize, #serialize_field, singleton_client, #state_params, #to_json, #to_ordered_hash, #to_s, #to_unordered_hash

Constructor Details

This class inherits a constructor from BillForward::MutableEntity

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class BillForward::BillingEntity

Class Method Details

.get_all(query_params = {}, customClient = nil) ⇒ Object



6
7
8
9
10
# 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) ⇒ Object

Raises:

  • (ArgumentError)


24
25
26
27
28
29
30
31
32
# File 'lib/bill_forward/entities/credit_note.rb', line 24

def (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) ⇒ Object

Raises:

  • (ArgumentError)


34
35
36
37
38
39
40
41
42
# 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) ⇒ Object



12
13
14
15
16
# File 'lib/bill_forward/entities/credit_note.rb', line 12

def (id, query_params = {}, custom_client = nil)
  credit_notes = (id, query_params, custom_client)

  self.count_remaining_credit credit_notes
end

.get_remaining_credit_on_subscription(id, query_params = {}, custom_client = nil) ⇒ Object



18
19
20
21
22
# 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