mailersend-ruby 2.0.3 → 3.0.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.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/main.yml +6 -6
  3. data/.github/workflows/publish_gem.yml +4 -4
  4. data/.rspec +1 -0
  5. data/.rubocop.yml +1 -1
  6. data/CHANGELOG.md +4 -0
  7. data/Gemfile +7 -3
  8. data/README.md +10 -1
  9. data/fixtures/activity/activity_get_activity.yml +61 -0
  10. data/fixtures/api_quota/api_quota_get.yml +51 -0
  11. data/fixtures/bulk_email/bulk_email_send.yml +54 -0
  12. data/fixtures/bulk_email/bulk_email_status.yml +53 -0
  13. data/fixtures/domains/domains_add.yml +55 -0
  14. data/fixtures/domains/domains_delete.yml +47 -0
  15. data/fixtures/domains/domains_dns.yml +52 -0
  16. data/fixtures/domains/domains_list.yml +63 -0
  17. data/fixtures/domains/domains_recipients.yml +51 -0
  18. data/fixtures/domains/domains_settings.yml +55 -0
  19. data/fixtures/domains/domains_single.yml +53 -0
  20. data/fixtures/domains/domains_verify.yml +51 -0
  21. data/fixtures/email/email_send.yml +56 -0
  22. data/fixtures/inbound_routing/inbound_routing_delete.yml +47 -0
  23. data/fixtures/inbound_routing/inbound_routing_list.yml +53 -0
  24. data/fixtures/inbound_routing/inbound_routing_single.yml +51 -0
  25. data/fixtures/messages/messages_list_messages.yml +51 -0
  26. data/fixtures/messages/messages_single_message.yml +54 -0
  27. data/fixtures/recipients/recipients_delete.yml +47 -0
  28. data/fixtures/recipients/recipients_list.yml +51 -0
  29. data/fixtures/recipients/recipients_single.yml +51 -0
  30. data/fixtures/scheduled_messages/scheduled_messages_delete.yml +34 -0
  31. data/fixtures/scheduled_messages/scheduled_messages_get_list.yml +53 -0
  32. data/fixtures/scheduled_messages/scheduled_messages_get_single.yml +34 -0
  33. data/fixtures/sms_activity/sms_activity_list.yml +51 -0
  34. data/fixtures/sms_inbounds/sms_inbounds_add_sms_inbound_route.yml +53 -0
  35. data/fixtures/sms_inbounds/sms_inbounds_delete_sms_inbound_route.yml +47 -0
  36. data/fixtures/sms_inbounds/sms_inbounds_get_sms_inbound_route.yml +51 -0
  37. data/fixtures/sms_inbounds/sms_inbounds_list_sms_inbounds.yml +53 -0
  38. data/fixtures/sms_inbounds/sms_inbounds_update_sms_inbound_route.yml +53 -0
  39. data/fixtures/sms_messages/sms_messages_list_sms_messages.yml +56 -0
  40. data/fixtures/sms_number/sms_number_delete.yml +26 -0
  41. data/fixtures/sms_number/sms_number_get.yml +51 -0
  42. data/fixtures/sms_number/sms_number_list.yml +53 -0
  43. data/fixtures/sms_number/sms_number_update.yml +53 -0
  44. data/fixtures/sms_recipient/sms_recipient_get.yml +51 -0
  45. data/fixtures/sms_recipient/sms_recipient_list.yml +51 -0
  46. data/fixtures/sms_recipient/sms_recipient_update.yml +53 -0
  47. data/fixtures/sms_webhooks/sms_webhooks_add_sms_webhook_route.yml +53 -0
  48. data/fixtures/sms_webhooks/sms_webhooks_delete_sms_webhook_route.yml +47 -0
  49. data/fixtures/sms_webhooks/sms_webhooks_get_sms_webhook_route.yml +51 -0
  50. data/fixtures/sms_webhooks/sms_webhooks_list_sms_webhooks.yml +53 -0
  51. data/fixtures/sms_webhooks/sms_webhooks_update_sms_webhook_route.yml +53 -0
  52. data/fixtures/suppressions/suppressions_add_to_blocklist.yml +53 -0
  53. data/fixtures/suppressions/suppressions_add_to_hard_bounces.yml +53 -0
  54. data/fixtures/suppressions/suppressions_add_to_spam_complaints.yml +53 -0
  55. data/fixtures/suppressions/suppressions_add_to_unsubscribers.yml +53 -0
  56. data/fixtures/suppressions/suppressions_delete_from_blocklist.yml +53 -0
  57. data/fixtures/suppressions/suppressions_delete_from_hard_bounces.yml +53 -0
  58. data/fixtures/suppressions/suppressions_delete_from_spam_complaints.yml +53 -0
  59. data/fixtures/suppressions/suppressions_delete_from_unsubscribers.yml +53 -0
  60. data/fixtures/suppressions/suppressions_get_from_blocklist.yml +51 -0
  61. data/fixtures/suppressions/suppressions_get_hard_bounces.yml +51 -0
  62. data/fixtures/suppressions/suppressions_get_spam_complaints.yml +51 -0
  63. data/fixtures/suppressions/suppressions_get_unsubscribes.yml +51 -0
  64. data/fixtures/templates/templates_delete.yml +51 -0
  65. data/fixtures/templates/templates_list.yml +51 -0
  66. data/fixtures/templates/templates_single.yml +51 -0
  67. data/fixtures/tokens/tokens_create.yml +54 -0
  68. data/fixtures/tokens/tokens_delete.yml +51 -0
  69. data/fixtures/tokens/tokens_update.yml +54 -0
  70. data/fixtures/webhooks/webhooks_create.yml +56 -0
  71. data/fixtures/webhooks/webhooks_delete.yml +47 -0
  72. data/fixtures/webhooks/webhooks_list.yml +55 -0
  73. data/fixtures/webhooks/webhooks_single.yml +53 -0
  74. data/lib/mailersend/scheduled_messages/scheduled_messages.rb +1 -1
  75. data/lib/mailersend/version.rb +1 -1
  76. data/mailersend-ruby.gemspec +4 -4
  77. data/spec/activity_rspec.rb +26 -0
  78. data/spec/api_quota_rspec.rb +29 -0
  79. data/spec/bulk_email_rspec.rb +44 -0
  80. data/spec/domains_rspec.rb +94 -0
  81. data/spec/email_rspec.rb +29 -0
  82. data/spec/inbound_routing_rspec.rb +44 -0
  83. data/spec/messages_rspec.rb +36 -0
  84. data/spec/recipients_rspec.rb +44 -0
  85. data/spec/scheduled_messages_rspec.rb +44 -0
  86. data/spec/sms_activity_rspec.rb +26 -0
  87. data/spec/sms_inbounds_rspec.rb +77 -0
  88. data/spec/sms_messages_rspec.rb +26 -0
  89. data/spec/sms_number_rspec.rb +54 -0
  90. data/spec/sms_recipient_rspec.rb +46 -0
  91. data/spec/sms_webhooks_rspec.rb +74 -0
  92. data/spec/spec_helper.rb +102 -0
  93. data/spec/suppressions_rspec.rb +124 -0
  94. data/spec/templates_rspec.rb +44 -0
  95. data/spec/tokens_rspec.rb +44 -0
  96. data/spec/webhooks_rspec.rb +60 -0
  97. metadata +96 -10
@@ -0,0 +1,56 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.mailersend.com/v1/webhooks
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"url":"https://example.com/webhook","name":"Test Webhook","events":["activity.sent","activity.delivered"],"domain_id":"jpzkmgq7e5vl059v","enabled":true}'
9
+ headers:
10
+ Authorization:
11
+ - "<AUTH>"
12
+ User-Agent:
13
+ - MailerSend-client-ruby/3.0.0
14
+ Accept:
15
+ - application/json
16
+ Connection:
17
+ - close
18
+ Content-Type:
19
+ - application/json; charset=utf-8
20
+ Host:
21
+ - api.mailersend.com
22
+ response:
23
+ status:
24
+ code: 201
25
+ message: Created
26
+ headers:
27
+ Date:
28
+ - Tue, 17 Dec 2024 23:06:45 GMT
29
+ Content-Type:
30
+ - application/json
31
+ Transfer-Encoding:
32
+ - chunked
33
+ Connection:
34
+ - close
35
+ Cache-Control:
36
+ - no-cache, private
37
+ X-Apiquota-Remaining:
38
+ - "-1"
39
+ X-Apiquota-Reset:
40
+ - '2024-12-18T00:00:00Z'
41
+ Strict-Transport-Security:
42
+ - max-age=31536000; includeSubDomains
43
+ Cf-Cache-Status:
44
+ - DYNAMIC
45
+ Server:
46
+ - cloudflare
47
+ Cf-Ray:
48
+ - 8f3a90c41bf6c1bc-BUD
49
+ body:
50
+ encoding: UTF-8
51
+ string: '{"data":{"id":"3yxj6lj6214do2rm","url":"https:\/\/example.com\/webhook","events":["activity.sent","activity.delivered"],"name":"Test
52
+ Webhook","enabled":true,"editable":null,"secret":"xjVdC89BpXpVmNMScBCKcHpeKIg6itb0","created_at":"2024-12-17T23:06:45.000000Z","updated_at":"2024-12-17T23:06:45.000000Z","domain":{"id":"jpzkmgq7e5vl059v","name":"test-sdk.com","dkim":false,"spf":false,"tracking":false,"is_verified":true,"is_cname_verified":false,"is_dns_active":false,"is_cname_active":false,"is_tracking_allowed":false,"has_not_queued_messages":false,"not_queued_messages_count":0,"domain_settings":{"send_paused":false,"track_clicks":true,"track_opens":true,"track_unsubscribe":false,"track_unsubscribe_html":"<p>Click
53
+ here to <a href=\"{{unsubscribe}}\">unsubscribe<\/a><\/p>","track_unsubscribe_html_enabled":false,"track_unsubscribe_plain":"Click
54
+ here to unsubscribe: {{unsubscribe}}","track_unsubscribe_plain_enabled":false,"track_content":true,"custom_tracking_enabled":true,"custom_tracking_subdomain":"email","return_path_subdomain":"mta","inbound_routing_enabled":false,"inbound_routing_subdomain":"","precedence_bulk":false,"ignore_duplicated_recipients":false},"created_at":"2022-04-20T11:36:15.000000Z","updated_at":"2024-09-02T10:02:27.000000Z","totals":{"sent":0,"delivered":119,"hard_bounced":0,"soft_bounced":5}}}}'
55
+ recorded_at: Tue, 17 Dec 2024 23:06:45 GMT
56
+ recorded_with: VCR 6.1.0
@@ -0,0 +1,47 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: delete
5
+ uri: https://api.mailersend.com/v1/webhooks/3vz9dlej514kj50y
6
+ body:
7
+ encoding: ASCII-8BIT
8
+ string: ''
9
+ headers:
10
+ Authorization:
11
+ - "<AUTH>"
12
+ User-Agent:
13
+ - MailerSend-client-ruby/3.0.0
14
+ Accept:
15
+ - application/json
16
+ Connection:
17
+ - close
18
+ Host:
19
+ - api.mailersend.com
20
+ response:
21
+ status:
22
+ code: 204
23
+ message: No Content
24
+ headers:
25
+ Date:
26
+ - Tue, 17 Dec 2024 23:09:24 GMT
27
+ Connection:
28
+ - close
29
+ Cache-Control:
30
+ - no-cache, private
31
+ X-Apiquota-Remaining:
32
+ - "-1"
33
+ X-Apiquota-Reset:
34
+ - '2024-12-18T00:00:00Z'
35
+ Strict-Transport-Security:
36
+ - max-age=31536000; includeSubDomains
37
+ Cf-Cache-Status:
38
+ - DYNAMIC
39
+ Server:
40
+ - cloudflare
41
+ Cf-Ray:
42
+ - 8f3a94a418736c85-ZAG
43
+ body:
44
+ encoding: ASCII-8BIT
45
+ string: ''
46
+ recorded_at: Tue, 17 Dec 2024 23:09:24 GMT
47
+ recorded_with: VCR 6.1.0
@@ -0,0 +1,55 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.mailersend.com/v1/webhooks?domain_id=jpzkmgq7e5vl059v
6
+ body:
7
+ encoding: ASCII-8BIT
8
+ string: ''
9
+ headers:
10
+ Authorization:
11
+ - "<AUTH>"
12
+ User-Agent:
13
+ - MailerSend-client-ruby/3.0.0
14
+ Accept:
15
+ - application/json
16
+ Connection:
17
+ - close
18
+ Host:
19
+ - api.mailersend.com
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Date:
26
+ - Tue, 17 Dec 2024 22:55:19 GMT
27
+ Content-Type:
28
+ - application/json
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - close
33
+ Cache-Control:
34
+ - no-cache, private
35
+ X-Apiquota-Remaining:
36
+ - "-1"
37
+ X-Apiquota-Reset:
38
+ - '2024-12-18T00:00:00Z'
39
+ Strict-Transport-Security:
40
+ - max-age=31536000; includeSubDomains
41
+ Cf-Cache-Status:
42
+ - DYNAMIC
43
+ Server:
44
+ - cloudflare
45
+ Cf-Ray:
46
+ - 8f3a7ffedae2ec1a-ZAG
47
+ body:
48
+ encoding: UTF-8
49
+ string: '{"data":[{"id":"3vz9dlej514kj50y","url":"https:\/\/test23.com","events":["activity.sent"],"name":"webhook","enabled":true,"editable":true,"secret":"nCbLSmKF9CrSZx2zqPqsH8p72zU2QAh7","created_at":"2024-12-17T22:54:21.000000Z","updated_at":"2024-12-17T22:54:21.000000Z","domain":{"id":"jpzkmgq7e5vl059v","name":"test-sdk.com","dkim":false,"spf":false,"tracking":false,"is_verified":true,"is_cname_verified":false,"is_dns_active":false,"is_cname_active":false,"is_tracking_allowed":false,"has_not_queued_messages":false,"not_queued_messages_count":0,"domain_settings":{"send_paused":false,"track_clicks":true,"track_opens":true,"track_unsubscribe":false,"track_unsubscribe_html":"<p>Click
50
+ here to <a href=\"{{unsubscribe}}\">unsubscribe<\/a><\/p>","track_unsubscribe_html_enabled":false,"track_unsubscribe_plain":"Click
51
+ here to unsubscribe: {{unsubscribe}}","track_unsubscribe_plain_enabled":false,"track_content":true,"custom_tracking_enabled":true,"custom_tracking_subdomain":"email","return_path_subdomain":"mta","inbound_routing_enabled":false,"inbound_routing_subdomain":"","precedence_bulk":false,"ignore_duplicated_recipients":false},"created_at":"2022-04-20T11:36:15.000000Z","updated_at":"2024-09-02T10:02:27.000000Z","totals":{"sent":0,"delivered":119,"hard_bounced":0,"soft_bounced":5}}}],"links":{"first":"https:\/\/api.mailersend.com\/v1\/webhooks?page=1","last":"https:\/\/api.mailersend.com\/v1\/webhooks?page=1","prev":null,"next":null},"meta":{"current_page":1,"from":1,"last_page":1,"links":[{"url":null,"label":"&laquo;
52
+ Previous","active":false},{"url":"https:\/\/api.mailersend.com\/v1\/webhooks?page=1","label":"1","active":true},{"url":null,"label":"Next
53
+ &raquo;","active":false}],"path":"https:\/\/api.mailersend.com\/v1\/webhooks","per_page":25,"to":1,"total":1}}'
54
+ recorded_at: Tue, 17 Dec 2024 22:55:19 GMT
55
+ recorded_with: VCR 6.1.0
@@ -0,0 +1,53 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.mailersend.com/v1/webhooks/3vz9dlej514kj50y
6
+ body:
7
+ encoding: ASCII-8BIT
8
+ string: ''
9
+ headers:
10
+ Authorization:
11
+ - "<AUTH>"
12
+ User-Agent:
13
+ - MailerSend-client-ruby/3.0.0
14
+ Accept:
15
+ - application/json
16
+ Connection:
17
+ - close
18
+ Host:
19
+ - api.mailersend.com
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Date:
26
+ - Tue, 17 Dec 2024 22:56:16 GMT
27
+ Content-Type:
28
+ - application/json
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - close
33
+ Cache-Control:
34
+ - no-cache, private
35
+ X-Apiquota-Remaining:
36
+ - "-1"
37
+ X-Apiquota-Reset:
38
+ - '2024-12-18T00:00:00Z'
39
+ Strict-Transport-Security:
40
+ - max-age=31536000; includeSubDomains
41
+ Cf-Cache-Status:
42
+ - DYNAMIC
43
+ Server:
44
+ - cloudflare
45
+ Cf-Ray:
46
+ - 8f3a81642f8dec1a-ZAG
47
+ body:
48
+ encoding: UTF-8
49
+ string: '{"data":{"id":"3vz9dlej514kj50y","url":"https:\/\/test23.com","events":["activity.sent"],"name":"webhook","enabled":true,"editable":true,"secret":"nCbLSmKF9CrSZx2zqPqsH8p72zU2QAh7","created_at":"2024-12-17T22:54:21.000000Z","updated_at":"2024-12-17T22:54:21.000000Z","domain":{"id":"jpzkmgq7e5vl059v","name":"test-sdk.com","dkim":false,"spf":false,"tracking":false,"is_verified":true,"is_cname_verified":false,"is_dns_active":false,"is_cname_active":false,"is_tracking_allowed":false,"has_not_queued_messages":false,"not_queued_messages_count":0,"domain_settings":{"send_paused":false,"track_clicks":true,"track_opens":true,"track_unsubscribe":false,"track_unsubscribe_html":"<p>Click
50
+ here to <a href=\"{{unsubscribe}}\">unsubscribe<\/a><\/p>","track_unsubscribe_html_enabled":false,"track_unsubscribe_plain":"Click
51
+ here to unsubscribe: {{unsubscribe}}","track_unsubscribe_plain_enabled":false,"track_content":true,"custom_tracking_enabled":true,"custom_tracking_subdomain":"email","return_path_subdomain":"mta","inbound_routing_enabled":false,"inbound_routing_subdomain":"","precedence_bulk":false,"ignore_duplicated_recipients":false},"created_at":"2022-04-20T11:36:15.000000Z","updated_at":"2024-09-02T10:02:27.000000Z","totals":{"sent":0,"delivered":119,"hard_bounced":0,"soft_bounced":5}}}}'
52
+ recorded_at: Tue, 17 Dec 2024 22:56:17 GMT
53
+ recorded_with: VCR 6.1.0
@@ -23,7 +23,7 @@ module Mailersend
23
23
  client.http.get("#{MAILERSEND_API_URL}/message-schedules")
24
24
  end
25
25
 
26
- def get_signle(message_id:)
26
+ def get_single(message_id:)
27
27
  client.http.get("#{MAILERSEND_API_URL}/message-schedules/#{message_id}")
28
28
  end
29
29
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mailersend
4
- VERSION = '2.0.3'
4
+ VERSION = '3.0.0'
5
5
  end
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.description = "MailerSend's official Ruby SDK. Interacts with all endpoints at MailerSend API."
15
15
  spec.homepage = 'https://www.mailersend.com'
16
16
  spec.license = 'MIT'
17
- spec.required_ruby_version = '>= 2.5.0'
17
+ spec.required_ruby_version = '>= 3.1'
18
18
 
19
19
  spec.metadata['allowed_push_host'] = 'https://rubygems.org'
20
20
 
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ['lib']
29
29
 
30
- spec.add_dependency 'http', '~> 5.0'
31
- spec.add_dependency 'json', '~> 2.5'
32
- spec.add_dependency 'uri', '~> 0.13.0'
30
+ spec.add_dependency 'http', '~> 5.2'
31
+ spec.add_dependency 'json', '~> 2.9'
32
+ spec.add_dependency 'uri', '~> 1.0'
33
33
  end
@@ -0,0 +1,26 @@
1
+ require 'rspec'
2
+ require 'vcr'
3
+ require 'json'
4
+
5
+ VCR.configure do |config|
6
+ config.cassette_library_dir = './fixtures'
7
+ config.hook_into :webmock
8
+ config.filter_sensitive_data('<AUTH>') do |interaction|
9
+ interaction.request.headers['Authorization'][0]
10
+ end
11
+ end
12
+
13
+ RSpec.describe Mailersend::Activity do
14
+ let(:client) { Mailersend::Client.new(API_TOKEN) }
15
+ let(:activity) { Mailersend::Activity.new(client) }
16
+
17
+ it 'returns activity data' do
18
+ VCR.use_cassette('activity/activity_get_activity') do
19
+ response = activity.get(domain_id: 'jpzkmgq7e5vl059v', page: 1, limit: 10, date_from: '1734115200', date_to: '1734633600')
20
+ parsed_response = JSON.parse(response.body)
21
+
22
+ expect(response.status).to eq(200)
23
+ expect(parsed_response['data']).to be_an(Array)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,29 @@
1
+ require 'rspec'
2
+ require 'vcr'
3
+ require 'json'
4
+
5
+ VCR.configure do |config|
6
+ config.cassette_library_dir = './fixtures'
7
+ config.hook_into :webmock
8
+ config.filter_sensitive_data('<AUTH>') do |interaction|
9
+ interaction.request.headers['Authorization'][0]
10
+ end
11
+ end
12
+
13
+ RSpec.describe Mailersend::APIQuota do
14
+ let(:client) { Mailersend::Client.new(API_TOKEN) }
15
+ let(:api_quota) { Mailersend::APIQuota.new(client) }
16
+
17
+ it 'returns the API quota' do
18
+ VCR.use_cassette('api_quota/api_quota_get') do
19
+ response = api_quota.get_api_quota
20
+ parsed_response = JSON.parse(response.body)
21
+
22
+ expect(response.status).to eq(200)
23
+ expect(parsed_response).to be_a(Hash)
24
+ expect(parsed_response).to have_key('quota')
25
+ expect(parsed_response).to have_key('remaining')
26
+ expect(parsed_response).to have_key('reset')
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,44 @@
1
+ require 'rspec'
2
+ require 'vcr'
3
+ require 'json'
4
+
5
+ VCR.configure do |config|
6
+ config.cassette_library_dir = './fixtures'
7
+ config.hook_into :webmock
8
+ config.filter_sensitive_data('<AUTH>') do |interaction|
9
+ interaction.request.headers['Authorization'][0]
10
+ end
11
+ end
12
+
13
+ RSpec.describe Mailersend::BulkEmail do
14
+ let(:client) { Mailersend::Client.new(API_TOKEN) }
15
+ let(:bulk_email) { Mailersend::BulkEmail.new(client) }
16
+
17
+ it 'sends bulk email' do
18
+ VCR.use_cassette('bulk_email/bulk_email_send') do
19
+ bulk_email.instance_variable_set(:@messages, [
20
+ {
21
+ 'from' => 'sender@test-sdk.com',
22
+ 'to' => ['test@mailerlite.com'],
23
+ 'subject' => 'Test Bulk Email',
24
+ 'text' => 'This is a test bulk email.'
25
+ }
26
+ ])
27
+ response = bulk_email.send
28
+ parsed_response = JSON.parse(response.body)
29
+
30
+ expect(response.status).to eq(202)
31
+ expect(parsed_response).to be_a(Hash)
32
+ end
33
+ end
34
+
35
+ it 'gets bulk email status' do
36
+ VCR.use_cassette('bulk_email/bulk_email_status') do
37
+ response = bulk_email.get_bulk_status(bulk_email_id: '67618140bf85c862710f2c5a')
38
+ parsed_response = JSON.parse(response.body)
39
+
40
+ expect(response.status).to eq(200)
41
+ expect(parsed_response).to be_a(Hash)
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,94 @@
1
+ require 'rspec'
2
+ require 'vcr'
3
+ require 'json'
4
+
5
+ VCR.configure do |config|
6
+ config.cassette_library_dir = './fixtures'
7
+ config.hook_into :webmock
8
+ config.filter_sensitive_data('<AUTH>') do |interaction|
9
+ interaction.request.headers['Authorization'][0]
10
+ end
11
+ end
12
+
13
+ RSpec.describe Mailersend::Domains do
14
+ let(:client) { Mailersend::Client.new(API_TOKEN) }
15
+ let(:domains) { Mailersend::Domains.new(client) }
16
+
17
+ it 'returns a list of domains' do
18
+ VCR.use_cassette('domains/domains_list') do
19
+ response = domains.list
20
+ parsed_response = JSON.parse(response.body)
21
+
22
+ expect(response.status).to eq(200)
23
+ expect(parsed_response['data']).to be_an(Array)
24
+ end
25
+ end
26
+
27
+ it 'returns a single domain' do
28
+ VCR.use_cassette('domains/domains_single') do
29
+ response = domains.single(domain_id: 'z3m5jgrdk7z4dpyo')
30
+ parsed_response = JSON.parse(response.body)
31
+
32
+ expect(response.status).to eq(200)
33
+ expect(parsed_response['data']).to be_a(Hash)
34
+ end
35
+ end
36
+
37
+ it 'adds a new domain' do
38
+ VCR.use_cassette('domains/domains_add') do
39
+ response = domains.add(name: 'ourdomain.com')
40
+ parsed_response = JSON.parse(response.body)
41
+
42
+ expect(response.status).to eq(201)
43
+ expect(parsed_response['data']).to be_a(Hash)
44
+ end
45
+ end
46
+
47
+ it 'deletes a domain' do
48
+ VCR.use_cassette('domains/domains_delete') do
49
+ response = domains.delete(domain_id: 'zkq340ezdqkgd796')
50
+
51
+ expect(response.status).to eq(204)
52
+ end
53
+ end
54
+
55
+ it 'returns recipients for a domain' do
56
+ VCR.use_cassette('domains/domains_recipients') do
57
+ response = domains.recipients(domain_id: '3yxj6lj1r05ldo2r')
58
+ parsed_response = JSON.parse(response.body)
59
+
60
+ expect(response.status).to eq(200)
61
+ expect(parsed_response['data']).to be_an(Array)
62
+ end
63
+ end
64
+
65
+ it 'updates domain settings' do
66
+ VCR.use_cassette('domains/domains_settings') do
67
+ response = domains.settings(domain_id: '3yxj6lj1r05ldo2r', send_paused: true)
68
+ parsed_response = JSON.parse(response.body)
69
+
70
+ expect(response.status).to eq(200)
71
+ expect(parsed_response['data']).to be_a(Hash)
72
+ end
73
+ end
74
+
75
+ it 'returns DNS records for a domain' do
76
+ VCR.use_cassette('domains/domains_dns') do
77
+ response = domains.dns(domain_id: 'jpzkmgq7e5vl059v')
78
+ parsed_response = JSON.parse(response.body)
79
+
80
+ expect(response.status).to eq(200)
81
+ expect(parsed_response['data']).to be_an(Hash)
82
+ end
83
+ end
84
+
85
+ it 'verifies a domain' do
86
+ VCR.use_cassette('domains/domains_verify') do
87
+ response = domains.verify(domain_id: 'jpzkmgq7e5vl059v')
88
+ parsed_response = JSON.parse(response.body)
89
+
90
+ expect(response.status).to eq(200)
91
+ expect(parsed_response['data']).to be_a(Hash)
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,29 @@
1
+ require 'rspec'
2
+ require 'vcr'
3
+ require 'json'
4
+
5
+ VCR.configure do |config|
6
+ config.cassette_library_dir = './fixtures'
7
+ config.hook_into :webmock
8
+ config.filter_sensitive_data('<AUTH>') do |interaction|
9
+ interaction.request.headers['Authorization'][0]
10
+ end
11
+ end
12
+
13
+ RSpec.describe Mailersend::Email do
14
+ let(:client) { Mailersend::Client.new(API_TOKEN) }
15
+ let(:email) { Mailersend::Email.new(client) }
16
+
17
+ it 'sends an email' do
18
+ VCR.use_cassette('email/email_send') do
19
+ email.from = { 'email' => 'sender@test-sdk.com', 'name' => 'Sender' }
20
+ email.recipients = [{ 'email' => 'test@mailerlite.com', 'name' => 'Test' }]
21
+ email.subject = 'Test Email'
22
+ email.text = 'This is a test email.'
23
+ email.html = '<p>This is a test email.</p>'
24
+
25
+ response = email.send
26
+ expect(response.status).to eq(202)
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,44 @@
1
+ require 'rspec'
2
+ require 'vcr'
3
+ require 'json'
4
+
5
+ VCR.configure do |config|
6
+ config.cassette_library_dir = './fixtures'
7
+ config.hook_into :webmock
8
+ config.filter_sensitive_data('<AUTH>') do |interaction|
9
+ interaction.request.headers['Authorization'][0]
10
+ end
11
+ end
12
+
13
+ RSpec.describe Mailersend::InboundRouting do
14
+ let(:client) { Mailersend::Client.new(API_TOKEN) }
15
+ let(:inbound_routing) { Mailersend::InboundRouting.new(client) }
16
+
17
+ it 'returns a list of inbound routes' do
18
+ VCR.use_cassette('inbound_routing/inbound_routing_list') do
19
+ response = inbound_routing.get_inbound_routes
20
+ parsed_response = JSON.parse(response.body)
21
+
22
+ expect(response.status).to eq(200)
23
+ expect(parsed_response['data']).to be_an(Array)
24
+ end
25
+ end
26
+
27
+ it 'returns a single inbound route' do
28
+ VCR.use_cassette('inbound_routing/inbound_routing_single') do
29
+ response = inbound_routing.get_single_route(inbound_id: 'pr9084zw584w63dn')
30
+ parsed_response = JSON.parse(response.body)
31
+
32
+ expect(response.status).to eq(200)
33
+ expect(parsed_response['data']).to be_a(Hash)
34
+ end
35
+ end
36
+
37
+ it 'deletes an inbound route' do
38
+ VCR.use_cassette('inbound_routing/inbound_routing_delete') do
39
+ response = inbound_routing.delete_route(inbound_id: '7dnvo4dkd6l5r86y')
40
+
41
+ expect(response.status).to eq(204)
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,36 @@
1
+ require 'rspec'
2
+ require 'vcr'
3
+ require 'json'
4
+
5
+ VCR.configure do |config|
6
+ config.cassette_library_dir = './fixtures'
7
+ config.hook_into :webmock
8
+ config.filter_sensitive_data('<AUTH>') do |interaction|
9
+ interaction.request.headers['Authorization'][0]
10
+ end
11
+ end
12
+
13
+ RSpec.describe Mailersend::Messages do
14
+ let(:client) { Mailersend::Client.new(API_TOKEN) }
15
+ let(:messages) { Mailersend::Messages.new(client) }
16
+
17
+ it 'returns a list of messages' do
18
+ VCR.use_cassette('messages/messages_list_messages') do
19
+ response = messages.list(page: 1, limit: 10)
20
+ parsed_response = JSON.parse(response.body)
21
+
22
+ expect(response.status).to eq(200)
23
+ expect(parsed_response['data']).to be_an(Array)
24
+ end
25
+ end
26
+
27
+ it 'returns a single message' do
28
+ VCR.use_cassette('messages/messages_single_message') do
29
+ response = messages.single(message_id: '676184e34aed90153c5efa6f')
30
+ parsed_response = JSON.parse(response.body)
31
+
32
+ expect(response.status).to eq(200)
33
+ expect(parsed_response['data']).to be_a(Hash)
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,44 @@
1
+ require 'rspec'
2
+ require 'vcr'
3
+ require 'json'
4
+
5
+ VCR.configure do |config|
6
+ config.cassette_library_dir = './fixtures'
7
+ config.hook_into :webmock
8
+ config.filter_sensitive_data('<AUTH>') do |interaction|
9
+ interaction.request.headers['Authorization'][0]
10
+ end
11
+ end
12
+
13
+ RSpec.describe Mailersend::Recipients do
14
+ let(:client) { Mailersend::Client.new(API_TOKEN) }
15
+ let(:recipients) { Mailersend::Recipients.new(client) }
16
+
17
+ it 'returns a list of recipients' do
18
+ VCR.use_cassette('recipients/recipients_list') do
19
+ response = recipients.list(page: 1, limit: 10)
20
+ parsed_response = JSON.parse(response.body)
21
+
22
+ expect(response.status).to eq(200)
23
+ expect(parsed_response['data']).to be_an(Array)
24
+ end
25
+ end
26
+
27
+ it 'returns a single recipient' do
28
+ VCR.use_cassette('recipients/recipients_single') do
29
+ response = recipients.single(recipient_id: '663cd8f984e4628b80b976a3')
30
+ parsed_response = JSON.parse(response.body)
31
+
32
+ expect(response.status).to eq(200)
33
+ expect(parsed_response['data']).to be_a(Hash)
34
+ end
35
+ end
36
+
37
+ it 'deletes a recipient' do
38
+ VCR.use_cassette('recipients/recipients_delete') do
39
+ response = recipients.delete(recipient_id: '663cd8f984e4628b80b976a3')
40
+
41
+ expect(response.status).to eq(204)
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,44 @@
1
+ require 'rspec'
2
+ require 'vcr'
3
+ require 'json'
4
+
5
+ VCR.configure do |config|
6
+ config.cassette_library_dir = './fixtures'
7
+ config.hook_into :webmock
8
+ config.filter_sensitive_data('<AUTH>') do |interaction|
9
+ interaction.request.headers['Authorization'][0]
10
+ end
11
+ end
12
+
13
+ RSpec.describe Mailersend::ScheduledMessages do
14
+ let(:client) { Mailersend::Client.new(API_TOKEN) }
15
+ let(:scheduled_messages) { Mailersend::ScheduledMessages.new(client) }
16
+
17
+ it 'returns a list of scheduled messages' do
18
+ VCR.use_cassette('scheduled_messages/scheduled_messages_get_list') do
19
+ response = scheduled_messages.get_list
20
+ parsed_response = JSON.parse(response.body)
21
+
22
+ expect(response.status).to eq(200)
23
+ expect(parsed_response['data']).to be_an(Array)
24
+ end
25
+ end
26
+
27
+ it 'returns a single scheduled message' do
28
+ VCR.use_cassette('scheduled_messages/scheduled_messages_get_single') do
29
+ response = scheduled_messages.get_single(message_id: '6764a963c5b6195e097987ca')
30
+ parsed_response = JSON.parse(response.body)
31
+
32
+ expect(response.status).to eq(200)
33
+ expect(parsed_response['data']).to be_a(Hash)
34
+ end
35
+ end
36
+
37
+ it 'deletes a scheduled message' do
38
+ VCR.use_cassette('scheduled_messages/scheduled_messages_delete') do
39
+ response = scheduled_messages.delete(message_id: '6764a963c5b6195e097987ca')
40
+
41
+ expect(response.status).to eq(204)
42
+ end
43
+ end
44
+ end