mailersend-ruby 3.4.1 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +27 -0
- data/fixtures/account/account_get.yml +43 -0
- data/fixtures/account/account_get_without_whatsapp.yml +43 -0
- data/fixtures/activity/activity_get_activity.yml +1 -1
- data/fixtures/api_quota/api_quota_get.yml +1 -1
- data/fixtures/bulk_email/bulk_email_send.yml +1 -1
- data/fixtures/bulk_email/bulk_email_status.yml +1 -1
- data/fixtures/dmarc_monitoring/add_favorite.yml +1 -1
- data/fixtures/dmarc_monitoring/create.yml +1 -1
- data/fixtures/dmarc_monitoring/delete.yml +1 -1
- data/fixtures/dmarc_monitoring/list.yml +1 -1
- data/fixtures/dmarc_monitoring/remove_favorite.yml +1 -1
- data/fixtures/dmarc_monitoring/report.yml +1 -1
- data/fixtures/dmarc_monitoring/report_by_ip.yml +1 -1
- data/fixtures/dmarc_monitoring/report_sources.yml +1 -1
- data/fixtures/dmarc_monitoring/update.yml +1 -1
- data/fixtures/domains/domains_add.yml +1 -1
- data/fixtures/domains/domains_delete.yml +1 -1
- data/fixtures/domains/domains_dns.yml +1 -1
- data/fixtures/domains/domains_list.yml +1 -1
- data/fixtures/domains/domains_recipients.yml +1 -1
- data/fixtures/domains/domains_settings.yml +1 -1
- data/fixtures/domains/domains_single.yml +1 -1
- data/fixtures/domains/domains_verify.yml +1 -1
- data/fixtures/email/email_send.yml +1 -1
- data/fixtures/email/email_send_template_language.yml +1 -1
- data/fixtures/emails/emails_list_emails.yml +1 -1
- data/fixtures/emails/emails_list_emails_empty_page.yml +1 -1
- data/fixtures/emails/emails_single_email.yml +1 -1
- data/fixtures/inbound_routing/inbound_routing_delete.yml +1 -1
- data/fixtures/inbound_routing/inbound_routing_list.yml +1 -1
- data/fixtures/inbound_routing/inbound_routing_single.yml +1 -1
- data/fixtures/messages/messages_list_messages.yml +1 -1
- data/fixtures/messages/messages_single_message.yml +1 -1
- data/fixtures/recipients/recipients_delete.yml +1 -1
- data/fixtures/recipients/recipients_list.yml +1 -1
- data/fixtures/recipients/recipients_single.yml +1 -1
- data/fixtures/scheduled_messages/scheduled_messages_delete.yml +1 -1
- data/fixtures/scheduled_messages/scheduled_messages_get_list.yml +1 -1
- data/fixtures/scheduled_messages/scheduled_messages_get_single.yml +1 -1
- data/fixtures/sms_activity/sms_activity_list.yml +1 -1
- data/fixtures/sms_inbounds/sms_inbounds_add_sms_inbound_route.yml +1 -1
- data/fixtures/sms_inbounds/sms_inbounds_delete_sms_inbound_route.yml +1 -1
- data/fixtures/sms_inbounds/sms_inbounds_get_sms_inbound_route.yml +1 -1
- data/fixtures/sms_inbounds/sms_inbounds_list_sms_inbounds.yml +1 -1
- data/fixtures/sms_inbounds/sms_inbounds_update_sms_inbound_route.yml +1 -1
- data/fixtures/sms_messages/sms_messages_list_sms_messages.yml +1 -1
- data/fixtures/sms_number/sms_number_delete.yml +2 -2
- data/fixtures/sms_number/sms_number_get.yml +1 -1
- data/fixtures/sms_number/sms_number_list.yml +1 -1
- data/fixtures/sms_number/sms_number_update.yml +1 -1
- data/fixtures/sms_recipient/sms_recipient_get.yml +1 -1
- data/fixtures/sms_recipient/sms_recipient_list.yml +1 -1
- data/fixtures/sms_recipient/sms_recipient_update.yml +1 -1
- data/fixtures/sms_webhooks/sms_webhooks_add_sms_webhook_route.yml +1 -1
- data/fixtures/sms_webhooks/sms_webhooks_delete_sms_webhook_route.yml +1 -1
- data/fixtures/sms_webhooks/sms_webhooks_get_sms_webhook_route.yml +1 -1
- data/fixtures/sms_webhooks/sms_webhooks_list_sms_webhooks.yml +1 -1
- data/fixtures/sms_webhooks/sms_webhooks_update_sms_webhook_route.yml +1 -1
- data/fixtures/suppressions/suppressions_add_to_blocklist.yml +1 -1
- data/fixtures/suppressions/suppressions_add_to_hard_bounces.yml +1 -1
- data/fixtures/suppressions/suppressions_add_to_spam_complaints.yml +1 -1
- data/fixtures/suppressions/suppressions_add_to_unsubscribers.yml +1 -1
- data/fixtures/suppressions/suppressions_delete_from_blocklist.yml +1 -1
- data/fixtures/suppressions/suppressions_delete_from_hard_bounces.yml +1 -1
- data/fixtures/suppressions/suppressions_delete_from_spam_complaints.yml +1 -1
- data/fixtures/suppressions/suppressions_delete_from_unsubscribers.yml +1 -1
- data/fixtures/suppressions/suppressions_get_from_blocklist.yml +1 -1
- data/fixtures/suppressions/suppressions_get_hard_bounces.yml +1 -1
- data/fixtures/suppressions/suppressions_get_spam_complaints.yml +1 -1
- data/fixtures/suppressions/suppressions_get_unsubscribes.yml +1 -1
- data/fixtures/templates/templates_delete.yml +1 -1
- data/fixtures/templates/templates_list.yml +1 -1
- data/fixtures/templates/templates_single.yml +1 -1
- data/fixtures/tokens/tokens_create.yml +1 -1
- data/fixtures/tokens/tokens_delete.yml +1 -1
- data/fixtures/tokens/tokens_update.yml +1 -1
- data/fixtures/webhooks/webhooks_create.yml +1 -1
- data/fixtures/webhooks/webhooks_delete.yml +1 -1
- data/fixtures/webhooks/webhooks_list.yml +1 -1
- data/fixtures/webhooks/webhooks_single.yml +1 -1
- data/fixtures/whatsapp/whatsapp_send.yml +1 -1
- data/fixtures/whatsapp/whatsapp_send_multiple_recipients.yml +1 -1
- data/fixtures/whatsapp/whatsapp_send_personalization.yml +1 -1
- data/fixtures/whatsapp_activities/whatsapp_activities_list.yml +1 -1
- data/fixtures/whatsapp_inbound_messages/whatsapp_inbound_messages_get.yml +1 -1
- data/fixtures/whatsapp_inbound_messages/whatsapp_inbound_messages_list.yml +1 -1
- data/fixtures/whatsapp_items/whatsapp_items_get.yml +1 -1
- data/fixtures/whatsapp_items/whatsapp_items_list.yml +1 -1
- data/fixtures/whatsapp_messages/whatsapp_messages_get.yml +1 -1
- data/fixtures/whatsapp_messages/whatsapp_messages_list.yml +1 -1
- data/fixtures/whatsapp_recipient/whatsapp_recipient_get.yml +1 -1
- data/fixtures/whatsapp_recipient/whatsapp_recipient_list.yml +1 -1
- data/fixtures/whatsapp_templates/whatsapp_templates_get.yml +1 -1
- data/fixtures/whatsapp_templates/whatsapp_templates_list.yml +1 -1
- data/lib/mailersend/account/account.rb +16 -0
- data/lib/mailersend/activity/activity.rb +1 -1
- data/lib/mailersend/analytics/analytics.rb +4 -4
- data/lib/mailersend/api_quota/api_quota.rb +1 -1
- data/lib/mailersend/bulk_email/bulk_email.rb +2 -2
- data/lib/mailersend/client.rb +16 -1
- data/lib/mailersend/dmarc_monitoring/dmarc_monitoring.rb +9 -9
- data/lib/mailersend/domains/domains.rb +8 -8
- data/lib/mailersend/email/email.rb +1 -1
- data/lib/mailersend/email_verification/email_verification.rb +6 -6
- data/lib/mailersend/emails/emails.rb +2 -2
- data/lib/mailersend/inbound_routing/inbound_routing.rb +5 -5
- data/lib/mailersend/messages/messages.rb +2 -2
- data/lib/mailersend/recipients/recipients.rb +3 -3
- data/lib/mailersend/scheduled_messages/scheduled_messages.rb +3 -3
- data/lib/mailersend/sender_identity/sender_identity.rb +8 -8
- data/lib/mailersend/sms/sms.rb +1 -1
- data/lib/mailersend/sms_activity/sms_activity.rb +1 -1
- data/lib/mailersend/sms_inbounds/sms_inbounds.rb +5 -5
- data/lib/mailersend/sms_messages/sms_messages.rb +2 -2
- data/lib/mailersend/sms_number/sms_number.rb +4 -4
- data/lib/mailersend/sms_recipient/sms_recipient.rb +3 -3
- data/lib/mailersend/sms_webhooks/sms_webhooks.rb +5 -5
- data/lib/mailersend/suppressions/suppressions.rb +12 -12
- data/lib/mailersend/templates/templates.rb +3 -3
- data/lib/mailersend/tokens/tokens.rb +3 -3
- data/lib/mailersend/version.rb +1 -1
- data/lib/mailersend/webhooks/webhooks.rb +5 -5
- data/lib/mailersend/whatsapp/whatsapp.rb +1 -1
- data/lib/mailersend/whatsapp_activities/whatsapp_activities.rb +1 -1
- data/lib/mailersend/whatsapp_inbound_messages/whatsapp_inbound_messages.rb +2 -2
- data/lib/mailersend/whatsapp_items/whatsapp_items.rb +2 -2
- data/lib/mailersend/whatsapp_messages/whatsapp_messages.rb +2 -2
- data/lib/mailersend/whatsapp_recipient/whatsapp_recipient.rb +2 -2
- data/lib/mailersend/whatsapp_templates/whatsapp_templates.rb +2 -2
- data/lib/mailersend.rb +1 -0
- data/spec/account_rspec.rb +43 -0
- data/spec/client_rspec.rb +33 -0
- data/spec/emails_rspec.rb +7 -7
- metadata +6 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
http_interactions:
|
|
3
3
|
- request:
|
|
4
4
|
method: post
|
|
5
|
-
uri: https://api.mailersend.com/
|
|
5
|
+
uri: https://api.mailersend.com/2026-10/sms-webhooks
|
|
6
6
|
body:
|
|
7
7
|
encoding: UTF-8
|
|
8
8
|
string: '{"sms_number_id":"0p7kx4xd7el9yjre","name":"good-webhook","url":"https://mailersend.net/webhook","events":["sms.sent","sms.delivered"]}'
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
http_interactions:
|
|
3
3
|
- request:
|
|
4
4
|
method: put
|
|
5
|
-
uri: https://api.mailersend.com/
|
|
5
|
+
uri: https://api.mailersend.com/2026-10/sms-webhooks/0r83ql3pzvgzw1jm
|
|
6
6
|
body:
|
|
7
7
|
encoding: UTF-8
|
|
8
8
|
string: '{"url":"https://mailersend.net/updated_webhook","events":["sms.sent","sms.delivered"]}'
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
http_interactions:
|
|
3
3
|
- request:
|
|
4
4
|
method: post
|
|
5
|
-
uri: https://api.mailersend.com/
|
|
5
|
+
uri: https://api.mailersend.com/2026-10/suppressions/hard-bounces
|
|
6
6
|
body:
|
|
7
7
|
encoding: UTF-8
|
|
8
8
|
string: '{"domain_id":"jpzkmgq7e5vl059v","recipients":["test@mailerlite.com"]}'
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
http_interactions:
|
|
3
3
|
- request:
|
|
4
4
|
method: post
|
|
5
|
-
uri: https://api.mailersend.com/
|
|
5
|
+
uri: https://api.mailersend.com/2026-10/suppressions/spam-complaints
|
|
6
6
|
body:
|
|
7
7
|
encoding: UTF-8
|
|
8
8
|
string: '{"domain_id":"jpzkmgq7e5vl059v","recipients":["test@mailerlite.com"]}'
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
http_interactions:
|
|
3
3
|
- request:
|
|
4
4
|
method: post
|
|
5
|
-
uri: https://api.mailersend.com/
|
|
5
|
+
uri: https://api.mailersend.com/2026-10/suppressions/unsubscribes
|
|
6
6
|
body:
|
|
7
7
|
encoding: UTF-8
|
|
8
8
|
string: '{"domain_id":"jpzkmgq7e5vl059v","recipients":["test@mailerlite.com"]}'
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
http_interactions:
|
|
3
3
|
- request:
|
|
4
4
|
method: delete
|
|
5
|
-
uri: https://api.mailersend.com/
|
|
5
|
+
uri: https://api.mailersend.com/2026-10/suppressions/blocklist
|
|
6
6
|
body:
|
|
7
7
|
encoding: UTF-8
|
|
8
8
|
string: '{"domain_id":"jpzkmgq7e5vl059v","ids":["6764599b1cc3ea355ad717a0"]}'
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
http_interactions:
|
|
3
3
|
- request:
|
|
4
4
|
method: delete
|
|
5
|
-
uri: https://api.mailersend.com/
|
|
5
|
+
uri: https://api.mailersend.com/2026-10/suppressions/hard-bounces
|
|
6
6
|
body:
|
|
7
7
|
encoding: UTF-8
|
|
8
8
|
string: '{"domain_id":"jpzkmgq7e5vl059v","ids":["676457b042328d3c98db7600"]}'
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
http_interactions:
|
|
3
3
|
- request:
|
|
4
4
|
method: delete
|
|
5
|
-
uri: https://api.mailersend.com/
|
|
5
|
+
uri: https://api.mailersend.com/2026-10/suppressions/spam-complaints
|
|
6
6
|
body:
|
|
7
7
|
encoding: UTF-8
|
|
8
8
|
string: '{"domain_id":"jpzkmgq7e5vl059v","ids":["676457b1ee359d18093fcb99"]}'
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
http_interactions:
|
|
3
3
|
- request:
|
|
4
4
|
method: delete
|
|
5
|
-
uri: https://api.mailersend.com/
|
|
5
|
+
uri: https://api.mailersend.com/2026-10/suppressions/unsubscribes
|
|
6
6
|
body:
|
|
7
7
|
encoding: UTF-8
|
|
8
8
|
string: '{"domain_id":"jpzkmgq7e5vl059v","ids":["676457b1252f59f004ea2bac"]}'
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
http_interactions:
|
|
3
3
|
- request:
|
|
4
4
|
method: get
|
|
5
|
-
uri: https://api.mailersend.com/
|
|
5
|
+
uri: https://api.mailersend.com/2026-10/templates?domain_id=zkq340ezdqkgd796&limit=10&page=1
|
|
6
6
|
body:
|
|
7
7
|
encoding: ASCII-8BIT
|
|
8
8
|
string: ''
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
http_interactions:
|
|
3
3
|
- request:
|
|
4
4
|
method: delete
|
|
5
|
-
uri: https://api.mailersend.com/
|
|
5
|
+
uri: https://api.mailersend.com/2026-10/token/1dd8e323b92f9953069f9647ca5929a24674e2f972d85734b27de16cd06360256054a070b783c272
|
|
6
6
|
body:
|
|
7
7
|
encoding: ASCII-8BIT
|
|
8
8
|
string: ''
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
http_interactions:
|
|
3
3
|
- request:
|
|
4
4
|
method: put
|
|
5
|
-
uri: https://api.mailersend.com/
|
|
5
|
+
uri: https://api.mailersend.com/2026-10/token/1dd8e323b92f9953069f9647ca5929a24674e2f972d85734b27de16cd06360256054a070b783c272/settings
|
|
6
6
|
body:
|
|
7
7
|
encoding: UTF-8
|
|
8
8
|
string: '{"status":"pause"}'
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
http_interactions:
|
|
3
3
|
- request:
|
|
4
4
|
method: post
|
|
5
|
-
uri: https://api.mailersend.com/
|
|
5
|
+
uri: https://api.mailersend.com/2026-10/webhooks
|
|
6
6
|
body:
|
|
7
7
|
encoding: UTF-8
|
|
8
8
|
string: '{"url":"https://example.com/webhook","name":"Test Webhook","events":["activity.sent","activity.delivered"],"domain_id":"jpzkmgq7e5vl059v","enabled":true}'
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
http_interactions:
|
|
3
3
|
- request:
|
|
4
4
|
method: post
|
|
5
|
-
uri: https://api.mailersend.com/
|
|
5
|
+
uri: https://api.mailersend.com/2026-10/whatsapp/send
|
|
6
6
|
body:
|
|
7
7
|
encoding: UTF-8
|
|
8
8
|
string: '{"from":"15550001234","to":["+48600000001"],"template_id":"23zxk54v6gjy6v7m"}'
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
http_interactions:
|
|
3
3
|
- request:
|
|
4
4
|
method: post
|
|
5
|
-
uri: https://api.mailersend.com/
|
|
5
|
+
uri: https://api.mailersend.com/2026-10/whatsapp/send
|
|
6
6
|
body:
|
|
7
7
|
encoding: UTF-8
|
|
8
8
|
string: '{"from":"15550001234","to":["+48600000001","+48600000002"],"template_id":"23zxk54v6gjy6v7m"}'
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
http_interactions:
|
|
3
3
|
- request:
|
|
4
4
|
method: post
|
|
5
|
-
uri: https://api.mailersend.com/
|
|
5
|
+
uri: https://api.mailersend.com/2026-10/whatsapp/send
|
|
6
6
|
body:
|
|
7
7
|
encoding: UTF-8
|
|
8
8
|
string: '{"from":"15550001234","to":["+48600000001"],"template_id":"23zxk54v6gjy6v7m","personalization":[{"to":"+48600000001","data":{"header":["Order #12345"],"body":["John","December 31, 2026"],"buttons":["orders/12345"]}}]}'
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
http_interactions:
|
|
3
3
|
- request:
|
|
4
4
|
method: get
|
|
5
|
-
uri: https://api.mailersend.com/
|
|
5
|
+
uri: https://api.mailersend.com/2026-10/whatsapp/activities?date_from=1791936000&date_to=1792022400&limit=25&page=1&recipient=48600000001&type%5B%5D=delivered&type%5B%5D=read&whatsapp_item_id=67f91abe2202f3705540234a&whatsapp_message_id=67f91abd69f79df391e9d78d
|
|
6
6
|
body:
|
|
7
7
|
encoding: ASCII-8BIT
|
|
8
8
|
string: ''
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
http_interactions:
|
|
3
3
|
- request:
|
|
4
4
|
method: get
|
|
5
|
-
uri: https://api.mailersend.com/
|
|
5
|
+
uri: https://api.mailersend.com/2026-10/whatsapp/inbound-messages/62f114a3165fe0d8db0288d1
|
|
6
6
|
body:
|
|
7
7
|
encoding: ASCII-8BIT
|
|
8
8
|
string: ''
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
http_interactions:
|
|
3
3
|
- request:
|
|
4
4
|
method: get
|
|
5
|
-
uri: https://api.mailersend.com/
|
|
5
|
+
uri: https://api.mailersend.com/2026-10/whatsapp/inbound-messages?date_from=1790000000&date_to=1790086400&from=48600000001&limit=25&page=1&type%5B%5D=image&type%5B%5D=text&whatsapp_account_id=3enl6x27wmrxrl2v
|
|
6
6
|
body:
|
|
7
7
|
encoding: ASCII-8BIT
|
|
8
8
|
string: ''
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
http_interactions:
|
|
3
3
|
- request:
|
|
4
4
|
method: get
|
|
5
|
-
uri: https://api.mailersend.com/
|
|
5
|
+
uri: https://api.mailersend.com/2026-10/whatsapp/items?date_from=1791936000&date_to=1792022400&from=15550001234&limit=25&page=1&recipient=48600000002&status%5B%5D=failed&status%5B%5D=read&template_id=23zxk54v6gjy6v7m&whatsapp_account_id=3enl6x27wmrxrl2v&whatsapp_message_id=67f91abd69f79df391e9d78d
|
|
6
6
|
body:
|
|
7
7
|
encoding: ASCII-8BIT
|
|
8
8
|
string: ''
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
http_interactions:
|
|
3
3
|
- request:
|
|
4
4
|
method: get
|
|
5
|
-
uri: https://api.mailersend.com/
|
|
5
|
+
uri: https://api.mailersend.com/2026-10/whatsapp/messages?date_from=1791936000&date_to=1792022400&from=15550001234&limit=25&page=1&template_id=23zxk54v6gjy6v7m&whatsapp_account_id=3enl6x27wmrxrl2v
|
|
6
6
|
body:
|
|
7
7
|
encoding: ASCII-8BIT
|
|
8
8
|
string: ''
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
http_interactions:
|
|
3
3
|
- request:
|
|
4
4
|
method: get
|
|
5
|
-
uri: https://api.mailersend.com/
|
|
5
|
+
uri: https://api.mailersend.com/2026-10/whatsapp/recipients?limit=25&page=1&phone_number=48600000001&status=active
|
|
6
6
|
body:
|
|
7
7
|
encoding: ASCII-8BIT
|
|
8
8
|
string: ''
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
http_interactions:
|
|
3
3
|
- request:
|
|
4
4
|
method: get
|
|
5
|
-
uri: https://api.mailersend.com/
|
|
5
|
+
uri: https://api.mailersend.com/2026-10/whatsapp/templates?category=UTILITY&language=en_US&limit=25&page=1&status=approved&whatsapp_account_id=3enl6x27wmrxrl2v
|
|
6
6
|
body:
|
|
7
7
|
encoding: ASCII-8BIT
|
|
8
8
|
string: ''
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mailersend
|
|
4
|
+
# Account endpoint from MailerSend API
|
|
5
|
+
class Account
|
|
6
|
+
attr_accessor :client
|
|
7
|
+
|
|
8
|
+
def initialize(client = Mailersend::Client.new)
|
|
9
|
+
@client = client
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def get_account(*)
|
|
13
|
+
client.http.get("#{client.api_base_url}/account")
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -27,7 +27,7 @@ module Mailersend
|
|
|
27
27
|
date_to: date_to
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: "/
|
|
30
|
+
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: "#{client.api_path}/activity/#{domain_id}",
|
|
31
31
|
query: URI.encode_www_form(hash.compact)))
|
|
32
32
|
end
|
|
33
33
|
end
|
|
@@ -34,7 +34,7 @@ module Mailersend
|
|
|
34
34
|
'tags[]' => tags
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path:
|
|
37
|
+
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: "#{client.api_path}/analytics/date",
|
|
38
38
|
query: URI.encode_www_form(hash.compact)))
|
|
39
39
|
end
|
|
40
40
|
|
|
@@ -47,7 +47,7 @@ module Mailersend
|
|
|
47
47
|
'tags[]': tags
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path:
|
|
50
|
+
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: "#{client.api_path}/analytics/country",
|
|
51
51
|
query: URI.encode_www_form(hash.compact)))
|
|
52
52
|
end
|
|
53
53
|
|
|
@@ -60,7 +60,7 @@ module Mailersend
|
|
|
60
60
|
'tags[]': tags
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path:
|
|
63
|
+
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: "#{client.api_path}/analytics/ua-name",
|
|
64
64
|
query: URI.encode_www_form(hash.compact)))
|
|
65
65
|
end
|
|
66
66
|
|
|
@@ -73,7 +73,7 @@ module Mailersend
|
|
|
73
73
|
'tags[]': tags
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path:
|
|
76
|
+
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: "#{client.api_path}/analytics/ua-type",
|
|
77
77
|
query: URI.encode_www_form(hash.compact)))
|
|
78
78
|
end
|
|
79
79
|
end
|
|
@@ -24,11 +24,11 @@ module Mailersend
|
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def send
|
|
27
|
-
client.http.post("#{
|
|
27
|
+
client.http.post("#{client.api_base_url}/bulk-email", json: @messages)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
def get_bulk_status(bulk_email_id:)
|
|
31
|
-
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: "/
|
|
31
|
+
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: "#{client.api_path}/bulk-email/#{bulk_email_id}"))
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
end
|
data/lib/mailersend/client.rb
CHANGED
|
@@ -2,19 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
require 'http'
|
|
4
4
|
|
|
5
|
+
# Deprecated: always points at v1. Use Mailersend::Client#api_base_url.
|
|
5
6
|
MAILERSEND_API_URL = 'https://api.mailersend.com/v1'
|
|
6
7
|
MAILERSEND_API_BASE_HOST = 'api.mailersend.com'
|
|
7
8
|
|
|
8
9
|
# mailersend-ruby is a gem that integrates all endpoints from MailerSend API
|
|
9
10
|
module Mailersend
|
|
11
|
+
DEFAULT_API_VERSION = '2026-10'
|
|
12
|
+
|
|
10
13
|
attr_reader :api_token
|
|
11
14
|
|
|
12
15
|
# Inits the client.
|
|
13
16
|
class Client
|
|
14
|
-
|
|
17
|
+
attr_reader :api_version
|
|
18
|
+
|
|
19
|
+
def initialize(api_token = ENV.fetch('MAILERSEND_API_TOKEN', nil), api_version: DEFAULT_API_VERSION)
|
|
15
20
|
raise ArgumentError, 'API token is not provided' if api_token.nil?
|
|
21
|
+
raise ArgumentError, "Invalid API version #{api_version.inspect}: use 'v1' or a dated version like '2026-10'" unless api_version.to_s.match?(/\A(v1|\d{4}-(0[1-9]|1[0-2]))\z/)
|
|
16
22
|
|
|
17
23
|
@api_token = api_token
|
|
24
|
+
@api_version = api_version.to_s
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def api_path
|
|
28
|
+
"/#{@api_version}"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def api_base_url
|
|
32
|
+
"https://#{MAILERSEND_API_BASE_HOST}#{api_path}"
|
|
18
33
|
end
|
|
19
34
|
|
|
20
35
|
def http
|