Class: Nfe::TaxCodePaginatedResponse
- Inherits:
-
Data
- Object
- Data
- Nfe::TaxCodePaginatedResponse
- Defined in:
- lib/nfe/resources/dto/tax_codes/tax_code_paginated_response.rb,
sig/nfe/resources/dto/tax_codes/tax_code_paginated_response.rbs
Overview
Page-style paginated response for the CT-e tax-code lookup endpoints (operation code, acquisition purpose, issuer/recipient tax profile).
NOTE: unlike the cursor-style lists elsewhere in this SDK (which return an ListResponse carrying +starting_after+/+ending_before+), these tax-code endpoints are 1-based page-style, so this resource returns this custom response object exposing +current_page+/+total_pages+/+total_count+ directly.
items is hydrated to an Array of TaxCode. TaxCodePaginatedResponse.from_api is nil-tolerant
(+from_api(nil)+ returns nil).
Instance Attribute Summary collapse
-
#current_page ⇒ Object
readonly
Returns the value of attribute current_page.
-
#items ⇒ Array[Nfe::TaxCode?]
readonly
Returns the value of attribute items.
-
#total_count ⇒ Object
readonly
Returns the value of attribute total_count.
-
#total_pages ⇒ Object
readonly
Returns the value of attribute total_pages.
Class Method Summary collapse
-
.from_api(payload) ⇒ Nfe::TaxCodePaginatedResponse?
Build a TaxCodePaginatedResponse from an API payload.
- .new ⇒ instance
Instance Method Summary collapse
-
#initialize ⇒ TaxCodePaginatedResponse
constructor
A new instance of TaxCodePaginatedResponse.
Constructor Details
#initialize ⇒ TaxCodePaginatedResponse
Returns a new instance of TaxCodePaginatedResponse.
21 |
# File 'sig/nfe/resources/dto/tax_codes/tax_code_paginated_response.rbs', line 21
def initialize: (current_page: untyped, total_pages: untyped, total_count: untyped, items: Array[Nfe::TaxCode?]) -> void
|
Instance Attribute Details
#current_page ⇒ Object (readonly)
Returns the value of attribute current_page.
13 14 15 |
# File 'sig/nfe/resources/dto/tax_codes/tax_code_paginated_response.rbs', line 13 def current_page @current_page end |
#items ⇒ Array[Nfe::TaxCode?] (readonly)
Returns the value of attribute items.
16 17 18 |
# File 'sig/nfe/resources/dto/tax_codes/tax_code_paginated_response.rbs', line 16 def items @items end |
#total_count ⇒ Object (readonly)
Returns the value of attribute total_count.
15 16 17 |
# File 'sig/nfe/resources/dto/tax_codes/tax_code_paginated_response.rbs', line 15 def total_count @total_count end |
#total_pages ⇒ Object (readonly)
Returns the value of attribute total_pages.
14 15 16 |
# File 'sig/nfe/resources/dto/tax_codes/tax_code_paginated_response.rbs', line 14 def total_pages @total_pages end |
Class Method Details
.from_api(payload) ⇒ Nfe::TaxCodePaginatedResponse?
Build a Nfe::TaxCodePaginatedResponse from an API payload.
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/nfe/resources/dto/tax_codes/tax_code_paginated_response.rb', line 39 def self.from_api(payload) return nil if payload.nil? new( current_page: payload["currentPage"], total_pages: payload["totalPages"], total_count: payload["totalCount"], items: (payload["items"] || []).map { |item| Nfe::TaxCode.from_api(item) } ) end |
.new ⇒ instance
20 |
# File 'sig/nfe/resources/dto/tax_codes/tax_code_paginated_response.rbs', line 20
def self.new: (current_page: untyped, total_pages: untyped, total_count: untyped, items: Array[Nfe::TaxCode?]) -> instance
|