class Mailersend::Webhooks
This is a class for getting the analytics from MailerSend API.
Attributes
client[RW]
domain_id[RW]
enabled[RW]
events[RW]
name[RW]
url[RW]
Public Class Methods
new(client = Mailersend::Client.new)
click to toggle source
# File lib/mailersend/webhooks/webhooks.rb, line 13 def initialize(client = Mailersend::Client.new) @client = client @domain_id = domain_id @url = url @name = name @events = [] @enabled = enabled @events = events end
Public Instance Methods
create(url:, name:, events:, domain_id:, enabled: nil)
click to toggle source
# File lib/mailersend/webhooks/webhooks.rb, line 37 def create(url:, name:, events:, domain_id:, enabled: nil) hash = { 'url' => url, 'name' => name, 'events' => events, 'domain_id' => domain_id, 'enabled' => enabled.to_s == 'true' } response = client.http.post("#{API_URL}/webhooks", json: hash.compact) puts response end
delete(webhook_id:)
click to toggle source
# File lib/mailersend/webhooks/webhooks.rb, line 61 def delete(webhook_id:) response = client.http.delete("#{API_URL}/webhooks/#{webhook_id}") puts response end
list(domain_id:)
click to toggle source
# File lib/mailersend/webhooks/webhooks.rb, line 23 def list(domain_id:) hash = { 'domain_id' => domain_id } response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/webhooks', query: URI.encode_www_form(hash))) puts response end
single(webhook_id:)
click to toggle source
# File lib/mailersend/webhooks/webhooks.rb, line 32 def single(webhook_id:) response = client.http.get("#{API_URL}/webhooks/#{webhook_id}") puts response end
update(webhook_id:, url: nil, name: nil, events: nil, enabled: nil)
click to toggle source
# File lib/mailersend/webhooks/webhooks.rb, line 50 def update(webhook_id:, url: nil, name: nil, events: nil, enabled: nil) hash = { 'url' => url, 'name' => name, 'events' => events, 'enabled' => enabled.to_s == 'true' } response = client.http.put("#{API_URL}/webhooks/#{webhook_id}", json: hash.compact) puts response end