Class: SurgeAPI::Resources::Webhooks
- Inherits:
-
Object
- Object
- SurgeAPI::Resources::Webhooks
- Defined in:
- lib/surge_api/resources/webhooks.rb,
sig/surge_api/resources/webhooks.rbs
Instance Method Summary collapse
-
#initialize(client:) ⇒ Webhooks
constructor
private
A new instance of Webhooks.
- #unwrap(payload, headers:, key: @client.webhook_signing_secret) ⇒ SurgeAPI::Models::CallEndedWebhookEvent, ...
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.
27 28 29 |
# File 'lib/surge_api/resources/webhooks.rb', line 27 def initialize(client:) @client = client end |
Instance Method Details
#unwrap(payload, headers:, key: @client.webhook_signing_secret) ⇒ SurgeAPI::Models::CallEndedWebhookEvent, ...
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/surge_api/resources/webhooks.rb', line 13 def unwrap(payload, headers:, key: @client.webhook_signing_secret) if key.nil? raise ArgumentError.new("Cannot verify a webhook without a key on either the client's webhook_signing_secret or passed in as an argument") end ::StandardWebhooks::Webhook.new(key).verify(payload, headers) parsed = JSON.parse(payload, symbolize_names: true) SurgeAPI::Internal::Type::Converter.coerce(SurgeAPI::Models::UnwrapWebhookEvent, parsed) end |