Class: Mailgunner::Client
- Inherits:
-
Object
- Object
- Mailgunner::Client
- Defined in:
- lib/mailgunner/client.rb,
lib/mailgunner/client/ips.rb,
lib/mailgunner/client/tags.rb,
lib/mailgunner/client/stats.rb,
lib/mailgunner/client/events.rb,
lib/mailgunner/client/routes.rb,
lib/mailgunner/client/domains.rb,
lib/mailgunner/client/messages.rb,
lib/mailgunner/client/webhooks.rb,
lib/mailgunner/client/suppressions.rb,
lib/mailgunner/client/mailing_lists.rb,
lib/mailgunner/client/email_validation.rb
Instance Method Summary collapse
- #add_bounce(attributes = ATTRIBUTES) ⇒ Object
- #add_complaint(attributes = ATTRIBUTES) ⇒ Object
- #add_credentials(attributes) ⇒ Object
- #add_domain(attributes = ATTRIBUTES) ⇒ Object
- #add_ip(address) ⇒ Object
- #add_list(attributes = ATTRIBUTES) ⇒ Object
- #add_list_member(list_address, member_attributes) ⇒ Object
- #add_route(attributes = ATTRIBUTES) ⇒ Object
- #add_unsubscribe(attributes = ATTRIBUTES) ⇒ Object
- #add_webhook(attributes = ATTRIBUTES) ⇒ Object
- #add_whitelist(attributes = ATTRIBUTES) ⇒ Object
- #cancel_bulk_validation(list_id) ⇒ Object
- #create_bulk_validation(list_id) ⇒ Object
- #delete_bounce(address) ⇒ Object
- #delete_bounces ⇒ Object
- #delete_complaint(address) ⇒ Object
- #delete_complaints ⇒ Object
- #delete_credentials(login) ⇒ Object
- #delete_domain(name) ⇒ Object
- #delete_ip(address) ⇒ Object
- #delete_list(address) ⇒ Object
- #delete_list_member(list_address, member_address) ⇒ Object
- #delete_message(key) ⇒ Object
- #delete_route(id) ⇒ Object
- #delete_tag(id) ⇒ Object
- #delete_unsubscribe(address_or_id) ⇒ Object
- #delete_unsubscribes ⇒ Object
- #delete_webhook(id) ⇒ Object
- #delete_whitelist(address_or_domain) ⇒ Object
- #get_all_ips(params = PARAMS) ⇒ Object
- #get_bounce(address) ⇒ Object
- #get_bounces(params = PARAMS) ⇒ Object
- #get_bulk_validation(list_id) ⇒ Object
- #get_bulk_validations ⇒ Object
- #get_complaint(address) ⇒ Object
- #get_complaints(params = PARAMS) ⇒ Object
- #get_connection_settings ⇒ Object
- #get_credentials ⇒ Object
- #get_domain(name) ⇒ Object
- #get_domains(params = PARAMS) ⇒ Object
- #get_events(params = PARAMS) ⇒ Object
- #get_ip(address) ⇒ Object
- #get_ips ⇒ Object
- #get_list(address) ⇒ Object
- #get_list_member(list_address, member_address) ⇒ Object
- #get_list_members(list_address, params = PARAMS) ⇒ Object
- #get_lists(params = PARAMS) ⇒ Object
- #get_message(key) ⇒ Object
- #get_mime_message(key) ⇒ Object
- #get_route(id) ⇒ Object
- #get_routes(params = PARAMS) ⇒ Object
- #get_tag(id) ⇒ Object
- #get_tag_stats(id, params) ⇒ Object
- #get_tags(params = PARAMS) ⇒ Object
- #get_total_stats(params = PARAMS) ⇒ Object
- #get_tracking_settings ⇒ Object
- #get_unsubscribe(address) ⇒ Object
- #get_unsubscribes(params = PARAMS) ⇒ Object
- #get_webhook(id) ⇒ Object
- #get_webhooks ⇒ Object
- #get_whitelist(address_or_domain) ⇒ Object
- #get_whitelists(params = PARAMS) ⇒ Object
-
#initialize(domain: nil, api_key: nil, api_host: nil) ⇒ Client
constructor
A new instance of Client.
- #send_message(attributes = ATTRIBUTES) ⇒ Object
- #send_mime(mail) ⇒ Object
- #update_click_tracking_settings(params = PARAMS) ⇒ Object
- #update_connection_settings(attributes) ⇒ Object
- #update_credentials(login, attributes) ⇒ Object
- #update_dkim_authority(params = PARAMS) ⇒ Object
- #update_dkim_selector(params = PARAMS) ⇒ Object
- #update_list(address, attributes = ATTRIBUTES) ⇒ Object
- #update_list_member(list_address, member_address, member_attributes) ⇒ Object
- #update_open_tracking_settings(params = PARAMS) ⇒ Object
- #update_route(id, attributes = ATTRIBUTES) ⇒ Object
- #update_tag(id, attributes) ⇒ Object
- #update_unsubscribe_tracking_settings(params = PARAMS) ⇒ Object
- #update_web_prefix(params = PARAMS) ⇒ Object
- #update_webhook(id, attributes = ATTRIBUTES) ⇒ Object
- #validate_address(value) ⇒ Object
- #verify_domain(name) ⇒ Object
Constructor Details
#initialize(domain: nil, api_key: nil, api_host: nil) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/mailgunner/client.rb', line 7 def initialize(domain: nil, api_key: nil, api_host: nil) @domain = domain || Mailgunner.config.domain @api_key = api_key || Mailgunner.config.api_key @api_host = api_host || Mailgunner.config.api_host @http = Net::HTTP.new(@api_host, Net::HTTP.https_default_port) @http.use_ssl = true end |
Instance Method Details
#add_bounce(attributes = ATTRIBUTES) ⇒ Object
13 14 15 |
# File 'lib/mailgunner/client/suppressions.rb', line 13 def add_bounce(attributes = ATTRIBUTES) post("/v3/#{escape @domain}/bounces", attributes) end |
#add_complaint(attributes = ATTRIBUTES) ⇒ Object
53 54 55 |
# File 'lib/mailgunner/client/suppressions.rb', line 53 def add_complaint(attributes = ATTRIBUTES) post("/v3/#{escape @domain}/complaints", attributes) end |
#add_credentials(attributes) ⇒ Object
29 30 31 |
# File 'lib/mailgunner/client/domains.rb', line 29 def add_credentials(attributes) post("/v3/domains/#{escape @domain}/credentials", attributes) end |
#add_domain(attributes = ATTRIBUTES) ⇒ Object
13 14 15 |
# File 'lib/mailgunner/client/domains.rb', line 13 def add_domain(attributes = ATTRIBUTES) post('/v3/domains', attributes) end |
#add_ip(address) ⇒ Object
17 18 19 |
# File 'lib/mailgunner/client/ips.rb', line 17 def add_ip(address) post("/v3/domains/#{escape @domain}/ips", ip: address) end |
#add_list(attributes = ATTRIBUTES) ⇒ Object
13 14 15 |
# File 'lib/mailgunner/client/mailing_lists.rb', line 13 def add_list(attributes = ATTRIBUTES) post('/v3/lists', attributes) end |
#add_list_member(list_address, member_attributes) ⇒ Object
33 34 35 |
# File 'lib/mailgunner/client/mailing_lists.rb', line 33 def add_list_member(list_address, member_attributes) post("/v3/lists/#{escape list_address}/members", member_attributes) end |
#add_route(attributes = ATTRIBUTES) ⇒ Object
13 14 15 |
# File 'lib/mailgunner/client/routes.rb', line 13 def add_route(attributes = ATTRIBUTES) post('/v3/routes', attributes) end |
#add_unsubscribe(attributes = ATTRIBUTES) ⇒ Object
41 42 43 |
# File 'lib/mailgunner/client/suppressions.rb', line 41 def add_unsubscribe(attributes = ATTRIBUTES) post("/v3/#{escape @domain}/unsubscribes", attributes) end |
#add_webhook(attributes = ATTRIBUTES) ⇒ Object
13 14 15 |
# File 'lib/mailgunner/client/webhooks.rb', line 13 def add_webhook(attributes = ATTRIBUTES) post("/v3/domains/#{escape @domain}/webhooks", attributes) end |
#add_whitelist(attributes = ATTRIBUTES) ⇒ Object
73 74 75 |
# File 'lib/mailgunner/client/suppressions.rb', line 73 def add_whitelist(attributes = ATTRIBUTES) post("/v3/#{escape @domain}/whitelists", attributes) end |
#cancel_bulk_validation(list_id) ⇒ Object
21 22 23 |
# File 'lib/mailgunner/client/email_validation.rb', line 21 def cancel_bulk_validation(list_id) delete("/v4/address/validate/bulk/#{escape list_id}") end |
#create_bulk_validation(list_id) ⇒ Object
13 14 15 |
# File 'lib/mailgunner/client/email_validation.rb', line 13 def create_bulk_validation(list_id) post("/v4/address/validate/bulk/#{escape list_id}") end |
#delete_bounce(address) ⇒ Object
17 18 19 |
# File 'lib/mailgunner/client/suppressions.rb', line 17 def delete_bounce(address) delete("/v3/#{escape @domain}/bounces/#{escape address}") end |
#delete_bounces ⇒ Object
21 22 23 |
# File 'lib/mailgunner/client/suppressions.rb', line 21 def delete_bounces delete("/v3/#{escape @domain}/bounces") end |
#delete_complaint(address) ⇒ Object
57 58 59 |
# File 'lib/mailgunner/client/suppressions.rb', line 57 def delete_complaint(address) delete("/v3/#{escape @domain}/complaints/#{escape address}") end |
#delete_complaints ⇒ Object
61 62 63 |
# File 'lib/mailgunner/client/suppressions.rb', line 61 def delete_complaints delete("/v3/#{escape @domain}/complaints") end |
#delete_credentials(login) ⇒ Object
37 38 39 |
# File 'lib/mailgunner/client/domains.rb', line 37 def delete_credentials(login) delete("/v3/domains/#{escape @domain}/credentials/#{escape login}") end |
#delete_domain(name) ⇒ Object
17 18 19 |
# File 'lib/mailgunner/client/domains.rb', line 17 def delete_domain(name) delete("/v3/domains/#{escape name}") end |
#delete_ip(address) ⇒ Object
21 22 23 |
# File 'lib/mailgunner/client/ips.rb', line 21 def delete_ip(address) delete("/v3/domains/#{escape @domain}/ips/#{escape address}") end |
#delete_list(address) ⇒ Object
21 22 23 |
# File 'lib/mailgunner/client/mailing_lists.rb', line 21 def delete_list(address) delete("/v3/lists/#{escape address}") end |
#delete_list_member(list_address, member_address) ⇒ Object
41 42 43 |
# File 'lib/mailgunner/client/mailing_lists.rb', line 41 def delete_list_member(list_address, member_address) delete("/v3/lists/#{escape list_address}/members/#{escape member_address}") end |
#delete_message(key) ⇒ Object
25 26 27 |
# File 'lib/mailgunner/client/messages.rb', line 25 def (key) delete("/v3/domains/#{escape @domain}/messages/#{escape key}") end |
#delete_route(id) ⇒ Object
21 22 23 |
# File 'lib/mailgunner/client/routes.rb', line 21 def delete_route(id) delete("/v3/routes/#{escape id}") end |
#delete_tag(id) ⇒ Object
21 22 23 |
# File 'lib/mailgunner/client/tags.rb', line 21 def delete_tag(id) delete("/v3/#{escape @domain}/tags/#{escape id}") end |
#delete_unsubscribe(address_or_id) ⇒ Object
33 34 35 |
# File 'lib/mailgunner/client/suppressions.rb', line 33 def delete_unsubscribe(address_or_id) delete("/v3/#{escape @domain}/unsubscribes/#{escape address_or_id}") end |
#delete_unsubscribes ⇒ Object
37 38 39 |
# File 'lib/mailgunner/client/suppressions.rb', line 37 def delete_unsubscribes delete("/v3/#{escape @domain}/unsubscribes") end |
#delete_webhook(id) ⇒ Object
21 22 23 |
# File 'lib/mailgunner/client/webhooks.rb', line 21 def delete_webhook(id) delete("/v3/domains/#{escape @domain}/webhooks/#{escape id}") end |
#delete_whitelist(address_or_domain) ⇒ Object
77 78 79 |
# File 'lib/mailgunner/client/suppressions.rb', line 77 def delete_whitelist(address_or_domain) delete("/v3/#{escape @domain}/whitelists/#{escape address_or_domain}") end |
#get_all_ips(params = PARAMS) ⇒ Object
5 6 7 |
# File 'lib/mailgunner/client/ips.rb', line 5 def get_all_ips(params = PARAMS) get('/v3/ips', query: params) end |
#get_bounce(address) ⇒ Object
9 10 11 |
# File 'lib/mailgunner/client/suppressions.rb', line 9 def get_bounce(address) get("/v3/#{escape @domain}/bounces/#{escape address}") end |
#get_bounces(params = PARAMS) ⇒ Object
5 6 7 |
# File 'lib/mailgunner/client/suppressions.rb', line 5 def get_bounces(params = PARAMS) get("/v3/#{escape @domain}/bounces", query: params) end |
#get_bulk_validation(list_id) ⇒ Object
17 18 19 |
# File 'lib/mailgunner/client/email_validation.rb', line 17 def get_bulk_validation(list_id) get("/v4/address/validate/bulk/#{escape list_id}") end |
#get_bulk_validations ⇒ Object
9 10 11 |
# File 'lib/mailgunner/client/email_validation.rb', line 9 def get_bulk_validations get('/v4/address/validate/bulk') end |
#get_complaint(address) ⇒ Object
49 50 51 |
# File 'lib/mailgunner/client/suppressions.rb', line 49 def get_complaint(address) get("/v3/#{escape @domain}/complaints/#{escape address}") end |
#get_complaints(params = PARAMS) ⇒ Object
45 46 47 |
# File 'lib/mailgunner/client/suppressions.rb', line 45 def get_complaints(params = PARAMS) get("/v3/#{escape @domain}/complaints", query: params) end |
#get_connection_settings ⇒ Object
41 42 43 |
# File 'lib/mailgunner/client/domains.rb', line 41 def get_connection_settings get("/v3/domains/#{escape @domain}/connection") end |
#get_credentials ⇒ Object
25 26 27 |
# File 'lib/mailgunner/client/domains.rb', line 25 def get_credentials get("/v3/domains/#{escape @domain}/credentials") end |
#get_domain(name) ⇒ Object
9 10 11 |
# File 'lib/mailgunner/client/domains.rb', line 9 def get_domain(name) get("/v3/domains/#{escape name}") end |
#get_domains(params = PARAMS) ⇒ Object
5 6 7 |
# File 'lib/mailgunner/client/domains.rb', line 5 def get_domains(params = PARAMS) get('/v3/domains', query: params) end |
#get_events(params = PARAMS) ⇒ Object
5 6 7 |
# File 'lib/mailgunner/client/events.rb', line 5 def get_events(params = PARAMS) get("/v3/#{escape @domain}/events", query: params) end |
#get_ip(address) ⇒ Object
9 10 11 |
# File 'lib/mailgunner/client/ips.rb', line 9 def get_ip(address) get("/v3/ips/#{escape address}") end |
#get_ips ⇒ Object
13 14 15 |
# File 'lib/mailgunner/client/ips.rb', line 13 def get_ips get("/v3/domains/#{escape @domain}/ips") end |
#get_list(address) ⇒ Object
9 10 11 |
# File 'lib/mailgunner/client/mailing_lists.rb', line 9 def get_list(address) get("/v3/lists/#{escape address}") end |
#get_list_member(list_address, member_address) ⇒ Object
29 30 31 |
# File 'lib/mailgunner/client/mailing_lists.rb', line 29 def get_list_member(list_address, member_address) get("/v3/lists/#{escape list_address}/members/#{escape member_address}") end |
#get_list_members(list_address, params = PARAMS) ⇒ Object
25 26 27 |
# File 'lib/mailgunner/client/mailing_lists.rb', line 25 def get_list_members(list_address, params = PARAMS) get("/v3/lists/#{escape list_address}/members/pages", query: params) end |
#get_lists(params = PARAMS) ⇒ Object
5 6 7 |
# File 'lib/mailgunner/client/mailing_lists.rb', line 5 def get_lists(params = PARAMS) get('/v3/lists/pages', query: params) end |
#get_message(key) ⇒ Object
5 6 7 |
# File 'lib/mailgunner/client/messages.rb', line 5 def (key) get("/v3/domains/#{escape @domain}/messages/#{escape key}") end |
#get_mime_message(key) ⇒ Object
9 10 11 |
# File 'lib/mailgunner/client/messages.rb', line 9 def (key) get("/v3/domains/#{escape @domain}/messages/#{escape key}", headers: {'Accept' => 'message/rfc2822'}) end |
#get_route(id) ⇒ Object
9 10 11 |
# File 'lib/mailgunner/client/routes.rb', line 9 def get_route(id) get("/v3/routes/#{escape id}") end |
#get_routes(params = PARAMS) ⇒ Object
5 6 7 |
# File 'lib/mailgunner/client/routes.rb', line 5 def get_routes(params = PARAMS) get('/v3/routes', query: params) end |
#get_tag(id) ⇒ Object
9 10 11 |
# File 'lib/mailgunner/client/tags.rb', line 9 def get_tag(id) get("/v3/#{escape @domain}/tags/#{escape id}") end |
#get_tag_stats(id, params) ⇒ Object
17 18 19 |
# File 'lib/mailgunner/client/tags.rb', line 17 def get_tag_stats(id, params) get("/v3/#{escape @domain}/tags/#{escape id}/stats", query: params) end |
#get_tags(params = PARAMS) ⇒ Object
5 6 7 |
# File 'lib/mailgunner/client/tags.rb', line 5 def (params = PARAMS) get("/v3/#{escape @domain}/tags", query: params) end |
#get_total_stats(params = PARAMS) ⇒ Object
5 6 7 |
# File 'lib/mailgunner/client/stats.rb', line 5 def get_total_stats(params = PARAMS) get("/v3/#{escape @domain}/stats/total", query: params) end |
#get_tracking_settings ⇒ Object
49 50 51 |
# File 'lib/mailgunner/client/domains.rb', line 49 def get_tracking_settings get("/v3/domains/#{escape @domain}/tracking") end |
#get_unsubscribe(address) ⇒ Object
29 30 31 |
# File 'lib/mailgunner/client/suppressions.rb', line 29 def get_unsubscribe(address) get("/v3/#{escape @domain}/unsubscribes/#{escape address}") end |
#get_unsubscribes(params = PARAMS) ⇒ Object
25 26 27 |
# File 'lib/mailgunner/client/suppressions.rb', line 25 def get_unsubscribes(params = PARAMS) get("/v3/#{escape @domain}/unsubscribes", query: params) end |
#get_webhook(id) ⇒ Object
9 10 11 |
# File 'lib/mailgunner/client/webhooks.rb', line 9 def get_webhook(id) get("/v3/domains/#{escape @domain}/webhooks/#{escape id}") end |
#get_webhooks ⇒ Object
5 6 7 |
# File 'lib/mailgunner/client/webhooks.rb', line 5 def get_webhooks get("/v3/domains/#{escape @domain}/webhooks") end |
#get_whitelist(address_or_domain) ⇒ Object
69 70 71 |
# File 'lib/mailgunner/client/suppressions.rb', line 69 def get_whitelist(address_or_domain) get("/v3/#{escape @domain}/whitelists/#{escape address_or_domain}") end |
#get_whitelists(params = PARAMS) ⇒ Object
65 66 67 |
# File 'lib/mailgunner/client/suppressions.rb', line 65 def get_whitelists(params = PARAMS) get("/v3/#{escape @domain}/whitelists", query: params) end |
#send_message(attributes = ATTRIBUTES) ⇒ Object
13 14 15 |
# File 'lib/mailgunner/client/messages.rb', line 13 def (attributes = ATTRIBUTES) post("/v3/#{escape @domain}/messages", attributes) end |
#send_mime(mail) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/mailgunner/client/messages.rb', line 17 def send_mime(mail) to = ['to', Array(mail.destinations).join(',')] = ['message', mail.encoded, {filename: 'message.mime'}] multipart_post("/v3/#{escape @domain}/messages.mime", [to, ]) end |
#update_click_tracking_settings(params = PARAMS) ⇒ Object
57 58 59 |
# File 'lib/mailgunner/client/domains.rb', line 57 def update_click_tracking_settings(params = PARAMS) put("/v3/domains/#{escape @domain}/tracking/click", params) end |
#update_connection_settings(attributes) ⇒ Object
45 46 47 |
# File 'lib/mailgunner/client/domains.rb', line 45 def update_connection_settings(attributes) put("/v3/domains/#{escape @domain}/connection", attributes) end |
#update_credentials(login, attributes) ⇒ Object
33 34 35 |
# File 'lib/mailgunner/client/domains.rb', line 33 def update_credentials(login, attributes) put("/v3/domains/#{escape @domain}/credentials/#{escape login}", attributes) end |
#update_dkim_authority(params = PARAMS) ⇒ Object
65 66 67 |
# File 'lib/mailgunner/client/domains.rb', line 65 def (params = PARAMS) put("/v3/domains/#{escape @domain}/dkim_authority", params) end |
#update_dkim_selector(params = PARAMS) ⇒ Object
69 70 71 |
# File 'lib/mailgunner/client/domains.rb', line 69 def update_dkim_selector(params = PARAMS) put("/v3/domains/#{escape @domain}/dkim_selector", params) end |
#update_list(address, attributes = ATTRIBUTES) ⇒ Object
17 18 19 |
# File 'lib/mailgunner/client/mailing_lists.rb', line 17 def update_list(address, attributes = ATTRIBUTES) put("/v3/lists/#{escape address}", attributes) end |
#update_list_member(list_address, member_address, member_attributes) ⇒ Object
37 38 39 |
# File 'lib/mailgunner/client/mailing_lists.rb', line 37 def update_list_member(list_address, member_address, member_attributes) put("/v3/lists/#{escape list_address}/members/#{escape member_address}", member_attributes) end |
#update_open_tracking_settings(params = PARAMS) ⇒ Object
53 54 55 |
# File 'lib/mailgunner/client/domains.rb', line 53 def update_open_tracking_settings(params = PARAMS) put("/v3/domains/#{escape @domain}/tracking/open", params) end |
#update_route(id, attributes = ATTRIBUTES) ⇒ Object
17 18 19 |
# File 'lib/mailgunner/client/routes.rb', line 17 def update_route(id, attributes = ATTRIBUTES) put("/v3/routes/#{escape id}", attributes) end |
#update_tag(id, attributes) ⇒ Object
13 14 15 |
# File 'lib/mailgunner/client/tags.rb', line 13 def update_tag(id, attributes) put("/v3/#{escape @domain}/tags/#{escape id}", attributes) end |
#update_unsubscribe_tracking_settings(params = PARAMS) ⇒ Object
61 62 63 |
# File 'lib/mailgunner/client/domains.rb', line 61 def update_unsubscribe_tracking_settings(params = PARAMS) put("/v3/domains/#{escape @domain}/tracking/unsubscribe", params) end |
#update_web_prefix(params = PARAMS) ⇒ Object
73 74 75 |
# File 'lib/mailgunner/client/domains.rb', line 73 def update_web_prefix(params = PARAMS) put("/v3/domains/#{escape @domain}/web_prefix", params) end |
#update_webhook(id, attributes = ATTRIBUTES) ⇒ Object
17 18 19 |
# File 'lib/mailgunner/client/webhooks.rb', line 17 def update_webhook(id, attributes = ATTRIBUTES) put("/v3/domains/#{escape @domain}/webhooks/#{escape id}", attributes) end |
#validate_address(value) ⇒ Object
5 6 7 |
# File 'lib/mailgunner/client/email_validation.rb', line 5 def validate_address(value) get('/v4/address/validate', query: {address: value}) end |
#verify_domain(name) ⇒ Object
21 22 23 |
# File 'lib/mailgunner/client/domains.rb', line 21 def verify_domain(name) put("/v3/domains/#{escape name}/verify") end |