Class: ApiReference::CreditNoteApi
- Defined in:
- lib/api_reference/apis/credit_note_api.rb
Overview
CreditNoteApi
Constant Summary
Constants inherited from BaseApi
Instance Attribute Summary
Attributes inherited from BaseApi
Instance Method Summary collapse
-
#create_credit_note(body) ⇒ ApiResponse
This endpoint is used to create a single
Credit Note. -
#fetch_credit_note(credit_note_id) ⇒ ApiResponse
This endpoint is used to fetch a single
Credit Notegiven an identifier. -
#list_credit_notes(limit: 20, cursor: nil, created_at_gte: nil, created_at_gt: nil, created_at_lt: nil, created_at_lte: nil) ⇒ ApiResponse
Get a paginated list of CreditNotes.
Methods inherited from BaseApi
#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters
Constructor Details
This class inherits a constructor from ApiReference::BaseApi
Instance Method Details
#create_credit_note(body) ⇒ ApiResponse
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). description here
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/api_reference/apis/credit_note_api.rb', line 99 def create_credit_note(body) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/credit_notes', Server::DEFAULT) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body) .is_required(true)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('APIKeyAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(CreditNote.method(:from_hash)) .is_api_response(true) .local_error('400', 'Bad Request', APIException) .local_error('401', 'Unauthorized', AuthorizationErrorException) .local_error('404', 'Not Found', APIException) .local_error('409', 'Conflict', IdempotencyRequestMismatchException) .local_error('413', 'Content Too Large', APIException) .local_error('429', 'Too Many Requests', TooManyRequestsException) .local_error('500', 'Internal Server Error', ServerErrorException)) .execute end |
#fetch_credit_note(credit_note_id) ⇒ ApiResponse
This endpoint is used to fetch a single Credit Note given an identifier.
here
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/api_reference/apis/credit_note_api.rb', line 143 def fetch_credit_note(credit_note_id) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/credit_notes/{credit_note_id}', Server::DEFAULT) .template_param(new_parameter(credit_note_id, key: 'credit_note_id') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('APIKeyAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(CreditNote.method(:from_hash)) .is_api_response(true) .local_error('400', 'Bad Request', APIException) .local_error('401', 'Unauthorized', AuthorizationErrorException) .local_error('404', 'Not Found', APIException) .local_error('409', 'Conflict', IdempotencyRequestMismatchException) .local_error('413', 'Content Too Large', APIException) .local_error('429', 'Too Many Requests', TooManyRequestsException) .local_error('500', 'Internal Server Error', ServerErrorException)) .execute end |
#list_credit_notes(limit: 20, cursor: nil, created_at_gte: nil, created_at_gt: nil, created_at_lt: nil, created_at_lte: nil) ⇒ ApiResponse
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.
description here
here
here
description here
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/api_reference/apis/credit_note_api.rb', line 24 def list_credit_notes(limit: 20, cursor: nil, created_at_gte: nil, created_at_gt: nil, created_at_lt: nil, created_at_lte: nil) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/credit_notes', Server::DEFAULT) .query_param(new_parameter(limit, key: 'limit')) .query_param(new_parameter(cursor, key: 'cursor')) .query_param(new_parameter(created_at_gte, key: 'created_at[gte]')) .query_param(new_parameter(created_at_gt, key: 'created_at[gt]')) .query_param(new_parameter(created_at_lt, key: 'created_at[lt]')) .query_param(new_parameter(created_at_lte, key: 'created_at[lte]')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('APIKeyAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(CreditNotes.method(:from_hash)) .is_api_response(true) .local_error('400', 'Bad Request', APIException) .local_error('401', 'Unauthorized', AuthorizationErrorException) .local_error('404', 'Not Found', APIException) .local_error('409', 'Conflict', IdempotencyRequestMismatchException) .local_error('413', 'Content Too Large', APIException) .local_error('429', 'Too Many Requests', TooManyRequestsException) .local_error('500', 'Internal Server Error', ServerErrorException)) .execute end |