Class: Nfe::ProductInvoiceEventsResponse

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

Overview

Immutable value object for the events (eventos) associated with a product invoice (NF-e), fetched from the nfe.api.nfe.io query API by access key.

Hand-written (the consulta_nfe_distribuicao_v1 generated schema does not cover this shape). ProductInvoiceEventsResponse.from_api maps API camelCase keys onto snake_case members, drops unknown keys, and is nil-tolerant (+from_api(nil)+ returns nil). All fields are optional.

events is kept as the raw payload array (free-form event bodies); a missing list normalizes to [].

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeProductInvoiceEventsResponse

Returns a new instance of ProductInvoiceEventsResponse.

Parameters:

  • events: (Object)
  • created_on: (String, nil)


10
# File 'sig/nfe/resources/dto/product_invoice_query/product_invoice_events_response.rbs', line 10

def initialize: (events: untyped, created_on: String?) -> void

Instance Attribute Details

#created_onString? (readonly)

Returns the value of attribute created_on.

Returns:

  • (String, nil)


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

def created_on
  @created_on
end

#eventsObject (readonly)

Returns the value of attribute events.

Returns:

  • (Object)


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

def events
  @events
end

Class Method Details

.from_api(payload) ⇒ Nfe::ProductInvoiceEventsResponse?

Build a Nfe::ProductInvoiceEventsResponse from an API payload.

Parameters:

  • payload (Hash, nil)

    the response object.

Returns:



22
23
24
25
26
27
28
29
# File 'lib/nfe/resources/dto/product_invoice_query/product_invoice_events_response.rb', line 22

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

  new(
    events: payload["events"] || [],
    created_on: payload["createdOn"]
  )
end

.newinstance

Parameters:

  • events: (Object)
  • created_on: (String, nil)

Returns:

  • (instance)


8
# File 'sig/nfe/resources/dto/product_invoice_query/product_invoice_events_response.rbs', line 8

def self.new: (events: untyped, created_on: String?) -> instance