Class: Orb::Resources::CreditNotes
- Inherits:
-
Object
- Object
- Orb::Resources::CreditNotes
- Defined in:
- lib/orb/resources/credit_notes.rb,
sig/orb/resources/credit_notes.rbs
Overview
The Credit Note resource represents a credit that has been applied to a particular invoice.
Instance Method Summary collapse
-
#create(line_items:, reason:, end_date: nil, memo: nil, start_date: nil, request_options: {}) ⇒ Orb::Models::CreditNote
Some parameter documentations has been truncated, see Models::CreditNoteCreateParams for more details.
-
#fetch(credit_note_id, request_options: {}) ⇒ Orb::Models::CreditNote
This endpoint is used to fetch a single
Credit Notegiven an identifier. -
#initialize(client:) ⇒ CreditNotes
constructor
private
A new instance of CreditNotes.
-
#list(created_at_gt: nil, created_at_gte: nil, created_at_lt: nil, created_at_lte: nil, cursor: nil, limit: nil, request_options: {}) ⇒ Orb::Internal::Page<Orb::Models::CreditNote>
Some parameter documentations has been truncated, see Models::CreditNoteListParams for more details.
Constructor Details
#initialize(client:) ⇒ CreditNotes
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of CreditNotes.
134 135 136 |
# File 'lib/orb/resources/credit_notes.rb', line 134 def initialize(client:) @client = client end |
Instance Method Details
#create(line_items:, reason:, end_date: nil, memo: nil, start_date: nil, request_options: {}) ⇒ Orb::Models::CreditNote
Some parameter documentations has been truncated, see Models::CreditNoteCreateParams for more details.
This endpoint is used to create a single
Credit Note.
The credit note service period configuration supports two explicit modes:
-
Global service periods: Specify start_date and end_date at the credit note level. These dates will be applied to all line items uniformly.
-
Individual service periods: Specify start_date and end_date for each line item. When using this mode, ALL line items must have individual periods specified.
-
Default behavior: If no service periods are specified (neither global nor individual), the original invoice line item service periods will be used.
Note: Mixing global and individual service periods in the same request is not allowed to prevent confusion.
Service period dates are normalized to the start of the day in the customer's timezone to ensure consistent handling across different timezones.
Date Format: Use start_date and end_date with format "YYYY-MM-DD" (e.g., "2023-09-22") to match other Orb APIs like /v1/invoice_line_items.
Note: Both start_date and end_date are inclusive - the service period will cover both the start date and end date completely (from start of start_date to end of end_date).
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/orb/resources/credit_notes.rb', line 56 def create(params) parsed, = Orb::CreditNoteCreateParams.dump_request(params) @client.request( method: :post, path: "credit_notes", body: parsed, model: Orb::CreditNote, options: ) end |
#fetch(credit_note_id, request_options: {}) ⇒ Orb::Models::CreditNote
This endpoint is used to fetch a single Credit Note
given an identifier.
122 123 124 125 126 127 128 129 |
# File 'lib/orb/resources/credit_notes.rb', line 122 def fetch(credit_note_id, params = {}) @client.request( method: :get, path: ["credit_notes/%1$s", credit_note_id], model: Orb::CreditNote, options: params[:request_options] ) end |
#list(created_at_gt: nil, created_at_gte: nil, created_at_lt: nil, created_at_lte: nil, cursor: nil, limit: nil, request_options: {}) ⇒ Orb::Internal::Page<Orb::Models::CreditNote>
Some parameter documentations has been truncated, see Models::CreditNoteListParams for more details.
Get a paginated list of CreditNotes. Users can also filter by customer_id,
subscription_id, or external_customer_id. The credit notes will be returned in
reverse chronological order by creation_time.
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/orb/resources/credit_notes.rb', line 93 def list(params = {}) parsed, = Orb::CreditNoteListParams.dump_request(params) query = Orb::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "credit_notes", query: query.transform_keys( created_at_gt: "created_at[gt]", created_at_gte: "created_at[gte]", created_at_lt: "created_at[lt]", created_at_lte: "created_at[lte]" ), page: Orb::Internal::Page, model: Orb::CreditNote, options: ) end |