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