Class: Nfe::WebhookSubscription
- Inherits:
-
Data
- Object
- Data
- Nfe::WebhookSubscription
- 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
-
#active ⇒ Boolean?
readonly
Returns the value of attribute active.
-
#created_on ⇒ String?
readonly
Returns the value of attribute created_on.
-
#events ⇒ Array[String]?
readonly
Returns the value of attribute events.
-
#id ⇒ String?
readonly
Returns the value of attribute id.
-
#modified_on ⇒ String?
readonly
Returns the value of attribute modified_on.
-
#secret ⇒ String?
readonly
Returns the value of attribute secret.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#url ⇒ String?
readonly
Returns the value of attribute url.
Class Method Summary collapse
-
.from_api(payload) ⇒ Nfe::WebhookSubscription?
nilwhenpayloadisnil. - .new ⇒ instance
Instance Method Summary collapse
-
#initialize ⇒ WebhookSubscription
constructor
A new instance of WebhookSubscription.
Constructor Details
#initialize ⇒ WebhookSubscription
Returns a new instance of WebhookSubscription.
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
#active ⇒ Boolean? (readonly)
Returns the value of attribute active.
7 8 9 |
# File 'sig/nfe/resources/dto/webhook.rbs', line 7 def active @active end |
#created_on ⇒ String? (readonly)
Returns the value of attribute created_on.
9 10 11 |
# File 'sig/nfe/resources/dto/webhook.rbs', line 9 def created_on @created_on end |
#events ⇒ Array[String]? (readonly)
Returns the value of attribute events.
5 6 7 |
# File 'sig/nfe/resources/dto/webhook.rbs', line 5 def events @events end |
#id ⇒ String? (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'sig/nfe/resources/dto/webhook.rbs', line 3 def id @id end |
#modified_on ⇒ String? (readonly)
Returns the value of attribute modified_on.
10 11 12 |
# File 'sig/nfe/resources/dto/webhook.rbs', line 10 def modified_on @modified_on end |
#secret ⇒ String? (readonly)
Returns the value of attribute secret.
6 7 8 |
# File 'sig/nfe/resources/dto/webhook.rbs', line 6 def secret @secret end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
8 9 10 |
# File 'sig/nfe/resources/dto/webhook.rbs', line 8 def status @status end |
#url ⇒ String? (readonly)
Returns the value of attribute url.
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.
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 |
.new ⇒ 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
|