class Nylas::Webhooks
Public Class Methods
Extract the challenge parameter from a URL @param url [String] The URL sent by Nylas
containing the challenge parameter @return [String] The challenge parameter
# File lib/nylas/resources/webhooks.rb, line 114 def self.extract_challenge_parameter(url) url_object = URI.parse(url) query = CGI.parse(url_object.query || "") challenge_parameter = query["challenge"] if challenge_parameter.nil? || challenge_parameter.empty? || challenge_parameter.first.nil? raise "Invalid URL or no challenge parameter found." end challenge_parameter.first end
Public Instance Methods
Create a webhook.
@param request_body [Hash] The values to create the webhook with. @return [Array(Hash, String)] The created webhook and API Request ID.
# File lib/nylas/resources/webhooks.rb, line 62 def create(request_body:) post( path: "#{api_uri}/v3/webhooks", request_body: request_body ) end
Delete a webhook.
@param webhook_id [String] The id of the webhook to delete. @return [Array(TrueClass, String)] True and the API Request ID for the delete operation.
# File lib/nylas/resources/webhooks.rb, line 85 def destroy(webhook_id:) _, request_id = delete( path: "#{api_uri}/v3/webhooks/#{webhook_id}" ) [true, request_id] end
Return a webhook.
@param webhook_id [String] The id of the webhook to return. @return [Array(Hash, String)] The webhook and API request ID.
# File lib/nylas/resources/webhooks.rb, line 52 def find(webhook_id:) get( path: "#{api_uri}/v3/webhooks/#{webhook_id}" ) end
Return all webhooks.
@return [Array(Array(Hash), String)] The list of webhooks and API Request ID.
# File lib/nylas/resources/webhooks.rb, line 42 def list get( path: "#{api_uri}/v3/webhooks" ) end
Update the webhook secret value for a destination. @param webhook_id [String] The ID of the webhook destination to update. @return [Array(Hash, String)] The updated webhook destination and API Request ID.
# File lib/nylas/resources/webhooks.rb, line 96 def rotate_secret(webhook_id:) post( path: "#{api_uri}/v3/webhooks/rotate-secret/#{webhook_id}", request_body: {} ) end
Update a webhook.
@param webhook_id [String] The id of the webhook to update. @param request_body [Hash] The values to update the webhook with @return [Array(Hash, String)] The updated webhook and API Request ID.
# File lib/nylas/resources/webhooks.rb, line 74 def update(webhook_id:, request_body:) put( path: "#{api_uri}/v3/webhooks/#{webhook_id}", request_body: request_body ) end