Class: Nfe::TaxCode

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

A single CT-e tax-code entry (operation code, acquisition purpose, issuer or recipient tax profile). Hand-written: the consulta-cte tax-code endpoints are schema-less in the OpenAPI spec, so the generator produces no usable model. TaxCode.from_api maps the API camelCase keys onto snake_case members and is nil-tolerant (+from_api(nil)+ returns nil).

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTaxCode

Returns a new instance of TaxCode.

Parameters:

  • code: (String, nil)
  • description: (String, nil)


9
# File 'sig/nfe/resources/dto/tax_codes/tax_code_paginated_response.rbs', line 9

def initialize: (code: String?, description: String?) -> void

Instance Attribute Details

#codeString? (readonly)

Returns the value of attribute code.

Returns:

  • (String, nil)


3
4
5
# File 'sig/nfe/resources/dto/tax_codes/tax_code_paginated_response.rbs', line 3

def code
  @code
end

#descriptionString? (readonly)

Returns the value of attribute description.

Returns:

  • (String, nil)


4
5
6
# File 'sig/nfe/resources/dto/tax_codes/tax_code_paginated_response.rbs', line 4

def description
  @description
end

Class Method Details

.from_api(payload) ⇒ Nfe::TaxCode?

Build a Nfe::TaxCode from an API payload.

Parameters:

  • payload (Hash, nil)

    the response object.

Returns:



14
15
16
17
18
19
20
21
# File 'lib/nfe/resources/dto/tax_codes/tax_code_paginated_response.rb', line 14

def self.from_api(payload)
  return nil if payload.nil?

  new(
    code: payload["code"],
    description: payload["description"]
  )
end

.newinstance

Parameters:

  • code: (String, nil)
  • description: (String, nil)

Returns:

  • (instance)


8
# File 'sig/nfe/resources/dto/tax_codes/tax_code_paginated_response.rbs', line 8

def self.new: (code: String?, description: String?) -> instance