Class: Nfe::WebhookSubscription

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

Overview

Immutable value object for a persisted webhook subscription, as returned by the /companies/{id}/webhooks entity API.

NOTE ON NAMING: the spec text refers to this DTO as "Nfe::Webhook", but that constant is reserved for the canonical signature-verification module (Webhook, lib/nfe/webhook.rb). A Ruby module and a class cannot share a constant, so the subscription DTO is named Nfe::WebhookSubscription. Resources hydrating a webhook subscription (+Nfe::Resources::Webhooks+) MUST hydrate this class.

WebhookSubscription.from_api maps API camelCase onto snake_case, drops unknown keys, and is nil-tolerant (+from_api(nil)+ returns nil).

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeWebhookSubscription

Returns a new instance of WebhookSubscription.

Parameters:

  • id: (String, nil)
  • url: (String, nil)
  • events: (Array[String], nil)
  • secret: (String, nil)
  • active: (Boolean, nil)
  • status: (Object)
  • created_on: (String, nil)
  • modified_on: (String, nil)


16
# File 'sig/nfe/resources/dto/webhook.rbs', line 16

def initialize: (id: String?, url: String?, events: Array[String]?, secret: String?, active: bool?, status: untyped, created_on: String?, modified_on: String?) -> void

Instance Attribute Details

#activeBoolean? (readonly)

Returns the value of attribute active.

Returns:

  • (Boolean, nil)


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

def active
  @active
end

#created_onString? (readonly)

Returns the value of attribute created_on.

Returns:

  • (String, nil)


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

def created_on
  @created_on
end

#eventsArray[String]? (readonly)

Returns the value of attribute events.

Returns:

  • (Array[String], nil)


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

def events
  @events
end

#idString? (readonly)

Returns the value of attribute id.

Returns:

  • (String, nil)


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

def id
  @id
end

#modified_onString? (readonly)

Returns the value of attribute modified_on.

Returns:

  • (String, nil)


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

def modified_on
  @modified_on
end

#secretString? (readonly)

Returns the value of attribute secret.

Returns:

  • (String, nil)


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

def secret
  @secret
end

#statusObject (readonly)

Returns the value of attribute status.

Returns:

  • (Object)


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

def status
  @status
end

#urlString? (readonly)

Returns the value of attribute url.

Returns:

  • (String, nil)


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

def url
  @url
end

Class Method Details

.from_api(payload) ⇒ Nfe::WebhookSubscription?

Returns nil when payload is nil.

Parameters:

  • payload (Hash, nil)

    the unwrapped webhook object.

Returns:



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

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

  new(
    id: payload["id"],
    url: payload["url"],
    events: payload["events"],
    secret: payload["secret"],
    active: payload["active"],
    status: payload["status"],
    created_on: payload["createdOn"],
    modified_on: payload["modifiedOn"]
  )
end

.newinstance

Parameters:

  • id: (String, nil)
  • url: (String, nil)
  • events: (Array[String], nil)
  • secret: (String, nil)
  • active: (Boolean, nil)
  • status: (Object)
  • created_on: (String, nil)
  • modified_on: (String, nil)

Returns:

  • (instance)


14
# File 'sig/nfe/resources/dto/webhook.rbs', line 14

def self.new: (id: String?, url: String?, events: Array[String]?, secret: String?, active: bool?, status: untyped, created_on: String?, modified_on: String?) -> instance