Class: Cadenya::Resources::Webhooks
- Inherits:
-
Object
- Object
- Cadenya::Resources::Webhooks
- Defined in:
- lib/cadenya/resources/webhooks.rb
Instance Method Summary collapse
-
#initialize(client:) ⇒ Webhooks
constructor
private
A new instance of Webhooks.
- #unsafe_unwrap(payload) ⇒ Cadenya::Models::UnsafeUnwrapWebhookEvent
- #unwrap(payload, headers:, key: @client.webhook_key) ⇒ Cadenya::Models::UnwrapWebhookEvent
Constructor Details
#initialize(client:) ⇒ Webhooks
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.
Returns a new instance of Webhooks.
35 36 37 |
# File 'lib/cadenya/resources/webhooks.rb', line 35 def initialize(client:) @client = client end |
Instance Method Details
#unsafe_unwrap(payload) ⇒ Cadenya::Models::UnsafeUnwrapWebhookEvent
9 10 11 12 |
# File 'lib/cadenya/resources/webhooks.rb', line 9 def unsafe_unwrap(payload) parsed = JSON.parse(payload, symbolize_names: true) Cadenya::Internal::Type::Converter.coerce(Cadenya::Models::UnsafeUnwrapWebhookEvent, parsed) end |
#unwrap(payload, headers:, key: @client.webhook_key) ⇒ Cadenya::Models::UnwrapWebhookEvent
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/cadenya/resources/webhooks.rb', line 21 def unwrap(payload, headers:, key: @client.webhook_key) if key.nil? raise ArgumentError.new("Cannot verify a webhook without a key on either the client's webhook_key or passed in as an argument") end ::StandardWebhooks::Webhook.new(key).verify(payload, headers) parsed = JSON.parse(payload, symbolize_names: true) Cadenya::Internal::Type::Converter.coerce(Cadenya::Models::UnwrapWebhookEvent, parsed) end |