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.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +6 -6
- data/.github/workflows/publish_gem.yml +4 -4
- data/.rspec +1 -0
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +4 -0
- data/Gemfile +7 -3
- data/README.md +10 -1
- data/fixtures/activity/activity_get_activity.yml +61 -0
- data/fixtures/api_quota/api_quota_get.yml +51 -0
- data/fixtures/bulk_email/bulk_email_send.yml +54 -0
- data/fixtures/bulk_email/bulk_email_status.yml +53 -0
- data/fixtures/domains/domains_add.yml +55 -0
- data/fixtures/domains/domains_delete.yml +47 -0
- data/fixtures/domains/domains_dns.yml +52 -0
- data/fixtures/domains/domains_list.yml +63 -0
- data/fixtures/domains/domains_recipients.yml +51 -0
- data/fixtures/domains/domains_settings.yml +55 -0
- data/fixtures/domains/domains_single.yml +53 -0
- data/fixtures/domains/domains_verify.yml +51 -0
- data/fixtures/email/email_send.yml +56 -0
- data/fixtures/inbound_routing/inbound_routing_delete.yml +47 -0
- data/fixtures/inbound_routing/inbound_routing_list.yml +53 -0
- data/fixtures/inbound_routing/inbound_routing_single.yml +51 -0
- data/fixtures/messages/messages_list_messages.yml +51 -0
- data/fixtures/messages/messages_single_message.yml +54 -0
- data/fixtures/recipients/recipients_delete.yml +47 -0
- data/fixtures/recipients/recipients_list.yml +51 -0
- data/fixtures/recipients/recipients_single.yml +51 -0
- data/fixtures/scheduled_messages/scheduled_messages_delete.yml +34 -0
- data/fixtures/scheduled_messages/scheduled_messages_get_list.yml +53 -0
- data/fixtures/scheduled_messages/scheduled_messages_get_single.yml +34 -0
- data/fixtures/sms_activity/sms_activity_list.yml +51 -0
- data/fixtures/sms_inbounds/sms_inbounds_add_sms_inbound_route.yml +53 -0
- data/fixtures/sms_inbounds/sms_inbounds_delete_sms_inbound_route.yml +47 -0
- data/fixtures/sms_inbounds/sms_inbounds_get_sms_inbound_route.yml +51 -0
- data/fixtures/sms_inbounds/sms_inbounds_list_sms_inbounds.yml +53 -0
- data/fixtures/sms_inbounds/sms_inbounds_update_sms_inbound_route.yml +53 -0
- data/fixtures/sms_messages/sms_messages_list_sms_messages.yml +56 -0
- data/fixtures/sms_number/sms_number_delete.yml +26 -0
- data/fixtures/sms_number/sms_number_get.yml +51 -0
- data/fixtures/sms_number/sms_number_list.yml +53 -0
- data/fixtures/sms_number/sms_number_update.yml +53 -0
- data/fixtures/sms_recipient/sms_recipient_get.yml +51 -0
- data/fixtures/sms_recipient/sms_recipient_list.yml +51 -0
- data/fixtures/sms_recipient/sms_recipient_update.yml +53 -0
- data/fixtures/sms_webhooks/sms_webhooks_add_sms_webhook_route.yml +53 -0
- data/fixtures/sms_webhooks/sms_webhooks_delete_sms_webhook_route.yml +47 -0
- data/fixtures/sms_webhooks/sms_webhooks_get_sms_webhook_route.yml +51 -0
- data/fixtures/sms_webhooks/sms_webhooks_list_sms_webhooks.yml +53 -0
- data/fixtures/sms_webhooks/sms_webhooks_update_sms_webhook_route.yml +53 -0
- data/fixtures/suppressions/suppressions_add_to_blocklist.yml +53 -0
- data/fixtures/suppressions/suppressions_add_to_hard_bounces.yml +53 -0
- data/fixtures/suppressions/suppressions_add_to_spam_complaints.yml +53 -0
- data/fixtures/suppressions/suppressions_add_to_unsubscribers.yml +53 -0
- data/fixtures/suppressions/suppressions_delete_from_blocklist.yml +53 -0
- data/fixtures/suppressions/suppressions_delete_from_hard_bounces.yml +53 -0
- data/fixtures/suppressions/suppressions_delete_from_spam_complaints.yml +53 -0
- data/fixtures/suppressions/suppressions_delete_from_unsubscribers.yml +53 -0
- data/fixtures/suppressions/suppressions_get_from_blocklist.yml +51 -0
- data/fixtures/suppressions/suppressions_get_hard_bounces.yml +51 -0
- data/fixtures/suppressions/suppressions_get_spam_complaints.yml +51 -0
- data/fixtures/suppressions/suppressions_get_unsubscribes.yml +51 -0
- data/fixtures/templates/templates_delete.yml +51 -0
- data/fixtures/templates/templates_list.yml +51 -0
- data/fixtures/templates/templates_single.yml +51 -0
- data/fixtures/tokens/tokens_create.yml +54 -0
- data/fixtures/tokens/tokens_delete.yml +51 -0
- data/fixtures/tokens/tokens_update.yml +54 -0
- data/fixtures/webhooks/webhooks_create.yml +56 -0
- data/fixtures/webhooks/webhooks_delete.yml +47 -0
- data/fixtures/webhooks/webhooks_list.yml +55 -0
- data/fixtures/webhooks/webhooks_single.yml +53 -0
- data/lib/mailersend/scheduled_messages/scheduled_messages.rb +1 -1
- data/lib/mailersend/version.rb +1 -1
- data/mailersend-ruby.gemspec +4 -4
- data/spec/activity_rspec.rb +26 -0
- data/spec/api_quota_rspec.rb +29 -0
- data/spec/bulk_email_rspec.rb +44 -0
- data/spec/domains_rspec.rb +94 -0
- data/spec/email_rspec.rb +29 -0
- data/spec/inbound_routing_rspec.rb +44 -0
- data/spec/messages_rspec.rb +36 -0
- data/spec/recipients_rspec.rb +44 -0
- data/spec/scheduled_messages_rspec.rb +44 -0
- data/spec/sms_activity_rspec.rb +26 -0
- data/spec/sms_inbounds_rspec.rb +77 -0
- data/spec/sms_messages_rspec.rb +26 -0
- data/spec/sms_number_rspec.rb +54 -0
- data/spec/sms_recipient_rspec.rb +46 -0
- data/spec/sms_webhooks_rspec.rb +74 -0
- data/spec/spec_helper.rb +102 -0
- data/spec/suppressions_rspec.rb +124 -0
- data/spec/templates_rspec.rb +44 -0
- data/spec/tokens_rspec.rb +44 -0
- data/spec/webhooks_rspec.rb +60 -0
- metadata +96 -10
@@ -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::SMSActivity do
|
14
|
+
let(:client) { Mailersend::Client.new(API_TOKEN) }
|
15
|
+
let(:sms_activity) { Mailersend::SMSActivity.new(client) }
|
16
|
+
|
17
|
+
it 'returns a list of SMS activities' do
|
18
|
+
VCR.use_cassette('sms_activity/sms_activity_list') do
|
19
|
+
response = sms_activity.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
|
+
end
|
@@ -0,0 +1,77 @@
|
|
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::SMSInbounds do
|
14
|
+
let(:client) { Mailersend::Client.new(API_TOKEN) }
|
15
|
+
let(:sms_inbounds) { Mailersend::SMSInbounds.new(client) }
|
16
|
+
|
17
|
+
it 'returns a list of SMS inbounds' do
|
18
|
+
VCR.use_cassette('sms_inbounds/sms_inbounds_list_sms_inbounds') do
|
19
|
+
response = sms_inbounds.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 SMS inbound route' do
|
28
|
+
VCR.use_cassette('sms_inbounds/sms_inbounds_get_sms_inbound_route') do
|
29
|
+
response = sms_inbounds.get_sms_inbound_route(sms_inbound_id: '6vywj2lpml7oqzd1')
|
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 SMS inbound route' do
|
38
|
+
VCR.use_cassette('sms_inbounds/sms_inbounds_add_sms_inbound_route') do
|
39
|
+
sms_inbounds.settings = {
|
40
|
+
'sms_number_id' => '0p7kx4xd7el9yjre',
|
41
|
+
'forward_url' => 'https://mailersend.com',
|
42
|
+
'name' => 'my-inbound-route',
|
43
|
+
'events' => ['sms.sent', 'sms.delivered']
|
44
|
+
}
|
45
|
+
response = sms_inbounds.add_sms_inbound_route
|
46
|
+
parsed_response = JSON.parse(response.body)
|
47
|
+
|
48
|
+
expect(response.status).to eq(201)
|
49
|
+
expect(parsed_response['data']).to be_a(Hash)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'updates an SMS inbound route' do
|
54
|
+
VCR.use_cassette('sms_inbounds/sms_inbounds_update_sms_inbound_route') do
|
55
|
+
sms_inbounds.settings = {
|
56
|
+
'sms_number_id' => '0p7kx4xd7el9yjre',
|
57
|
+
'forward_url' => 'https://mailersend.com',
|
58
|
+
'name' => 'my-inbound-route',
|
59
|
+
'events' => ['sms.sent', 'sms.delivered']
|
60
|
+
|
61
|
+
}
|
62
|
+
response = sms_inbounds.update_sms_inbound_route(sms_inbound_id: '0p7kx4xw0eg9yjre')
|
63
|
+
parsed_response = JSON.parse(response.body)
|
64
|
+
|
65
|
+
expect(response.status).to eq(200)
|
66
|
+
expect(parsed_response['data']).to be_a(Hash)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'deletes an SMS inbound route' do
|
71
|
+
VCR.use_cassette('sms_inbounds/sms_inbounds_delete_sms_inbound_route') do
|
72
|
+
response = sms_inbounds.delete_sms_inbound_route(sms_inbound_id: '0p7kx4xw0eg9yjre')
|
73
|
+
|
74
|
+
expect(response.status).to eq(204)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
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::SMSMessages do
|
14
|
+
let(:client) { Mailersend::Client.new(API_TOKEN) }
|
15
|
+
let(:sms_messages) { Mailersend::SMSMessages.new(client) }
|
16
|
+
|
17
|
+
it 'returns a list of SMS messages' do
|
18
|
+
VCR.use_cassette('sms_messages/sms_messages_list_sms_messages') do
|
19
|
+
response = sms_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
|
+
end
|
@@ -0,0 +1,54 @@
|
|
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::SMSNumber do
|
14
|
+
let(:client) { Mailersend::Client.new(API_TOKEN) }
|
15
|
+
let(:sms_number) { Mailersend::SMSNumber.new(client) }
|
16
|
+
|
17
|
+
it 'returns a list of SMS numbers' do
|
18
|
+
VCR.use_cassette('sms_number/sms_number_list') do
|
19
|
+
response = sms_number.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 SMS number' do
|
28
|
+
VCR.use_cassette('sms_number/sms_number_get') do
|
29
|
+
response = sms_number.get(sms_number_id: '0p7kx4xd7el9yjre')
|
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 'updates an SMS number' do
|
38
|
+
VCR.use_cassette('sms_number/sms_number_update') do
|
39
|
+
response = sms_number.update(sms_number_id: '0p7kx4xd7el9yjre', paused: true)
|
40
|
+
parsed_response = JSON.parse(response.body)
|
41
|
+
|
42
|
+
expect(response.status).to eq(200)
|
43
|
+
expect(parsed_response['data']).to be_a(Hash)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'deletes an SMS number' do
|
48
|
+
VCR.use_cassette('sms_number/sms_number_delete') do
|
49
|
+
response = sms_number.delete(sms_number_id: 'example_sms_number_id')
|
50
|
+
|
51
|
+
expect(response.status).to eq(204)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,46 @@
|
|
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::SMSRecipient do
|
14
|
+
let(:client) { Mailersend::Client.new(API_TOKEN) }
|
15
|
+
let(:sms_recipient) { Mailersend::SMSRecipient.new(client) }
|
16
|
+
|
17
|
+
it 'returns a list of SMS recipients' do
|
18
|
+
VCR.use_cassette('sms_recipient/sms_recipient_list') do
|
19
|
+
response = sms_recipient.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 SMS recipient' do
|
28
|
+
VCR.use_cassette('sms_recipient/sms_recipient_get') do
|
29
|
+
response = sms_recipient.get(sms_recipient_id: '627e7503d30078fb2208cc83')
|
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 'updates an SMS recipient' do
|
38
|
+
VCR.use_cassette('sms_recipient/sms_recipient_update') do
|
39
|
+
response = sms_recipient.update(sms_recipient_id: '627e7503d30078fb2208cc83', status: 'active')
|
40
|
+
parsed_response = JSON.parse(response.body)
|
41
|
+
|
42
|
+
expect(response.status).to eq(200)
|
43
|
+
expect(parsed_response['data']).to be_a(Hash)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,74 @@
|
|
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::SMSWebhooks do
|
14
|
+
let(:client) { Mailersend::Client.new(API_TOKEN) }
|
15
|
+
let(:sms_webhooks) { Mailersend::SMSWebhooks.new(client) }
|
16
|
+
|
17
|
+
it 'returns a list of SMS webhooks' do
|
18
|
+
VCR.use_cassette('sms_webhooks/sms_webhooks_list_sms_webhooks') do
|
19
|
+
response = sms_webhooks.list(sms_number_id: '0p7kx4xd7el9yjre')
|
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 SMS webhook route' do
|
28
|
+
VCR.use_cassette('sms_webhooks/sms_webhooks_get_sms_webhook_route') do
|
29
|
+
response = sms_webhooks.get_sms_webhook_route(sms_webhook_id: '0r83ql3pzvgzw1jm')
|
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 SMS webhook route' do
|
38
|
+
VCR.use_cassette('sms_webhooks/sms_webhooks_add_sms_webhook_route') do
|
39
|
+
sms_webhooks.settings = {
|
40
|
+
'sms_number_id' => '0p7kx4xd7el9yjre',
|
41
|
+
'name' => 'good-webhook',
|
42
|
+
'url' => 'https://mailersend.net/webhook',
|
43
|
+
'events' => ['sms.sent', 'sms.delivered']
|
44
|
+
}
|
45
|
+
response = sms_webhooks.add_sms_webhook_route
|
46
|
+
parsed_response = JSON.parse(response.body)
|
47
|
+
|
48
|
+
expect(response.status).to eq(201)
|
49
|
+
expect(parsed_response['data']).to be_a(Hash)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'updates an SMS webhook route' do
|
54
|
+
VCR.use_cassette('sms_webhooks/sms_webhooks_update_sms_webhook_route') do
|
55
|
+
sms_webhooks.settings = {
|
56
|
+
'url' => 'https://mailersend.net/updated_webhook',
|
57
|
+
'events' => ['sms.sent', 'sms.delivered']
|
58
|
+
}
|
59
|
+
response = sms_webhooks.update_sms_webhook_route(sms_webhook_id: '0r83ql3pzvgzw1jm')
|
60
|
+
parsed_response = JSON.parse(response.body)
|
61
|
+
|
62
|
+
expect(response.status).to eq(200)
|
63
|
+
expect(parsed_response['data']).to be_a(Hash)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'deletes an SMS webhook route' do
|
68
|
+
VCR.use_cassette('sms_webhooks/sms_webhooks_delete_sms_webhook_route') do
|
69
|
+
response = sms_webhooks.delete_sms_webhook_route(sms_webhook_id: '0r83ql3pzvgzw1jm')
|
70
|
+
|
71
|
+
expect(response.status).to eq(204)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start
|
3
|
+
require 'mailersend'
|
4
|
+
|
5
|
+
API_TOKEN = 'enter_your_api_token_here'
|
6
|
+
|
7
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
8
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
9
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
10
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
11
|
+
# files.
|
12
|
+
#
|
13
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
14
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
15
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
16
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
17
|
+
# a separate helper file that requires the additional dependencies and performs
|
18
|
+
# the additional setup, and require it from the spec files that actually need
|
19
|
+
# it.
|
20
|
+
#
|
21
|
+
# See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
22
|
+
RSpec.configure do |config|
|
23
|
+
# rspec-expectations config goes here. You can use an alternate
|
24
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
25
|
+
# assertions if you prefer.
|
26
|
+
config.expect_with :rspec do |expectations|
|
27
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
28
|
+
# and `failure_message` of custom matchers include text for helper methods
|
29
|
+
# defined using `chain`, e.g.:
|
30
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
31
|
+
# # => "be bigger than 2 and smaller than 4"
|
32
|
+
# ...rather than:
|
33
|
+
# # => "be bigger than 2"
|
34
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
35
|
+
end
|
36
|
+
|
37
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
38
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
39
|
+
config.mock_with :rspec do |mocks|
|
40
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
41
|
+
# a real object. This is generally recommended, and will default to
|
42
|
+
# `true` in RSpec 4.
|
43
|
+
mocks.verify_partial_doubles = true
|
44
|
+
end
|
45
|
+
|
46
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
47
|
+
# have no way to turn it off -- the option exists only for backwards
|
48
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
49
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
50
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
51
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
52
|
+
|
53
|
+
# The settings below are suggested to provide a good initial experience
|
54
|
+
# with RSpec, but feel free to customize to your heart's content.
|
55
|
+
# # This allows you to limit a spec run to individual examples or groups
|
56
|
+
# # you care about by tagging them with `:focus` metadata. When nothing
|
57
|
+
# # is tagged with `:focus`, all examples get run. RSpec also provides
|
58
|
+
# # aliases for `it`, `describe`, and `context` that include `:focus`
|
59
|
+
# # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
60
|
+
# config.filter_run_when_matching :focus
|
61
|
+
#
|
62
|
+
# # Allows RSpec to persist some state between runs in order to support
|
63
|
+
# # the `--only-failures` and `--next-failure` CLI options. We recommend
|
64
|
+
# # you configure your source control system to ignore this file.
|
65
|
+
# config.example_status_persistence_file_path = "spec/examples.txt"
|
66
|
+
#
|
67
|
+
# # Limits the available syntax to the non-monkey patched syntax that is
|
68
|
+
# # recommended. For more details, see:
|
69
|
+
# # https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/
|
70
|
+
# config.disable_monkey_patching!
|
71
|
+
#
|
72
|
+
# # This setting enables warnings. It's recommended, but in some cases may
|
73
|
+
# # be too noisy due to issues in dependencies.
|
74
|
+
# config.warnings = true
|
75
|
+
#
|
76
|
+
# # Many RSpec users commonly either run the entire suite or an individual
|
77
|
+
# # file, and it's useful to allow more verbose output when running an
|
78
|
+
# # individual spec file.
|
79
|
+
# if config.files_to_run.one?
|
80
|
+
# # Use the documentation formatter for detailed output,
|
81
|
+
# # unless a formatter has already been configured
|
82
|
+
# # (e.g. via a command-line flag).
|
83
|
+
# config.default_formatter = "doc"
|
84
|
+
# end
|
85
|
+
#
|
86
|
+
# # Print the 10 slowest examples and example groups at the
|
87
|
+
# # end of the spec run, to help surface which specs are running
|
88
|
+
# # particularly slow.
|
89
|
+
# config.profile_examples = 10
|
90
|
+
#
|
91
|
+
# # Run specs in random order to surface order dependencies. If you find an
|
92
|
+
# # order dependency and want to debug it, you can fix the order by providing
|
93
|
+
# # the seed, which is printed after each run.
|
94
|
+
# # --seed 1234
|
95
|
+
# config.order = :random
|
96
|
+
#
|
97
|
+
# # Seed global randomization in this process using the `--seed` CLI option.
|
98
|
+
# # Setting this allows you to use `--seed` to deterministically reproduce
|
99
|
+
# # test failures related to randomization by passing the same `--seed` value
|
100
|
+
# # as the one that triggered the failure.
|
101
|
+
# Kernel.srand config.seed
|
102
|
+
end
|
@@ -0,0 +1,124 @@
|
|
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::Suppressions do
|
14
|
+
let(:client) { Mailersend::Client.new(API_TOKEN) }
|
15
|
+
let(:suppressions) { Mailersend::Suppressions.new(client) }
|
16
|
+
|
17
|
+
it 'returns the blocklist' do
|
18
|
+
VCR.use_cassette('suppressions/suppressions_get_from_blocklist') do
|
19
|
+
response = suppressions.get_from_blocklist
|
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 hard bounces' do
|
28
|
+
VCR.use_cassette('suppressions/suppressions_get_hard_bounces') do
|
29
|
+
response = suppressions.get_hard_bounces
|
30
|
+
parsed_response = JSON.parse(response.body)
|
31
|
+
|
32
|
+
expect(response.status).to eq(200)
|
33
|
+
expect(parsed_response['data']).to be_an(Array)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'returns spam complaints' do
|
38
|
+
VCR.use_cassette('suppressions/suppressions_get_spam_complaints') do
|
39
|
+
response = suppressions.get_spam_complaints
|
40
|
+
parsed_response = JSON.parse(response.body)
|
41
|
+
|
42
|
+
expect(response.status).to eq(200)
|
43
|
+
expect(parsed_response['data']).to be_an(Array)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'returns unsubscribes' do
|
48
|
+
VCR.use_cassette('suppressions/suppressions_get_unsubscribes') do
|
49
|
+
response = suppressions.get_unsubscribes
|
50
|
+
parsed_response = JSON.parse(response.body)
|
51
|
+
|
52
|
+
expect(response.status).to eq(200)
|
53
|
+
expect(parsed_response['data']).to be_an(Array)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'adds to blocklist' do
|
58
|
+
VCR.use_cassette('suppressions/suppressions_add_to_blocklist') do
|
59
|
+
response = suppressions.add_to_blocklist(recipients: ['test@mailerlite.com'])
|
60
|
+
parsed_response = JSON.parse(response.body)
|
61
|
+
|
62
|
+
expect(response.status).to eq(201)
|
63
|
+
expect(parsed_response['data']).to be_an(Array)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'adds to hard bounces' do
|
68
|
+
VCR.use_cassette('suppressions/suppressions_add_to_hard_bounces') do
|
69
|
+
response = suppressions.add_to_hard_bounces(domain_id: 'jpzkmgq7e5vl059v', recipients: ['test@mailerlite.com'])
|
70
|
+
parsed_response = JSON.parse(response.body)
|
71
|
+
|
72
|
+
expect(response.status).to eq(201)
|
73
|
+
expect(parsed_response['data']).to be_an(Array)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'adds to spam complaints' do
|
78
|
+
VCR.use_cassette('suppressions/suppressions_add_to_spam_complaints') do
|
79
|
+
response = suppressions.add_to_spam_complaints(domain_id: 'jpzkmgq7e5vl059v', recipients: ['test@mailerlite.com'])
|
80
|
+
parsed_response = JSON.parse(response.body)
|
81
|
+
|
82
|
+
expect(response.status).to eq(201)
|
83
|
+
expect(parsed_response['data']).to be_an(Array)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'adds to unsubscribers' do
|
88
|
+
VCR.use_cassette('suppressions/suppressions_add_to_unsubscribers') do
|
89
|
+
response = suppressions.add_to_unsubscribers(domain_id: 'jpzkmgq7e5vl059v', recipients: ['test@mailerlite.com'])
|
90
|
+
parsed_response = JSON.parse(response.body)
|
91
|
+
|
92
|
+
expect(response.status).to eq(201)
|
93
|
+
expect(parsed_response['data']).to be_an(Array)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'deletes from blocklist' do
|
98
|
+
VCR.use_cassette('suppressions/suppressions_delete_from_blocklist') do
|
99
|
+
response = suppressions.delete_from_blocklist(domain_id: 'jpzkmgq7e5vl059v', ids: ['6764599b1cc3ea355ad717a0'])
|
100
|
+
expect(response.status).to eq(200)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'deletes from hard bounces' do
|
105
|
+
VCR.use_cassette('suppressions/suppressions_delete_from_hard_bounces') do
|
106
|
+
response = suppressions.delete_from_hard_bounces(domain_id: 'jpzkmgq7e5vl059v', ids: ['676457b042328d3c98db7600'])
|
107
|
+
expect(response.status).to eq(200)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'deletes from spam complaints' do
|
112
|
+
VCR.use_cassette('suppressions/suppressions_delete_from_spam_complaints') do
|
113
|
+
response = suppressions.delete_from_spam_complaints(domain_id: 'jpzkmgq7e5vl059v', ids: ['676457b1ee359d18093fcb99'])
|
114
|
+
expect(response.status).to eq(200)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'deletes from unsubscribers' do
|
119
|
+
VCR.use_cassette('suppressions/suppressions_delete_from_unsubscribers') do
|
120
|
+
response = suppressions.delete_from_unsubscribers(domain_id: 'jpzkmgq7e5vl059v', ids: ['676457b1252f59f004ea2bac'])
|
121
|
+
expect(response.status).to eq(200)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
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::Templates do
|
14
|
+
let(:client) { Mailersend::Client.new(API_TOKEN) }
|
15
|
+
let(:templates) { Mailersend::Templates.new(client) }
|
16
|
+
|
17
|
+
it 'returns a list of templates' do
|
18
|
+
VCR.use_cassette('templates/templates_list') do
|
19
|
+
response = templates.list(domain_id: 'zkq340ezdqkgd796', 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 template' do
|
28
|
+
VCR.use_cassette('templates/templates_single') do
|
29
|
+
response = templates.single(template_id: 'pq3enl6v607g2vwr')
|
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 template' do
|
38
|
+
VCR.use_cassette('templates/templates_delete') do
|
39
|
+
response = templates.delete(template_id: 'z3m5jgrow5zgdpyo')
|
40
|
+
|
41
|
+
expect(response.status).to eq(200)
|
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::Tokens do
|
14
|
+
let(:client) { Mailersend::Client.new(API_TOKEN) }
|
15
|
+
let(:tokens) { Mailersend::Tokens.new(client) }
|
16
|
+
|
17
|
+
it 'creates a new token' do
|
18
|
+
VCR.use_cassette('tokens/tokens_create') do
|
19
|
+
response = tokens.create(name: 'Test Token', scopes: ['email_full'], domain_id: 'example_domain_id')
|
20
|
+
parsed_response = JSON.parse(response.body)
|
21
|
+
|
22
|
+
expect(response.status).to eq(200)
|
23
|
+
expect(parsed_response['data']).to be_an(Hash)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'updates a token status' do
|
28
|
+
VCR.use_cassette('tokens/tokens_update') do
|
29
|
+
response = tokens.update(token_id: '1dd8e323b92f9953069f9647ca5929a24674e2f972d85734b27de16cd06360256054a070b783c272', status: 'pause')
|
30
|
+
parsed_response = JSON.parse(response.body)
|
31
|
+
|
32
|
+
expect(response.status).to eq(200)
|
33
|
+
expect(parsed_response).to be_a(Hash)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'deletes a token' do
|
38
|
+
VCR.use_cassette('tokens/tokens_delete') do
|
39
|
+
response = tokens.delete(token_id: '1dd8e323b92f9953069f9647ca5929a24674e2f972d85734b27de16cd06360256054a070b783c272')
|
40
|
+
|
41
|
+
expect(response.status).to eq(200)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,60 @@
|
|
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::Webhooks do
|
14
|
+
let(:client) { Mailersend::Client.new(API_TOKEN) }
|
15
|
+
let(:webhooks) { Mailersend::Webhooks.new(client) }
|
16
|
+
|
17
|
+
it 'returns a list of webhooks' do
|
18
|
+
VCR.use_cassette('webhooks/webhooks_list') do
|
19
|
+
response = webhooks.list(domain_id: 'jpzkmgq7e5vl059v')
|
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 webhook' do
|
28
|
+
VCR.use_cassette('webhooks/webhooks_single') do
|
29
|
+
response = webhooks.single(webhook_id: '3vz9dlej514kj50y')
|
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 'creates a new webhook' do
|
38
|
+
VCR.use_cassette('webhooks/webhooks_create') do
|
39
|
+
response = webhooks.create(
|
40
|
+
url: 'https://example.com/webhook',
|
41
|
+
name: 'Test Webhook',
|
42
|
+
events: ['activity.sent', 'activity.delivered'],
|
43
|
+
domain_id: 'jpzkmgq7e5vl059v',
|
44
|
+
enabled: true
|
45
|
+
)
|
46
|
+
parsed_response = JSON.parse(response.body)
|
47
|
+
|
48
|
+
expect(response.status).to eq(201)
|
49
|
+
expect(parsed_response['data']).to be_a(Hash)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'deletes a webhook' do
|
54
|
+
VCR.use_cassette('webhooks/webhooks_delete') do
|
55
|
+
response = webhooks.delete(webhook_id: '3vz9dlej514kj50y')
|
56
|
+
|
57
|
+
expect(response.status).to eq(204)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|