Class: Nfe::TaxCodePaginatedResponse

Inherits:
Data
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTaxCodePaginatedResponse

Returns a new instance of TaxCodePaginatedResponse.

Parameters:

  • current_page: (Object)
  • total_pages: (Object)
  • total_count: (Object)
  • items: (Array[Nfe::TaxCode?])


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_pageObject (readonly)

Returns the value of attribute current_page.

Returns:

  • (Object)


13
14
15
# File 'sig/nfe/resources/dto/tax_codes/tax_code_paginated_response.rbs', line 13

def current_page
  @current_page
end

#itemsArray[Nfe::TaxCode?] (readonly)

Returns the value of attribute items.

Returns:



16
17
18
# File 'sig/nfe/resources/dto/tax_codes/tax_code_paginated_response.rbs', line 16

def items
  @items
end

#total_countObject (readonly)

Returns the value of attribute total_count.

Returns:

  • (Object)


15
16
17
# File 'sig/nfe/resources/dto/tax_codes/tax_code_paginated_response.rbs', line 15

def total_count
  @total_count
end

#total_pagesObject (readonly)

Returns the value of attribute total_pages.

Returns:

  • (Object)


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.

Parameters:

  • payload (Hash, nil)

    the response object.

Returns:



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

.newinstance

Parameters:

  • current_page: (Object)
  • total_pages: (Object)
  • total_count: (Object)
  • items: (Array[Nfe::TaxCode?])

Returns:

  • (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