Class: Nfe::InboundInvoiceMetadata

Inherits:
Data
  • Object
show all
Defined in:
lib/nfe/resources/dto/inbound_invoice_metadata.rb,
sig/nfe/resources/dto/inbound_invoice_metadata.rbs

Overview

Immutable value object for the metadata of an inbound document (CT-e or supplier NF-e) returned by the api.nfse.io inbound endpoints when looked up by 44-digit access key, or by an event lookup.

Hand-written so the public surface stays small and snake_case. InboundInvoiceMetadata.from_api maps the API camelCase keys onto snake_case members, drops unknown keys, and is nil-tolerant. The full payload is preserved in details (including the webhook-v2 productInvoices array, when present) so callers can read fields the SDK does not surface yet.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeInboundInvoiceMetadata

Returns a new instance of InboundInvoiceMetadata.

Parameters:

  • access_key: (String, nil)
  • nsu: (Object)
  • status: (Object)
  • name_sender: (String, nil)
  • federal_tax_number_sender: (String, nil)
  • total_invoice_amount: (Object)
  • issued_on: (String, nil)
  • product_invoices: (Object)
  • details: (Object)


19
# File 'sig/nfe/resources/dto/inbound_invoice_metadata.rbs', line 19

def initialize: (access_key: String?, nsu: untyped, status: untyped, name_sender: String?, federal_tax_number_sender: String?, total_invoice_amount: untyped, issued_on: String?, product_invoices: untyped, details: untyped) -> void

Instance Attribute Details

#access_keyString? (readonly)

Returns the value of attribute access_key.

Returns:

  • (String, nil)


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

def access_key
  @access_key
end

#detailsObject (readonly)

Returns the value of attribute details.

Returns:

  • (Object)


11
12
13
# File 'sig/nfe/resources/dto/inbound_invoice_metadata.rbs', line 11

def details
  @details
end

#federal_tax_number_senderString? (readonly)

Returns the value of attribute federal_tax_number_sender.

Returns:

  • (String, nil)


7
8
9
# File 'sig/nfe/resources/dto/inbound_invoice_metadata.rbs', line 7

def federal_tax_number_sender
  @federal_tax_number_sender
end

#issued_onString? (readonly)

Returns the value of attribute issued_on.

Returns:

  • (String, nil)


9
10
11
# File 'sig/nfe/resources/dto/inbound_invoice_metadata.rbs', line 9

def issued_on
  @issued_on
end

#name_senderString? (readonly)

Returns the value of attribute name_sender.

Returns:

  • (String, nil)


6
7
8
# File 'sig/nfe/resources/dto/inbound_invoice_metadata.rbs', line 6

def name_sender
  @name_sender
end

#nsuObject (readonly)

Returns the value of attribute nsu.

Returns:

  • (Object)


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

def nsu
  @nsu
end

#product_invoicesObject (readonly)

Returns the value of attribute product_invoices.

Returns:

  • (Object)


10
11
12
# File 'sig/nfe/resources/dto/inbound_invoice_metadata.rbs', line 10

def product_invoices
  @product_invoices
end

#statusObject (readonly)

Returns the value of attribute status.

Returns:

  • (Object)


5
6
7
# File 'sig/nfe/resources/dto/inbound_invoice_metadata.rbs', line 5

def status
  @status
end

#total_invoice_amountObject (readonly)

Returns the value of attribute total_invoice_amount.

Returns:

  • (Object)


8
9
10
# File 'sig/nfe/resources/dto/inbound_invoice_metadata.rbs', line 8

def total_invoice_amount
  @total_invoice_amount
end

Class Method Details

.from_api(payload) ⇒ Nfe::InboundInvoiceMetadata?

Build a Nfe::InboundInvoiceMetadata from an API payload.

Parameters:

  • payload (Hash, nil)

    the inbound document metadata object.

Returns:



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/nfe/resources/dto/inbound_invoice_metadata.rb', line 28

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

  new(
    access_key: payload["accessKey"] || payload["accesskey"],
    nsu: payload["nsu"],
    status: payload["status"],
    name_sender: payload["nameSender"],
    federal_tax_number_sender: stringify(payload["federalTaxNumberSender"]),
    total_invoice_amount: payload["totalInvoiceAmount"],
    issued_on: payload["issuedOn"],
    product_invoices: payload["productInvoices"],
    details: payload
  )
end

.newinstance

Parameters:

  • access_key: (String, nil)
  • nsu: (Object)
  • status: (Object)
  • name_sender: (String, nil)
  • federal_tax_number_sender: (String, nil)
  • total_invoice_amount: (Object)
  • issued_on: (String, nil)
  • product_invoices: (Object)
  • details: (Object)

Returns:

  • (instance)


17
# File 'sig/nfe/resources/dto/inbound_invoice_metadata.rbs', line 17

def self.new: (access_key: String?, nsu: untyped, status: untyped, name_sender: String?, federal_tax_number_sender: String?, total_invoice_amount: untyped, issued_on: String?, product_invoices: untyped, details: untyped) -> instance

.stringify(value) ⇒ String?

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.

Coerce a tax number to a String without numeric coercion. nil stays nil.

Parameters:

  • value (Object)

Returns:

  • (String, nil)


48
49
50
# File 'lib/nfe/resources/dto/inbound_invoice_metadata.rb', line 48

def self.stringify(value)
  value&.to_s
end