Class: Nylas::Webhooks
- Includes:
- ApiOperations::Delete, ApiOperations::Get, ApiOperations::Post, ApiOperations::Put
- Defined in:
- lib/nylas/resources/webhooks.rb
Overview
Nylas Webhooks API
Class Method Summary collapse
-
.extract_challenge_parameter(url) ⇒ String
Extract the challenge parameter from a URL.
Instance Method Summary collapse
-
#create(request_body:) ⇒ Array(Hash, String)
Create a webhook.
-
#destroy(webhook_id:) ⇒ Array(TrueClass, String)
Delete a webhook.
-
#find(webhook_id:) ⇒ Array(Hash, String)
Return a webhook.
-
#ip_addresses ⇒ Array(Hash, String)
Get the current list of IP addresses that Nylas sends webhooks from.
-
#list ⇒ Array(Array(Hash), String)
Return all webhooks.
-
#rotate_secret(webhook_id:) ⇒ Array(Hash, String)
Update the webhook secret value for a destination.
-
#update(webhook_id:, request_body:) ⇒ Array(Hash, String)
Update a webhook.
Methods inherited from Resource
Constructor Details
This class inherits a constructor from Nylas::Resource
Class Method Details
.extract_challenge_parameter(url) ⇒ String
Extract the challenge parameter from a URL
114 115 116 117 118 119 120 121 122 123 124 |
# 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 |
Instance Method Details
#create(request_body:) ⇒ Array(Hash, String)
Create a webhook.
62 63 64 65 66 67 |
# File 'lib/nylas/resources/webhooks.rb', line 62 def create(request_body:) post( path: "#{api_uri}/v3/webhooks", request_body: request_body ) end |
#destroy(webhook_id:) ⇒ Array(TrueClass, String)
Delete a webhook.
85 86 87 88 89 90 91 |
# 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 |
#find(webhook_id:) ⇒ Array(Hash, String)
Return a webhook.
52 53 54 55 56 |
# File 'lib/nylas/resources/webhooks.rb', line 52 def find(webhook_id:) get( path: "#{api_uri}/v3/webhooks/#{webhook_id}" ) end |
#ip_addresses ⇒ Array(Hash, String)
Get the current list of IP addresses that Nylas sends webhooks from
105 106 107 108 109 |
# File 'lib/nylas/resources/webhooks.rb', line 105 def ip_addresses get( path: "#{api_uri}/v3/webhooks/ip-addresses" ) end |
#list ⇒ Array(Array(Hash), String)
Return all webhooks.
42 43 44 45 46 |
# File 'lib/nylas/resources/webhooks.rb', line 42 def list get( path: "#{api_uri}/v3/webhooks" ) end |
#rotate_secret(webhook_id:) ⇒ Array(Hash, String)
Update the webhook secret value for a destination.
96 97 98 99 100 101 |
# 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(webhook_id:, request_body:) ⇒ Array(Hash, String)
Update a webhook.
74 75 76 77 78 79 |
# 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 |