mailersend-ruby 0.2.4 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env.example +1 -1
- data/.github/workflows/publish_gem.yml +21 -0
- data/CHANGELOG.md +17 -0
- data/README.md +128 -6
- data/lib/mailersend/activity/activity.rb +2 -3
- data/lib/mailersend/analytics/analytics.rb +8 -12
- data/lib/mailersend/bulk_email/bulk_email.rb +3 -6
- data/lib/mailersend/client.rb +3 -3
- data/lib/mailersend/domains/domains.rb +16 -13
- data/lib/mailersend/email/email.rb +11 -6
- data/lib/mailersend/inbound_routing/inbound_routing.rb +42 -0
- data/lib/mailersend/messages/messages.rb +3 -5
- data/lib/mailersend/recipients/recipients.rb +4 -7
- data/lib/mailersend/scheduled_messages/scheduled_messages.rb +34 -0
- data/lib/mailersend/suppressions/suppressions.rb +20 -28
- data/lib/mailersend/templates/templates.rb +4 -7
- data/lib/mailersend/tokens/tokens.rb +3 -6
- data/lib/mailersend/version.rb +1 -1
- data/lib/mailersend/webhooks/webhooks.rb +6 -11
- data/lib/mailersend.rb +3 -0
- data/mailersend-ruby.gemspec +1 -1
- metadata +11 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8d67b989e26722f62ec3b556872643721be50947b67392f899f75115bb5dd9b
|
4
|
+
data.tar.gz: 5b9ee2fe25d34a07f71f38ff5a88137abcf22cfd1619b88b4505646e1f8facc2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f59c4b41f8134c36df9e0dd8c3365444719d942a6a6c57e1643bd58c3973dfbb768c922b3df2291eb1e2fbb8d99df14df40e3a4dd26ebb0caade3c999cb45d0
|
7
|
+
data.tar.gz: ebcb98375a4a56f3d6033dd93fecd22bef6019ac58d2338701aaa061a6579306ccf44311a202df5194a142ac0ae55f2bc880aa6595f98e09774503ce2359a298
|
data/.env.example
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
MAILERSEND_API_TOKEN="superlongkey"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
name: Publish Gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
tags:
|
6
|
+
- v*
|
7
|
+
jobs:
|
8
|
+
build:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@v2
|
13
|
+
|
14
|
+
- name: Release Gem
|
15
|
+
if: contains(github.ref, 'refs/tags/v')
|
16
|
+
uses: cadwallion/publish-rubygems-action@master
|
17
|
+
env:
|
18
|
+
GITHUB_TOKEN: ${{secrets.GITHUBTOKEN}}
|
19
|
+
RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
|
20
|
+
RELEASE_COMMAND: rake release
|
21
|
+
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
## [Released]
|
2
2
|
|
3
|
+
## [1.1.0] - 2022-02-18
|
4
|
+
|
5
|
+
- Domains endpoint improvements
|
6
|
+
- Added schedule an email parameter
|
7
|
+
- Added inbound routes endpoint
|
8
|
+
- Added scheduled messages endpoint
|
9
|
+
|
10
|
+
## [1.0.1] - 2022-02-16
|
11
|
+
|
12
|
+
- Removed puts from request response
|
13
|
+
- Added dynamic User-Agent based on SDK version
|
14
|
+
|
15
|
+
## [1.0.0] - 2022-02-15
|
16
|
+
|
17
|
+
- BREAKING CHANGE: Renamed `API_TOKEN` variable to `MAILERSEND_API_TOKEN`
|
18
|
+
|
3
19
|
## [0.2.4] - 2021-12-13
|
4
20
|
|
5
21
|
- Added bulk email endpoint
|
@@ -32,6 +48,7 @@
|
|
32
48
|
|
33
49
|
- Added required parameter for token creation
|
34
50
|
-
|
51
|
+
|
35
52
|
## [0.1.6] - 2021-06-15
|
36
53
|
|
37
54
|
- Fixed small issues in Domains
|
data/README.md
CHANGED
@@ -28,15 +28,27 @@ MailerSend Ruby SDK
|
|
28
28
|
- [Opens by country](#opens-by-country)
|
29
29
|
- [Opens by user-agent name](#opens-by-user-agent-name)
|
30
30
|
- [Opens by reading environment](#opens-by-reading-environment)
|
31
|
+
- [Inbound Routes](#inbound-routes)
|
32
|
+
- [Get a list of inbound routes](#get-a-list-of-inbound-routes)
|
33
|
+
- [Get a single inbound route](#get-a-single-inbound-route)
|
34
|
+
- [Add an inbound route](#add-an-inbound-route)
|
35
|
+
- [Update an inbound route](#update-an-inbound-route)
|
36
|
+
- [Delete an inbound route](#delete-an-inbound-route)
|
31
37
|
- [Domains](#domains)
|
32
38
|
- [Get a list of domains](#get-a-list-of-domains)
|
33
39
|
- [Get a single domain](#get-a-single-domain)
|
34
40
|
- [Delete a domain](#delete-a-domain)
|
35
41
|
- [Get recipients for a domain](#get-recipients-for-a-domain)
|
36
42
|
- [Update domain settings](#update-domain-settings)
|
43
|
+
- [Get DNS Records](#get-dns-records)
|
44
|
+
- [Get verification status](#get-verification-status)
|
37
45
|
- [Messages](#messages)
|
38
46
|
- [Get a list of messages](#get-a-list-of-messages)
|
39
47
|
- [Get info for a single message](#get-info-for-a-single-message)
|
48
|
+
- [Scheduled Messages](#scheduled-messages)
|
49
|
+
- [Get a list of scheduled messages](#get-a-list-of-scheduled-messages)
|
50
|
+
- [Get a single scheduled message](#get-a-single-scheduled-message)
|
51
|
+
- [Delete a scheduled message](#delete-a-scheduled-message)
|
40
52
|
- [Recipients](#recipients)
|
41
53
|
- [Get recipients](#get-recipients)
|
42
54
|
- [Get a single recipient](#get-a-single-recipient)
|
@@ -70,7 +82,7 @@ You will have to initalize it in your Ruby file with `require "mailersend-ruby"`
|
|
70
82
|
|
71
83
|
# Usage
|
72
84
|
|
73
|
-
This SDK requires that you either have `.env` file with `
|
85
|
+
This SDK requires that you either have `.env` file with `MAILERSEND_API_TOKEN` env variable or that your variable is enabled system wide (useful for Docker/Kubernetes). The example of how `MAILERSEND_API_TOKEN` should look like is in `.env.example`.
|
74
86
|
|
75
87
|
## Email
|
76
88
|
|
@@ -328,6 +340,69 @@ ms_analytics = Mailersend::Analytics.new
|
|
328
340
|
ms_analytics.ua_type(date_from: 1620643567, date_to: 1623321967)
|
329
341
|
```
|
330
342
|
|
343
|
+
## Inbound Routes
|
344
|
+
|
345
|
+
### Get a list of inbound routes
|
346
|
+
|
347
|
+
```ruby
|
348
|
+
require "mailersend-ruby"
|
349
|
+
|
350
|
+
ms_inbound_routes = Mailersend::InboundRouting.new
|
351
|
+
ms_inbound_routes.get_inbound_routes
|
352
|
+
```
|
353
|
+
|
354
|
+
### Get a single inbound route
|
355
|
+
|
356
|
+
```ruby
|
357
|
+
require "mailersend-ruby"
|
358
|
+
|
359
|
+
ms_inbound_routes = Mailersend::InboundRouting.new
|
360
|
+
ms_inbound_routes.get_single_route(inbound_id: 'idofroute12412')
|
361
|
+
```
|
362
|
+
|
363
|
+
### Add an inbound route
|
364
|
+
|
365
|
+
```ruby
|
366
|
+
require "mailersend-ruby"
|
367
|
+
|
368
|
+
ms_inbound_routes = Mailersend::InboundRouting.new
|
369
|
+
ms_inbound_routes.settings =
|
370
|
+
{
|
371
|
+
'domain_id' => 'yourdomainid',
|
372
|
+
'name' => 'inbound_name',
|
373
|
+
'domain_enabled' => false,
|
374
|
+
'match_filter' => { 'type' => 'match_all' },
|
375
|
+
'forwards' => [{ 'type' => 'webhook', 'value' => 'https://example.com' }]
|
376
|
+
}
|
377
|
+
puts ms_inbound_routes.add_inbound_route
|
378
|
+
```
|
379
|
+
|
380
|
+
### Update an inbound route
|
381
|
+
|
382
|
+
```ruby
|
383
|
+
require "mailersend-ruby"
|
384
|
+
|
385
|
+
ms_inbound_routes = Mailersend::InboundRouting.new
|
386
|
+
ms_inbound_routes.settings =
|
387
|
+
{
|
388
|
+
'domain_id' => 'yourdomainid',
|
389
|
+
'name' => 'inbound_updated',
|
390
|
+
'domain_enabled' => false,
|
391
|
+
'match_filter' => { 'type' => 'match_all' },
|
392
|
+
'forwards' => [{ 'type' => 'webhook', 'value' => 'https://example.com' }]
|
393
|
+
}
|
394
|
+
puts ms_inbound_routes.update_inbound_route(inbound_id: 'idofroute12412')
|
395
|
+
```
|
396
|
+
|
397
|
+
### Delete an inbound route
|
398
|
+
|
399
|
+
```ruby
|
400
|
+
require "mailersend-ruby"
|
401
|
+
|
402
|
+
ms_inbound_routes = Mailersend::InboundRouting.new
|
403
|
+
ms_inbound_routes.delete_route(inbound_id: 'idofroute12412')
|
404
|
+
```
|
405
|
+
|
331
406
|
## Domains
|
332
407
|
|
333
408
|
### Get a list of domains
|
@@ -375,6 +450,24 @@ ms_domains = Mailersend::Domains.new
|
|
375
450
|
ms_domains.settings(domain_id: "idofdomain12412", track_clicks: true, track_unsubscribe: false)
|
376
451
|
```
|
377
452
|
|
453
|
+
### Get DNS Records
|
454
|
+
|
455
|
+
```ruby
|
456
|
+
require "mailersend-ruby"
|
457
|
+
|
458
|
+
ms_domains = Mailersend::Domains.new
|
459
|
+
ms_domains.dns(domain_id: "idofdomain12412")
|
460
|
+
```
|
461
|
+
|
462
|
+
### Get verification status
|
463
|
+
|
464
|
+
```ruby
|
465
|
+
require "mailersend-ruby"
|
466
|
+
|
467
|
+
ms_domains = Mailersend::Domains.new
|
468
|
+
ms_domains.verify(domain_id: "idofdomain12412")
|
469
|
+
```
|
470
|
+
|
378
471
|
## Messages
|
379
472
|
|
380
473
|
### Get a list of messages
|
@@ -395,6 +488,35 @@ ms_messages = Mailersend::Messages.new
|
|
395
488
|
ms_messages.single(message_id: "mess11454")
|
396
489
|
```
|
397
490
|
|
491
|
+
## Scheduled Messages
|
492
|
+
|
493
|
+
### Get a list of scheduled messages
|
494
|
+
|
495
|
+
```ruby
|
496
|
+
require "mailersend-ruby"
|
497
|
+
|
498
|
+
ms_scheduled_messages = Mailersend::ScheduledMessages.new
|
499
|
+
ms_scheduled_messages.get_list
|
500
|
+
```
|
501
|
+
|
502
|
+
### Get a single scheduled message
|
503
|
+
|
504
|
+
```ruby
|
505
|
+
require "mailersend-ruby"
|
506
|
+
|
507
|
+
ms_scheduled_messages = Mailersend::ScheduledMessages.new
|
508
|
+
ms_scheduled_messages.get_signle(message_id: 'mess11454')
|
509
|
+
```
|
510
|
+
|
511
|
+
### Delete a scheduled message
|
512
|
+
|
513
|
+
```ruby
|
514
|
+
require "mailersend-ruby"
|
515
|
+
|
516
|
+
ms_scheduled_messages = Mailersend::ScheduledMessages.new
|
517
|
+
ms_scheduled_messages.delete(message_id: 'mess11454')
|
518
|
+
```
|
519
|
+
|
398
520
|
## Recipients
|
399
521
|
|
400
522
|
### Get recipients
|
@@ -477,16 +599,16 @@ require "mailersend-ruby"
|
|
477
599
|
ms_suppressions = Mailersend::Suppressions.new
|
478
600
|
|
479
601
|
// Delete from Block List
|
480
|
-
ms_suppressions.delete_from_blocklist(ids: ["xxx2241ll"])
|
602
|
+
ms_suppressions.delete_from_blocklist(domain_id: 'yourdomainid', ids: ["xxx2241ll"])
|
481
603
|
|
482
604
|
// Delete from Hard Bounces
|
483
|
-
ms_suppressions.delete_from_hard_bounces(ids: ["xxx2241ll"])
|
605
|
+
ms_suppressions.delete_from_hard_bounces(domain_id: 'yourdomainid', ids: ["xxx2241ll"])
|
484
606
|
|
485
607
|
// Delete from Spam Complaints
|
486
|
-
ms_suppressions.delete_from_spam_complaints(ids: ["xxx2241ll"])
|
608
|
+
ms_suppressions.delete_from_spam_complaints(domain_id: 'yourdomainid', ids: ["xxx2241ll"])
|
487
609
|
|
488
610
|
// Delete from Unsubscribes
|
489
|
-
ms_suppressions.delete_from_unsubscribers(ids: ["xxx2241ll"])
|
611
|
+
ms_suppressions.delete_from_unsubscribers(domain_id: 'yourdomainid', ids: ["xxx2241ll"])
|
490
612
|
```
|
491
613
|
|
492
614
|
## Webhooks
|
@@ -572,4 +694,4 @@ The official documentation is at [https://developers.mailersend.com](https://dev
|
|
572
694
|
|
573
695
|
# License
|
574
696
|
|
575
|
-
[The MIT License (MIT)](LICENSE)
|
697
|
+
[The MIT License (MIT)](LICENSE)
|
@@ -27,9 +27,8 @@ module Mailersend
|
|
27
27
|
date_to: date_to
|
28
28
|
}
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
puts response
|
30
|
+
client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/activity/#{domain_id}",
|
31
|
+
query: URI.encode_www_form(hash.compact)))
|
33
32
|
end
|
34
33
|
end
|
35
34
|
end
|
@@ -34,9 +34,8 @@ module Mailersend
|
|
34
34
|
'tags[]' => tags
|
35
35
|
}
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
puts response
|
37
|
+
client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/analytics/date',
|
38
|
+
query: URI.encode_www_form(hash.compact)))
|
40
39
|
end
|
41
40
|
|
42
41
|
def country(date_from:, date_to:, domain_id: nil, recipient_id: nil, tags: nil)
|
@@ -48,9 +47,8 @@ module Mailersend
|
|
48
47
|
'tags[]': tags
|
49
48
|
}
|
50
49
|
|
51
|
-
|
52
|
-
|
53
|
-
puts response
|
50
|
+
client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/analytics/country',
|
51
|
+
query: URI.encode_www_form(hash.compact)))
|
54
52
|
end
|
55
53
|
|
56
54
|
def ua_name(date_from:, date_to:, domain_id: nil, recipient_id: nil, tags: nil)
|
@@ -62,9 +60,8 @@ module Mailersend
|
|
62
60
|
'tags[]': tags
|
63
61
|
}
|
64
62
|
|
65
|
-
|
66
|
-
|
67
|
-
puts response
|
63
|
+
client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/analytics/ua-name',
|
64
|
+
query: URI.encode_www_form(hash.compact)))
|
68
65
|
end
|
69
66
|
|
70
67
|
def ua_type(date_from:, date_to:, domain_id: nil, recipient_id: nil, tags: nil)
|
@@ -76,9 +73,8 @@ module Mailersend
|
|
76
73
|
'tags[]': tags
|
77
74
|
}
|
78
75
|
|
79
|
-
|
80
|
-
|
81
|
-
puts response
|
76
|
+
client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/analytics/ua-type',
|
77
|
+
query: URI.encode_www_form(hash.compact)))
|
82
78
|
end
|
83
79
|
end
|
84
80
|
end
|
@@ -14,7 +14,7 @@ module Mailersend
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def add_attachment(content:, filename:)
|
17
|
-
data = File.
|
17
|
+
data = File.read(content.to_s)
|
18
18
|
encoded = Base64.strict_encode64(data)
|
19
19
|
@attachments << {
|
20
20
|
'content' => encoded,
|
@@ -23,14 +23,11 @@ module Mailersend
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def send
|
26
|
-
|
27
|
-
puts response
|
28
|
-
puts response.status.code
|
26
|
+
client.http.post("#{API_URL}/bulk-email", json: @messages)
|
29
27
|
end
|
30
28
|
|
31
29
|
def get_bulk_status(bulk_email_id:)
|
32
|
-
|
33
|
-
puts response
|
30
|
+
client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/bulk-email/#{bulk_email_id}"))
|
34
31
|
end
|
35
32
|
end
|
36
33
|
end
|
data/lib/mailersend/client.rb
CHANGED
@@ -6,7 +6,7 @@ require 'dotenv/load'
|
|
6
6
|
API_URL = 'https://api.mailersend.com/v1'
|
7
7
|
API_BASE_HOST = 'api.mailersend.com'
|
8
8
|
|
9
|
-
Dotenv.require_keys('
|
9
|
+
Dotenv.require_keys('MAILERSEND_API_TOKEN')
|
10
10
|
|
11
11
|
# mailersend-ruby is a gem that integrates all endpoints from MailerSend API
|
12
12
|
module Mailersend
|
@@ -14,7 +14,7 @@ module Mailersend
|
|
14
14
|
|
15
15
|
# Inits the client.
|
16
16
|
class Client
|
17
|
-
def initialize(api_token = ENV['
|
17
|
+
def initialize(api_token = ENV['MAILERSEND_API_TOKEN'])
|
18
18
|
@api_token = api_token
|
19
19
|
end
|
20
20
|
|
@@ -22,7 +22,7 @@ module Mailersend
|
|
22
22
|
HTTP
|
23
23
|
.timeout(connect: 15, read: 30)
|
24
24
|
.auth("Bearer #{@api_token}")
|
25
|
-
.headers('User-Agent' =>
|
25
|
+
.headers('User-Agent' => "MailerSend-client-ruby/#{Mailersend::VERSION}",
|
26
26
|
'Accept' => 'application/json')
|
27
27
|
end
|
28
28
|
end
|
@@ -23,9 +23,8 @@ module Mailersend
|
|
23
23
|
'limit' => limit,
|
24
24
|
'verified' => verified
|
25
25
|
}
|
26
|
-
|
27
|
-
|
28
|
-
puts response
|
26
|
+
client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/domains',
|
27
|
+
query: URI.encode_www_form(hash.compact)))
|
29
28
|
end
|
30
29
|
|
31
30
|
def single(domain_id:, page: nil, limit: nil, verified: nil)
|
@@ -34,14 +33,12 @@ module Mailersend
|
|
34
33
|
'limit' => limit,
|
35
34
|
'verified' => verified
|
36
35
|
}
|
37
|
-
|
38
|
-
|
39
|
-
puts response
|
36
|
+
client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/domains/#{domain_id}",
|
37
|
+
query: URI.encode_www_form(hash.compact)))
|
40
38
|
end
|
41
39
|
|
42
40
|
def delete(domain_id:)
|
43
|
-
|
44
|
-
puts response
|
41
|
+
client.http.delete(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/domains/#{domain_id}"))
|
45
42
|
end
|
46
43
|
|
47
44
|
def recipients(domain_id:)
|
@@ -49,9 +46,8 @@ module Mailersend
|
|
49
46
|
'page' => page,
|
50
47
|
'limit' => limit
|
51
48
|
}
|
52
|
-
|
53
|
-
|
54
|
-
puts response
|
49
|
+
client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/domains/#{domain_id}/recipients",
|
50
|
+
query: URI.encode_www_form(hash.compact)))
|
55
51
|
end
|
56
52
|
|
57
53
|
def settings(domain_id:, send_paused: nil, track_clicks: nil, track_opens: nil, track_unsubscribe: nil, track_unsubscribe_html: nil, track_unsubscribe_plain: nil, track_content: nil, custom_tracking_enabled: nil, custom_tracking_subdomain: nil)
|
@@ -66,8 +62,15 @@ module Mailersend
|
|
66
62
|
'custom_tracking_enabled' => custom_tracking_enabled,
|
67
63
|
'custom_tracking_subdomain' => custom_tracking_subdomain
|
68
64
|
}
|
69
|
-
|
70
|
-
|
65
|
+
client.http.put("#{API_URL}/domains/#{domain_id}/settings", json: hash.compact)
|
66
|
+
end
|
67
|
+
|
68
|
+
def dns(domain_id:)
|
69
|
+
client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/domains/#{domain_id}/dns-records"))
|
70
|
+
end
|
71
|
+
|
72
|
+
def verify(domain_id:)
|
73
|
+
client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/domains/#{domain_id}/verify"))
|
71
74
|
end
|
72
75
|
end
|
73
76
|
end
|
@@ -18,7 +18,8 @@ module Mailersend
|
|
18
18
|
:template_id,
|
19
19
|
:tags,
|
20
20
|
:variables,
|
21
|
-
:personalization
|
21
|
+
:personalization,
|
22
|
+
:send_at
|
22
23
|
|
23
24
|
def initialize(client = Mailersend::Client.new)
|
24
25
|
@client = client
|
@@ -34,6 +35,7 @@ module Mailersend
|
|
34
35
|
@personalization = []
|
35
36
|
@attachments = []
|
36
37
|
@tags = []
|
38
|
+
@send_at = send_at
|
37
39
|
end
|
38
40
|
|
39
41
|
def add_recipients(recipients)
|
@@ -85,7 +87,7 @@ module Mailersend
|
|
85
87
|
end
|
86
88
|
|
87
89
|
def add_attachment(content:, filename:)
|
88
|
-
data = File.
|
90
|
+
data = File.read(content.to_s)
|
89
91
|
encoded = Base64.strict_encode64(data)
|
90
92
|
@attachments << {
|
91
93
|
'content' => encoded,
|
@@ -93,6 +95,10 @@ module Mailersend
|
|
93
95
|
}
|
94
96
|
end
|
95
97
|
|
98
|
+
def add_send_at(send_at)
|
99
|
+
@send_at = send_at
|
100
|
+
end
|
101
|
+
|
96
102
|
def send
|
97
103
|
message = {
|
98
104
|
'from' => @from,
|
@@ -106,12 +112,11 @@ module Mailersend
|
|
106
112
|
'variables' => @variables,
|
107
113
|
'personalization' => @personalization,
|
108
114
|
'template_id' => @template_id,
|
109
|
-
'attachments' => @attachments
|
115
|
+
'attachments' => @attachments,
|
116
|
+
'send_at' => @send_at
|
110
117
|
}
|
111
118
|
|
112
|
-
|
113
|
-
puts response
|
114
|
-
puts response.status.code
|
119
|
+
client.http.post("#{API_URL}/email", json: message.delete_if { |_, value| value.to_s.strip == '' || value == [] || value == {} })
|
115
120
|
end
|
116
121
|
end
|
117
122
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Mailersend
|
4
|
+
# Inbound routing endpoint from MailerSend API.
|
5
|
+
class InboundRouting
|
6
|
+
attr_accessor :client,
|
7
|
+
:domain_id,
|
8
|
+
:page,
|
9
|
+
:limit,
|
10
|
+
:inbound_id,
|
11
|
+
:settings
|
12
|
+
|
13
|
+
def initialize(client = Mailersend::Client.new)
|
14
|
+
@client = client
|
15
|
+
@domain_id = domain_id
|
16
|
+
@page = page
|
17
|
+
@limit = limit
|
18
|
+
@inbound_id = inbound_id
|
19
|
+
@settings = []
|
20
|
+
end
|
21
|
+
|
22
|
+
def get_inbound_routes(*)
|
23
|
+
client.http.get("#{API_URL}/inbound")
|
24
|
+
end
|
25
|
+
|
26
|
+
def get_single_route(inbound_id:)
|
27
|
+
client.http.get("#{API_URL}/inbound/#{inbound_id}")
|
28
|
+
end
|
29
|
+
|
30
|
+
def add_inbound_route
|
31
|
+
client.http.post("#{API_URL}/inbound", json: @settings)
|
32
|
+
end
|
33
|
+
|
34
|
+
def update_inbound_route(inbound_id:)
|
35
|
+
client.http.put("#{API_URL}/inbound/#{inbound_id}", json: @settings)
|
36
|
+
end
|
37
|
+
|
38
|
+
def delete_route(inbound_id:)
|
39
|
+
client.http.delete("#{API_URL}/inbound/#{inbound_id}")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -21,14 +21,12 @@ module Mailersend
|
|
21
21
|
'limit' => limit
|
22
22
|
}
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
puts response
|
24
|
+
client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/messages',
|
25
|
+
query: URI.encode_www_form(hash)))
|
27
26
|
end
|
28
27
|
|
29
28
|
def single(message_id:)
|
30
|
-
|
31
|
-
puts response
|
29
|
+
client.http.get("#{API_URL}/messages/#{message_id}")
|
32
30
|
end
|
33
31
|
end
|
34
32
|
end
|
@@ -21,19 +21,16 @@ module Mailersend
|
|
21
21
|
'limit' => limit
|
22
22
|
}
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
puts response
|
24
|
+
client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/recipients',
|
25
|
+
query: URI.encode_www_form(hash)))
|
27
26
|
end
|
28
27
|
|
29
28
|
def single(recipient_id:)
|
30
|
-
|
31
|
-
puts response
|
29
|
+
client.http.get("#{API_URL}/recipients/#{recipient_id}")
|
32
30
|
end
|
33
31
|
|
34
32
|
def delete(recipient_id:)
|
35
|
-
|
36
|
-
puts response
|
33
|
+
client.http.delete("#{API_URL}/recipients/#{recipient_id}")
|
37
34
|
end
|
38
35
|
end
|
39
36
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Mailersend
|
4
|
+
# Scheduled messages endpoint from MailerSend API.
|
5
|
+
class ScheduledMessages
|
6
|
+
attr_accessor :client,
|
7
|
+
:domain_id,
|
8
|
+
:status,
|
9
|
+
:page,
|
10
|
+
:limit,
|
11
|
+
:message_id
|
12
|
+
|
13
|
+
def initialize(client = Mailersend::Client.new)
|
14
|
+
@client = client
|
15
|
+
@domain_id = domain_id
|
16
|
+
@status = status
|
17
|
+
@page = page
|
18
|
+
@limit = limit
|
19
|
+
@message_id = message_id
|
20
|
+
end
|
21
|
+
|
22
|
+
def get_list(*)
|
23
|
+
client.http.get("#{API_URL}/message-schedules")
|
24
|
+
end
|
25
|
+
|
26
|
+
def get_signle(message_id:)
|
27
|
+
client.http.get("#{API_URL}/message-schedules/#{message_id}")
|
28
|
+
end
|
29
|
+
|
30
|
+
def delete(message_id:)
|
31
|
+
client.http.delete("#{API_URL}/message-schedules/#{message_id}")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -16,23 +16,19 @@ module Mailersend
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def get_from_blocklist(*)
|
19
|
-
|
20
|
-
puts response
|
19
|
+
client.http.get("#{API_URL}/suppressions/blocklist")
|
21
20
|
end
|
22
21
|
|
23
22
|
def get_hard_bounces(*)
|
24
|
-
|
25
|
-
puts response
|
23
|
+
client.http.get("#{API_URL}/suppressions/hard-bounces")
|
26
24
|
end
|
27
25
|
|
28
26
|
def get_spam_complaints(*)
|
29
|
-
|
30
|
-
puts response
|
27
|
+
client.http.get("#{API_URL}/suppressions/spam-complaints")
|
31
28
|
end
|
32
29
|
|
33
30
|
def get_unsubscribes(*)
|
34
|
-
|
35
|
-
puts response
|
31
|
+
client.http.get("#{API_URL}/suppressions/unsubscribes")
|
36
32
|
end
|
37
33
|
|
38
34
|
def add_to_blocklist(recipients: nil, patterns: nil)
|
@@ -40,17 +36,16 @@ module Mailersend
|
|
40
36
|
'recipients' => recipients,
|
41
37
|
'patterns' => patterns
|
42
38
|
}
|
43
|
-
|
44
|
-
puts response
|
39
|
+
client.http.post("#{API_URL}/suppressions/blocklist", json: hash.compact)
|
45
40
|
end
|
46
41
|
|
47
|
-
def delete_from_blocklist(ids: nil, all: nil)
|
42
|
+
def delete_from_blocklist(domain_id: nil, ids: nil, all: nil)
|
48
43
|
hash = {
|
44
|
+
'domain_id' => domain_id,
|
49
45
|
'ids' => ids,
|
50
46
|
'all' => all
|
51
47
|
}
|
52
|
-
|
53
|
-
puts response
|
48
|
+
client.http.delete("#{API_URL}/suppressions/blocklist", json: hash.compact)
|
54
49
|
end
|
55
50
|
|
56
51
|
def add_to_hard_bounces(domain_id: nil, recipients: nil)
|
@@ -58,17 +53,16 @@ module Mailersend
|
|
58
53
|
'domain_id' => domain_id,
|
59
54
|
'recipients' => recipients
|
60
55
|
}
|
61
|
-
|
62
|
-
puts response
|
56
|
+
client.http.post("#{API_URL}/suppressions/hard-bounces", json: hash.compact)
|
63
57
|
end
|
64
58
|
|
65
|
-
def delete_from_hard_bounces(ids: nil, all: nil)
|
59
|
+
def delete_from_hard_bounces(domain_id: nil, ids: nil, all: nil)
|
66
60
|
hash = {
|
61
|
+
'domain_id' => domain_id,
|
67
62
|
'ids' => ids,
|
68
63
|
'all' => all
|
69
64
|
}
|
70
|
-
|
71
|
-
puts response
|
65
|
+
client.http.delete("#{API_URL}/suppressions/hard-bounces", json: hash.compact)
|
72
66
|
end
|
73
67
|
|
74
68
|
def add_to_spam_complaints(domain_id: nil, recipients: nil)
|
@@ -76,17 +70,16 @@ module Mailersend
|
|
76
70
|
'domain_id' => domain_id,
|
77
71
|
'recipients' => recipients
|
78
72
|
}
|
79
|
-
|
80
|
-
puts response
|
73
|
+
client.http.post("#{API_URL}/suppressions/spam-complaints", json: hash.compact)
|
81
74
|
end
|
82
75
|
|
83
|
-
def delete_from_spam_complaints(ids: nil, all: nil)
|
76
|
+
def delete_from_spam_complaints(domain_id: nil, ids: nil, all: nil)
|
84
77
|
hash = {
|
78
|
+
'domain_id' => domain_id,
|
85
79
|
'ids' => ids,
|
86
80
|
'all' => all
|
87
81
|
}
|
88
|
-
|
89
|
-
puts response
|
82
|
+
client.http.delete("#{API_URL}/suppressions/spam-complaints", json: hash.compact)
|
90
83
|
end
|
91
84
|
|
92
85
|
def add_to_unsubscribers(domain_id: nil, recipients: nil)
|
@@ -94,17 +87,16 @@ module Mailersend
|
|
94
87
|
'domain_id' => domain_id,
|
95
88
|
'recipients' => recipients
|
96
89
|
}
|
97
|
-
|
98
|
-
puts response
|
90
|
+
client.http.post("#{API_URL}/suppressions/unsubscribes", json: hash.compact)
|
99
91
|
end
|
100
92
|
|
101
|
-
def delete_from_unsubscribers(ids: nil, all: nil)
|
93
|
+
def delete_from_unsubscribers(domain_id: nil, ids: nil, all: nil)
|
102
94
|
hash = {
|
95
|
+
'domain_id' => domain_id,
|
103
96
|
'ids' => ids,
|
104
97
|
'all' => all
|
105
98
|
}
|
106
|
-
|
107
|
-
puts response
|
99
|
+
client.http.delete("#{API_URL}/suppressions/unsubscribes", json: hash.compact)
|
108
100
|
end
|
109
101
|
end
|
110
102
|
end
|
@@ -22,19 +22,16 @@ module Mailersend
|
|
22
22
|
'limit' => limit
|
23
23
|
}
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
puts response
|
25
|
+
client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/templates',
|
26
|
+
query: URI.encode_www_form(hash)))
|
28
27
|
end
|
29
28
|
|
30
29
|
def single(template_id:)
|
31
|
-
|
32
|
-
puts response
|
30
|
+
client.http.get("#{API_URL}/templates/#{template_id}")
|
33
31
|
end
|
34
32
|
|
35
33
|
def delete(template_id:)
|
36
|
-
|
37
|
-
puts response
|
34
|
+
client.http.delete("#{API_URL}/templates/#{template_id}")
|
38
35
|
end
|
39
36
|
end
|
40
37
|
end
|
@@ -23,21 +23,18 @@ module Mailersend
|
|
23
23
|
'scopes' => scopes,
|
24
24
|
'domain_id' => domain_id
|
25
25
|
}
|
26
|
-
|
27
|
-
puts response
|
26
|
+
client.http.post("#{API_URL}/token", json: json)
|
28
27
|
end
|
29
28
|
|
30
29
|
def update(token_id:, status:)
|
31
30
|
status = {
|
32
31
|
status: status
|
33
32
|
}
|
34
|
-
|
35
|
-
puts response
|
33
|
+
client.http.put("#{API_URL}/token/#{token_id}/settings", json: status)
|
36
34
|
end
|
37
35
|
|
38
36
|
def delete(token_id:)
|
39
|
-
|
40
|
-
puts response
|
37
|
+
client.http.delete("#{API_URL}/token/#{token_id}")
|
41
38
|
end
|
42
39
|
end
|
43
40
|
end
|
data/lib/mailersend/version.rb
CHANGED
@@ -24,14 +24,12 @@ module Mailersend
|
|
24
24
|
hash = {
|
25
25
|
'domain_id' => domain_id
|
26
26
|
}
|
27
|
-
|
28
|
-
|
29
|
-
puts response
|
27
|
+
client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/webhooks',
|
28
|
+
query: URI.encode_www_form(hash)))
|
30
29
|
end
|
31
30
|
|
32
31
|
def single(webhook_id:)
|
33
|
-
|
34
|
-
puts response
|
32
|
+
client.http.get("#{API_URL}/webhooks/#{webhook_id}")
|
35
33
|
end
|
36
34
|
|
37
35
|
def create(url:, name:, events:, domain_id:, enabled: nil)
|
@@ -43,8 +41,7 @@ module Mailersend
|
|
43
41
|
'enabled' => enabled.to_s == 'true'
|
44
42
|
}
|
45
43
|
|
46
|
-
|
47
|
-
puts response
|
44
|
+
client.http.post("#{API_URL}/webhooks", json: hash.compact)
|
48
45
|
end
|
49
46
|
|
50
47
|
def update(webhook_id:, url: nil, name: nil, events: nil, enabled: nil)
|
@@ -54,13 +51,11 @@ module Mailersend
|
|
54
51
|
'events' => events,
|
55
52
|
'enabled' => enabled.to_s == 'true'
|
56
53
|
}
|
57
|
-
|
58
|
-
puts response
|
54
|
+
client.http.put("#{API_URL}/webhooks/#{webhook_id}", json: hash.compact)
|
59
55
|
end
|
60
56
|
|
61
57
|
def delete(webhook_id:)
|
62
|
-
|
63
|
-
puts response
|
58
|
+
client.http.delete("#{API_URL}/webhooks/#{webhook_id}")
|
64
59
|
end
|
65
60
|
end
|
66
61
|
end
|
data/lib/mailersend.rb
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'mailersend/client'
|
4
|
+
require_relative 'mailersend/version'
|
4
5
|
require_relative 'mailersend/activity/activity'
|
5
6
|
require_relative 'mailersend/analytics/analytics'
|
6
7
|
require_relative 'mailersend/bulk_email/bulk_email'
|
7
8
|
require_relative 'mailersend/domains/domains'
|
8
9
|
require_relative 'mailersend/email/email'
|
10
|
+
require_relative 'mailersend/inbound_routing/inbound_routing'
|
9
11
|
require_relative 'mailersend/messages/messages'
|
10
12
|
require_relative 'mailersend/recipients/recipients'
|
13
|
+
require_relative 'mailersend/scheduled_messages/scheduled_messages'
|
11
14
|
require_relative 'mailersend/suppressions/suppressions'
|
12
15
|
require_relative 'mailersend/templates/templates'
|
13
16
|
require_relative 'mailersend/tokens/tokens'
|
data/mailersend-ruby.gemspec
CHANGED
@@ -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_development_dependency 'bundler', '~> 2.
|
30
|
+
spec.add_development_dependency 'bundler', '~> 2.3.4'
|
31
31
|
spec.add_development_dependency 'rake', '~> 13.0'
|
32
32
|
spec.add_development_dependency 'rubocop', '~> 1.7'
|
33
33
|
spec.add_dependency 'dotenv', '~> 2.7'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailersend-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nikola Milojević
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: 2.3.4
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: 2.3.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,6 +120,7 @@ extra_rdoc_files: []
|
|
120
120
|
files:
|
121
121
|
- ".env.example"
|
122
122
|
- ".github/workflows/main.yml"
|
123
|
+
- ".github/workflows/publish_gem.yml"
|
123
124
|
- ".gitignore"
|
124
125
|
- ".rubocop.yml"
|
125
126
|
- CHANGELOG.md
|
@@ -137,8 +138,10 @@ files:
|
|
137
138
|
- lib/mailersend/client.rb
|
138
139
|
- lib/mailersend/domains/domains.rb
|
139
140
|
- lib/mailersend/email/email.rb
|
141
|
+
- lib/mailersend/inbound_routing/inbound_routing.rb
|
140
142
|
- lib/mailersend/messages/messages.rb
|
141
143
|
- lib/mailersend/recipients/recipients.rb
|
144
|
+
- lib/mailersend/scheduled_messages/scheduled_messages.rb
|
142
145
|
- lib/mailersend/suppressions/suppressions.rb
|
143
146
|
- lib/mailersend/templates/templates.rb
|
144
147
|
- lib/mailersend/tokens/tokens.rb
|
@@ -155,7 +158,7 @@ metadata:
|
|
155
158
|
source_code_uri: https://github.com/mailersend/mailersend-ruby
|
156
159
|
changelog_uri: https://github.com/mailersend/mailersend-ruby/blob/main/CHANGELOG.md
|
157
160
|
rubygems_mfa_required: 'true'
|
158
|
-
post_install_message:
|
161
|
+
post_install_message:
|
159
162
|
rdoc_options: []
|
160
163
|
require_paths:
|
161
164
|
- lib
|
@@ -170,8 +173,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
173
|
- !ruby/object:Gem::Version
|
171
174
|
version: '0'
|
172
175
|
requirements: []
|
173
|
-
rubygems_version: 3.
|
174
|
-
signing_key:
|
176
|
+
rubygems_version: 3.3.3
|
177
|
+
signing_key:
|
175
178
|
specification_version: 4
|
176
179
|
summary: MailerSend's official Ruby SDK
|
177
180
|
test_files: []
|