Class: Nfe::WebhookEvent

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

Overview

Immutable value object for a verified webhook delivery, produced by Nfe::Webhook.construct_event after the HMAC-SHA1 signature checks out.

  • type is the event type (e.g. "invoice.issued"), unwrapped from the delivery envelope's action or event key.
  • data is the payload Hash (the envelope's payload or data key).
  • id is a stable event/invoice id for deduplication, or nil when the envelope carries none. NFE.io sends no timestamp/nonce, so a valid signature proves authenticity but NOT freshness — handlers MUST be idempotent and dedupe on this id.
  • created_at is the delivery timestamp string, or nil.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, data:, id: nil, created_at: nil) ⇒ WebhookEvent

Allow id and created_at to default to nil so callers (and construct_event) can omit them.

Parameters:

  • type: (String, nil)
  • data: (Hash[untyped, untyped])
  • id: (String, nil) (defaults to: nil)
  • created_at: (String, nil) (defaults to: nil)


18
19
20
# File 'lib/nfe/webhook_event.rb', line 18

def initialize(type:, data:, id: nil, created_at: nil)
  super
end

Instance Attribute Details

#created_atString? (readonly)

Returns the value of attribute created_at.

Returns:

  • (String, nil)


6
7
8
# File 'sig/nfe/webhook_event.rbs', line 6

def created_at
  @created_at
end

#dataHash[untyped, untyped] (readonly)

Returns the value of attribute data.

Returns:

  • (Hash[untyped, untyped])


4
5
6
# File 'sig/nfe/webhook_event.rbs', line 4

def data
  @data
end

#idString? (readonly)

Returns the value of attribute id.

Returns:

  • (String, nil)


5
6
7
# File 'sig/nfe/webhook_event.rbs', line 5

def id
  @id
end

#typeString? (readonly)

Returns the value of attribute type.

Returns:

  • (String, nil)


3
4
5
# File 'sig/nfe/webhook_event.rbs', line 3

def type
  @type
end

Class Method Details

.new(type:, data:, id:, created_at:) ⇒ instance .new(type, data, id, created_at) ⇒ instance

Overloads:

  • .new(type:, data:, id:, created_at:) ⇒ instance

    Parameters:

    • type: (String, nil)
    • data: (Hash[untyped, untyped])
    • id: (String, nil)
    • created_at: (String, nil)

    Returns:

    • (instance)
  • .new(type, data, id, created_at) ⇒ instance

    Parameters:

    • type (String, nil)
    • data (Hash[untyped, untyped])
    • id (String, nil)
    • created_at (String, nil)

    Returns:

    • (instance)


8
9
# File 'sig/nfe/webhook_event.rbs', line 8

def self.new: (type: String?, data: Hash[untyped, untyped], ?id: String?, ?created_at: String?) -> instance
| (String? type, Hash[untyped, untyped] data, ?String? id, ?String? created_at) -> instance