mailersend-ruby 0.1.9 → 0.2.3
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/.rubocop.yml +0 -1
- data/CHANGELOG.md +20 -0
- data/Gemfile +1 -1
- data/README.md +150 -29
- data/Rakefile +2 -2
- data/bin/console +3 -3
- data/lib/mailersend/analytics/analytics.rb +19 -19
- data/lib/mailersend/client.rb +8 -8
- data/lib/mailersend/domains/domains.rb +18 -18
- data/lib/mailersend/email/email.rb +19 -19
- data/lib/mailersend/messages/messages.rb +3 -3
- data/lib/mailersend/recipients/recipients.rb +3 -3
- data/lib/mailersend/suppressions/suppressions.rb +110 -0
- data/lib/mailersend/templates/templates.rb +40 -0
- data/lib/mailersend/tokens/tokens.rb +3 -3
- data/lib/mailersend/version.rb +1 -1
- data/lib/mailersend/webhooks/webhooks.rb +11 -11
- data/lib/mailersend-ruby.rb +1 -1
- data/lib/mailersend.rb +11 -9
- data/mailersend-ruby.gemspec +20 -20
- data/renovate.json +5 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4207d4b81f4d12363f06fafb214a4b2d75dd2c0329376b3bafbe23a6b20fb97
|
4
|
+
data.tar.gz: 28f21d8500d4b7b07c0e6bddfa66ab08b522cd1040a1616858f81b03d422be86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5704c42a93de51701012a0ac5f55adeef0050b354ae1dff600c85f8f485645ecdf62c542847c60afe87a5655532faabd6551fac04900ee166ce5bae2f04783b1
|
7
|
+
data.tar.gz: f70b9d9fa4ab3c28d1a54d1769326833b0e5c154593f2bf339458d5fd33953af2ca1ade5e5d509e76142d18c5f7cbe33e5c03e777f5bad709c7ca75207534abf
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,25 @@
|
|
1
1
|
## [Released]
|
2
2
|
|
3
|
+
## [0.2.3] - 2021-11-11
|
4
|
+
|
5
|
+
- Fixed typo for reply_to (thanks @JohnGoodman)
|
6
|
+
|
7
|
+
## [0.2.2] - 2021-08-04
|
8
|
+
|
9
|
+
- Removed leftover debugging stuff
|
10
|
+
|
11
|
+
## [0.2.1] - 2021-08-04
|
12
|
+
|
13
|
+
- Fixed email class so that it omits empty values
|
14
|
+
|
15
|
+
## [0.2.0] - 2021-07-01
|
16
|
+
|
17
|
+
- Added Templates endpoint
|
18
|
+
|
19
|
+
## [0.1.9] - 2021-06-30
|
20
|
+
|
21
|
+
- Fixed docs
|
22
|
+
|
3
23
|
## [0.1.8] - 2021-06-15
|
4
24
|
|
5
25
|
- Fixed unused parameter
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -11,12 +11,12 @@ MailerSend Ruby SDK
|
|
11
11
|
- [Send an email](#send-an-email)
|
12
12
|
- [Add CC, BCC recipients](#add-cc-bcc-recipients)
|
13
13
|
- [Send a template-based email](#send-a-template-based-email)
|
14
|
+
- [Advanced personalization](#advanced-personalization)
|
15
|
+
- [Simple personalization](#simple-personalization)
|
14
16
|
- [Tokens](#tokens)
|
15
17
|
- [Create a token](#create-a-token)
|
16
18
|
- [Update a token](#update-a-token)
|
17
19
|
- [Delete a token](#delete-a-token)
|
18
|
-
- [Advanced personalization](#advanced-personalization)
|
19
|
-
- [Simple personalization](#simple-personalization)
|
20
20
|
- [Send email with attachment](#send-email-with-attachment)
|
21
21
|
- [Activity](#activity)
|
22
22
|
- [Get a list of activities](#get-a-list-of-activities)
|
@@ -29,6 +29,7 @@ MailerSend Ruby SDK
|
|
29
29
|
- [Get a list of domains](#get-a-list-of-domains)
|
30
30
|
- [Get a single domain](#get-a-single-domain)
|
31
31
|
- [Delete a domain](#delete-a-domain)
|
32
|
+
- [Get recipients for a domain](#get-recipients-for-a-domain)
|
32
33
|
- [Update domain settings](#update-domain-settings)
|
33
34
|
- [Messages](#messages)
|
34
35
|
- [Get a list of messages](#get-a-list-of-messages)
|
@@ -37,11 +38,20 @@ MailerSend Ruby SDK
|
|
37
38
|
- [Get recipients](#get-recipients)
|
38
39
|
- [Get a single recipient](#get-a-single-recipient)
|
39
40
|
- [Delete a recipient](#delete-a-recipient)
|
41
|
+
- [Suppressions](#suppressions)
|
42
|
+
- [Get recipients from a suppression list](#get-recipients-from-a-suppression-list)
|
43
|
+
- [Add recipients to a suppression list](#add-recipients-to-a-suppression-list)
|
44
|
+
- [Delete recipients from a suppression list](#delete-recipients-from-a-suppression-list)
|
40
45
|
- [Webhooks](#webhooks)
|
41
46
|
- [List webhooks](#list-webhooks)
|
42
47
|
- [Get a webhook](#get-a-webhook)
|
43
48
|
- [Create a webhook](#create-a-webhook)
|
44
49
|
- [Update a webhook](#update-a-webhook)
|
50
|
+
- [Delete a webhook](#delete-a-webhook)
|
51
|
+
- [Templates](#templates)
|
52
|
+
- [Get templates](#get-templates)
|
53
|
+
- [Get a single template](#get-a-single-template)
|
54
|
+
- [Delete template](#delete-template)
|
45
55
|
- [Support and Feedback](#support-and-feedback)
|
46
56
|
- [License](#license)
|
47
57
|
|
@@ -122,32 +132,6 @@ ms_email.add_template_id(12415125)
|
|
122
132
|
ms_email.send
|
123
133
|
```
|
124
134
|
|
125
|
-
## Tokens
|
126
|
-
|
127
|
-
### Create a token
|
128
|
-
```ruby
|
129
|
-
require "mailersend-ruby"
|
130
|
-
|
131
|
-
ms_tokens = Mailersend::Tokens.new
|
132
|
-
ms_tokens.create(name: "Very nice token", scopes: %w[ email_full domains_read ], domain_id: "yourdomainid")
|
133
|
-
```
|
134
|
-
|
135
|
-
### Update a token
|
136
|
-
```ruby
|
137
|
-
require "mailersend-ruby"
|
138
|
-
|
139
|
-
ms_tokens = Mailersend::Tokens.new
|
140
|
-
ms_tokens.update(token_id: "d2220fx04", status: "paused")
|
141
|
-
```
|
142
|
-
|
143
|
-
### Delete a token
|
144
|
-
```ruby
|
145
|
-
require "mailersend-ruby"
|
146
|
-
|
147
|
-
ms_tokens = Mailersend::Tokens.new
|
148
|
-
ms_tokens.delete(token_id: "d2220fx04")
|
149
|
-
```
|
150
|
-
|
151
135
|
### Advanced personalization
|
152
136
|
|
153
137
|
```ruby
|
@@ -205,6 +189,32 @@ ms_email.add_variables(variables)
|
|
205
189
|
ms_email.send
|
206
190
|
```
|
207
191
|
|
192
|
+
## Tokens
|
193
|
+
|
194
|
+
### Create a token
|
195
|
+
```ruby
|
196
|
+
require "mailersend-ruby"
|
197
|
+
|
198
|
+
ms_tokens = Mailersend::Tokens.new
|
199
|
+
ms_tokens.create(name: "Very nice token", scopes: %w[ email_full domains_read ], domain_id: "yourdomainid")
|
200
|
+
```
|
201
|
+
|
202
|
+
### Update a token
|
203
|
+
```ruby
|
204
|
+
require "mailersend-ruby"
|
205
|
+
|
206
|
+
ms_tokens = Mailersend::Tokens.new
|
207
|
+
ms_tokens.update(token_id: "d2220fx04", status: "paused")
|
208
|
+
```
|
209
|
+
|
210
|
+
### Delete a token
|
211
|
+
```ruby
|
212
|
+
require "mailersend-ruby"
|
213
|
+
|
214
|
+
ms_tokens = Mailersend::Tokens.new
|
215
|
+
ms_tokens.delete(token_id: "d2220fx04")
|
216
|
+
```
|
217
|
+
|
208
218
|
### Send email with attachment
|
209
219
|
|
210
220
|
```ruby
|
@@ -308,6 +318,15 @@ ms_domains = Mailersend::Domains.new
|
|
308
318
|
ms_domains.delete(domain_id: "idofdomain12412")
|
309
319
|
```
|
310
320
|
|
321
|
+
### Get recipients for a domain
|
322
|
+
|
323
|
+
```ruby
|
324
|
+
require "mailersend-ruby"
|
325
|
+
|
326
|
+
ms_domains = Mailersend::Domains.new
|
327
|
+
ms_domains.recipients(domain_id: "idofdomain12412")
|
328
|
+
```
|
329
|
+
|
311
330
|
### Update domain settings
|
312
331
|
|
313
332
|
```ruby
|
@@ -366,6 +385,71 @@ ms_recipients = Mailersend::Recipients.new
|
|
366
385
|
ms_recipients.delete(recipient_id: "id124")
|
367
386
|
```
|
368
387
|
|
388
|
+
## Suppressions
|
389
|
+
|
390
|
+
### Get recipients from a suppression list
|
391
|
+
|
392
|
+
```ruby
|
393
|
+
require "mailersend-ruby"
|
394
|
+
|
395
|
+
ms_suppressions = Mailersend::Suppressions.new
|
396
|
+
|
397
|
+
// List from Blocklist
|
398
|
+
ms_suppressions.get_from_blocklist(domain_id: "xxx2241ll")
|
399
|
+
|
400
|
+
// List from Hard Bounces
|
401
|
+
ms_suppressions.get_hard_bounces(domain_id: "xxx2241ll")
|
402
|
+
|
403
|
+
// List from Spam Complaints
|
404
|
+
ms_suppressions.get_spam_complaints(domain_id: "xxx2241ll")
|
405
|
+
|
406
|
+
// List from Unsubscribers
|
407
|
+
ms_suppressions.get_unsubscribes(domain_id: "xxx2241ll")
|
408
|
+
```
|
409
|
+
|
410
|
+
### Add recipients to a suppression list
|
411
|
+
|
412
|
+
```ruby
|
413
|
+
require "mailersend-ruby"
|
414
|
+
|
415
|
+
ms_suppressions = Mailersend::Suppressions.new
|
416
|
+
|
417
|
+
// Add Recipient to Block List using recipients
|
418
|
+
ms_suppressions.add_to_blocklist(domain_id: "xxx2241ll", recipients: ["blocked@client.com"])
|
419
|
+
|
420
|
+
// Add Recipient to Block List using patterns
|
421
|
+
ms_suppressions.add_to_blocklist(domain_id: "xxx2241ll", patterns: ["*@client.com"])
|
422
|
+
|
423
|
+
// Add Recipient to Hard Bounces
|
424
|
+
ms_suppressions.add_to_hard_bounces(domain_id: "xxx2241ll", recipients: ["bounced@client.com"])
|
425
|
+
|
426
|
+
// Add Recipient to Spam Complaints
|
427
|
+
ms_suppressions.add_to_spam_complaints(domain_id: "xxx2241ll", recipients: ["bounced@client.com"])
|
428
|
+
|
429
|
+
// Add Recipient to Unsubscribes
|
430
|
+
ms_suppressions.add_to_unsubscribers(domain_id: "xxx2241ll", recipients: ["bounced@client.com"])
|
431
|
+
```
|
432
|
+
|
433
|
+
### Delete recipients from a suppression list
|
434
|
+
|
435
|
+
```ruby
|
436
|
+
require "mailersend-ruby"
|
437
|
+
|
438
|
+
ms_suppressions = Mailersend::Suppressions.new
|
439
|
+
|
440
|
+
// Delete from Block List
|
441
|
+
ms_suppressions.delete_from_blocklist(ids: ["xxx2241ll"])
|
442
|
+
|
443
|
+
// Delete from Hard Bounces
|
444
|
+
ms_suppressions.delete_from_hard_bounces(ids: ["xxx2241ll"])
|
445
|
+
|
446
|
+
// Delete from Spam Complaints
|
447
|
+
ms_suppressions.delete_from_spam_complaints(ids: ["xxx2241ll"])
|
448
|
+
|
449
|
+
// Delete from Unsubscribes
|
450
|
+
ms_suppressions.delete_from_unsubscribers(ids: ["xxx2241ll"])
|
451
|
+
```
|
452
|
+
|
369
453
|
## Webhooks
|
370
454
|
|
371
455
|
### List webhooks
|
@@ -400,6 +484,43 @@ ms_webhooks = Mailersend::Webhooks.new
|
|
400
484
|
ms_webhooks.update(webhook_id: "zzz2241ll", enabled: false)
|
401
485
|
```
|
402
486
|
|
487
|
+
### Delete a webhook
|
488
|
+
```ruby
|
489
|
+
require "mailersend-ruby"
|
490
|
+
|
491
|
+
ms_webhooks = Mailersend::Webhooks.new
|
492
|
+
ms_webhooks.delete(webhook_id: "zzz2241ll")
|
493
|
+
```
|
494
|
+
|
495
|
+
## Templates
|
496
|
+
|
497
|
+
### Get templates
|
498
|
+
|
499
|
+
```ruby
|
500
|
+
require "mailersend-ruby"
|
501
|
+
|
502
|
+
ms_templates = Mailersend::Templates.new
|
503
|
+
ms_templates.list(domain_id: "aax455lll", page: 1, limit: 10)
|
504
|
+
```
|
505
|
+
|
506
|
+
### Get a single template
|
507
|
+
|
508
|
+
```ruby
|
509
|
+
require "mailersend-ruby"
|
510
|
+
|
511
|
+
ms_templates = Mailersend::Templates.new
|
512
|
+
ms_templates.single(template_id: "id124")
|
513
|
+
```
|
514
|
+
|
515
|
+
### Delete template
|
516
|
+
|
517
|
+
```ruby
|
518
|
+
require "mailersend-ruby"
|
519
|
+
|
520
|
+
ms_templates = Mailersend::Templates.new
|
521
|
+
ms_templates.delete(template_id: "id124")
|
522
|
+
```
|
523
|
+
|
403
524
|
# Support and Feedback
|
404
525
|
|
405
526
|
In case you find any bugs, submit an issue directly here in GitHub.
|
@@ -412,4 +533,4 @@ The official documentation is at [https://developers.mailersend.com](https://dev
|
|
412
533
|
|
413
534
|
# License
|
414
535
|
|
415
|
-
[The MIT License (MIT)](LICENSE)
|
536
|
+
[The MIT License (MIT)](LICENSE)
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require
|
5
|
-
require_relative
|
4
|
+
require 'bundler/setup'
|
5
|
+
require_relative '../lib/mailersend/version'
|
6
6
|
|
7
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
8
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -11,5 +11,5 @@ require_relative "../lib/mailersend/version"
|
|
11
11
|
# require "pry"
|
12
12
|
# Pry.start
|
13
13
|
|
14
|
-
require
|
14
|
+
require 'irb'
|
15
15
|
IRB.start(__FILE__)
|
@@ -14,27 +14,27 @@ module Mailersend
|
|
14
14
|
|
15
15
|
def initialize(client = Mailersend::Client.new)
|
16
16
|
@client = client
|
17
|
-
@date_from =
|
18
|
-
@date_to =
|
17
|
+
@date_from = ''
|
18
|
+
@date_to = ''
|
19
19
|
@events = []
|
20
|
-
@domain_id =
|
21
|
-
@recipient_id =
|
22
|
-
@group_by =
|
20
|
+
@domain_id = ''
|
21
|
+
@recipient_id = ''
|
22
|
+
@group_by = ''
|
23
23
|
@tags = []
|
24
24
|
end
|
25
25
|
|
26
26
|
def date(date_from:, date_to:, events:, domain_id: nil, recipient_id: nil, group_by: nil, tags: nil)
|
27
27
|
hash = {
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
28
|
+
'date_from' => date_from,
|
29
|
+
'date_to' => date_to,
|
30
|
+
'event[]' => events,
|
31
|
+
'domain_id' => domain_id,
|
32
|
+
'recipient_id' => recipient_id,
|
33
|
+
'group_by' => group_by,
|
34
|
+
'tags[]' => tags
|
35
35
|
}
|
36
36
|
|
37
|
-
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path:
|
37
|
+
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/analytics/date',
|
38
38
|
query: URI.encode_www_form(hash.compact)))
|
39
39
|
puts response
|
40
40
|
end
|
@@ -45,10 +45,10 @@ module Mailersend
|
|
45
45
|
recipient_id: recipient_id,
|
46
46
|
date_from: date_from,
|
47
47
|
date_to: date_to,
|
48
|
-
|
48
|
+
'tags[]': tags
|
49
49
|
}
|
50
50
|
|
51
|
-
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path:
|
51
|
+
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/analytics/country',
|
52
52
|
query: URI.encode_www_form(hash.compact)))
|
53
53
|
puts response
|
54
54
|
end
|
@@ -59,10 +59,10 @@ module Mailersend
|
|
59
59
|
recipient_id: recipient_id,
|
60
60
|
date_from: date_from,
|
61
61
|
date_to: date_to,
|
62
|
-
|
62
|
+
'tags[]': tags
|
63
63
|
}
|
64
64
|
|
65
|
-
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path:
|
65
|
+
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/analytics/ua-name',
|
66
66
|
query: URI.encode_www_form(hash.compact)))
|
67
67
|
puts response
|
68
68
|
end
|
@@ -73,10 +73,10 @@ module Mailersend
|
|
73
73
|
recipient_id: recipient_id,
|
74
74
|
date_from: date_from,
|
75
75
|
date_to: date_to,
|
76
|
-
|
76
|
+
'tags[]': tags
|
77
77
|
}
|
78
78
|
|
79
|
-
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path:
|
79
|
+
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/analytics/ua-type',
|
80
80
|
query: URI.encode_www_form(hash.compact)))
|
81
81
|
puts response
|
82
82
|
end
|
data/lib/mailersend/client.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'http'
|
4
|
+
require 'dotenv/load'
|
5
5
|
|
6
|
-
API_URL =
|
7
|
-
API_BASE_HOST =
|
6
|
+
API_URL = 'https://api.mailersend.com/v1'
|
7
|
+
API_BASE_HOST = 'api.mailersend.com'
|
8
8
|
|
9
|
-
Dotenv.require_keys(
|
9
|
+
Dotenv.require_keys('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['API_TOKEN'])
|
18
18
|
@api_token = api_token
|
19
19
|
end
|
20
20
|
|
@@ -22,8 +22,8 @@ module Mailersend
|
|
22
22
|
HTTP
|
23
23
|
.timeout(connect: 15, read: 30)
|
24
24
|
.auth("Bearer #{@api_token}")
|
25
|
-
.headers(
|
26
|
-
|
25
|
+
.headers('User-Agent' => 'MailerSend-client-ruby/1.0.0',
|
26
|
+
'Accept' => 'application/json')
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -19,20 +19,20 @@ module Mailersend
|
|
19
19
|
|
20
20
|
def list(page: nil, limit: nil, verified: nil)
|
21
21
|
hash = {
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
'page' => page,
|
23
|
+
'limit' => limit,
|
24
|
+
'verified' => verified
|
25
25
|
}
|
26
|
-
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path:
|
26
|
+
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/domains',
|
27
27
|
query: URI.encode_www_form(hash.compact)))
|
28
28
|
puts response
|
29
29
|
end
|
30
30
|
|
31
31
|
def single(domain_id:, page: nil, limit: nil, verified: nil)
|
32
32
|
hash = {
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
'page' => page,
|
34
|
+
'limit' => limit,
|
35
|
+
'verified' => verified
|
36
36
|
}
|
37
37
|
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/domains/#{domain_id}",
|
38
38
|
query: URI.encode_www_form(hash.compact)))
|
@@ -46,8 +46,8 @@ module Mailersend
|
|
46
46
|
|
47
47
|
def recipients(domain_id:)
|
48
48
|
hash = {
|
49
|
-
|
50
|
-
|
49
|
+
'page' => page,
|
50
|
+
'limit' => limit
|
51
51
|
}
|
52
52
|
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/domains/#{domain_id}/recipients",
|
53
53
|
query: URI.encode_www_form(hash.compact)))
|
@@ -56,15 +56,15 @@ module Mailersend
|
|
56
56
|
|
57
57
|
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)
|
58
58
|
hash = {
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
59
|
+
'send_paused' => send_paused,
|
60
|
+
'track_clicks' => track_clicks,
|
61
|
+
'track_opens' => track_opens,
|
62
|
+
'track_unsubscribe' => track_unsubscribe,
|
63
|
+
'track_unsubscribe_html' => track_unsubscribe_html,
|
64
|
+
'track_unsubscribe_plain' => track_unsubscribe_plain,
|
65
|
+
'track_content' => track_content,
|
66
|
+
'custom_tracking_enabled' => custom_tracking_enabled,
|
67
|
+
'custom_tracking_subdomain' => custom_tracking_subdomain
|
68
68
|
}
|
69
69
|
response = client.http.put("#{API_URL}/domains/#{domain_id}/settings", json: hash.compact)
|
70
70
|
puts response
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require 'base64'
|
4
4
|
|
5
5
|
module Mailersend
|
6
6
|
# Send an email through MailerSend API
|
@@ -52,8 +52,8 @@ module Mailersend
|
|
52
52
|
@bcc << bcc
|
53
53
|
end
|
54
54
|
|
55
|
-
def add_reply_to(
|
56
|
-
@reply_to =
|
55
|
+
def add_reply_to(reply_to)
|
56
|
+
@reply_to = reply_to
|
57
57
|
end
|
58
58
|
|
59
59
|
def add_subject(subject)
|
@@ -87,29 +87,29 @@ module Mailersend
|
|
87
87
|
def add_attachment(content:, filename:)
|
88
88
|
data = File.open(content.to_s).read
|
89
89
|
encoded = Base64.strict_encode64(data)
|
90
|
-
attachments << {
|
91
|
-
|
92
|
-
|
90
|
+
@attachments << {
|
91
|
+
'content' => encoded,
|
92
|
+
'filename' => filename
|
93
93
|
}
|
94
94
|
end
|
95
95
|
|
96
96
|
def send
|
97
97
|
message = {
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
98
|
+
'from' => @from,
|
99
|
+
'to' => @recipients,
|
100
|
+
'cc' => @ccs,
|
101
|
+
'bcc' => @bcc,
|
102
|
+
'reply_to' => @reply_to,
|
103
|
+
'subject' => @subject,
|
104
|
+
'text' => @text,
|
105
|
+
'html' => @html,
|
106
|
+
'variables' => @variables,
|
107
|
+
'personalization' => @personalization,
|
108
|
+
'template_id' => @template_id,
|
109
|
+
'attachments' => @attachments
|
110
110
|
}
|
111
111
|
|
112
|
-
response = client.http.post("#{API_URL}/email", json: message.
|
112
|
+
response = client.http.post("#{API_URL}/email", json: message.delete_if { |_, value| value.to_s.strip == '' || value == [] || value == {} })
|
113
113
|
puts response
|
114
114
|
puts response.status.code
|
115
115
|
end
|
@@ -17,11 +17,11 @@ module Mailersend
|
|
17
17
|
|
18
18
|
def list(page: nil, limit: nil)
|
19
19
|
hash = {
|
20
|
-
|
21
|
-
|
20
|
+
'page' => page,
|
21
|
+
'limit' => limit
|
22
22
|
}
|
23
23
|
|
24
|
-
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path:
|
24
|
+
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/messages',
|
25
25
|
query: URI.encode_www_form(hash)))
|
26
26
|
puts response
|
27
27
|
end
|
@@ -17,11 +17,11 @@ module Mailersend
|
|
17
17
|
|
18
18
|
def list(page: nil, limit: nil)
|
19
19
|
hash = {
|
20
|
-
|
21
|
-
|
20
|
+
'page' => page,
|
21
|
+
'limit' => limit
|
22
22
|
}
|
23
23
|
|
24
|
-
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path:
|
24
|
+
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/recipients',
|
25
25
|
query: URI.encode_www_form(hash)))
|
26
26
|
puts response
|
27
27
|
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Mailersend
|
4
|
+
# Suppressions endpoint from MailerSend API.
|
5
|
+
class Suppressions
|
6
|
+
attr_accessor :client,
|
7
|
+
:page,
|
8
|
+
:limit,
|
9
|
+
:recipient_id
|
10
|
+
|
11
|
+
def initialize(client = Mailersend::Client.new)
|
12
|
+
@client = client
|
13
|
+
@page = page
|
14
|
+
@limit = limit
|
15
|
+
@recipient_id = recipient_id
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_from_blocklist(*)
|
19
|
+
response = client.http.get("#{API_URL}/suppressions/blocklist")
|
20
|
+
puts response
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_hard_bounces(*)
|
24
|
+
response = client.http.get("#{API_URL}/suppressions/hard-bounces")
|
25
|
+
puts response
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_spam_complaints(*)
|
29
|
+
response = client.http.get("#{API_URL}/suppressions/spam-complaints")
|
30
|
+
puts response
|
31
|
+
end
|
32
|
+
|
33
|
+
def get_unsubscribes(*)
|
34
|
+
response = client.http.get("#{API_URL}/suppressions/unsubscribes")
|
35
|
+
puts response
|
36
|
+
end
|
37
|
+
|
38
|
+
def add_to_blocklist(recipients: nil, patterns: nil)
|
39
|
+
hash = {
|
40
|
+
'recipients' => recipients,
|
41
|
+
'patterns' => patterns
|
42
|
+
}
|
43
|
+
response = client.http.post("#{API_URL}/suppressions/blocklist", json: hash.compact)
|
44
|
+
puts response
|
45
|
+
end
|
46
|
+
|
47
|
+
def delete_from_blocklist(ids: nil, all: nil)
|
48
|
+
hash = {
|
49
|
+
'ids' => ids,
|
50
|
+
'all' => all
|
51
|
+
}
|
52
|
+
response = client.http.delete("#{API_URL}/suppressions/blocklist", json: hash.compact)
|
53
|
+
puts response
|
54
|
+
end
|
55
|
+
|
56
|
+
def add_to_hard_bounces(domain_id: nil, recipients: nil)
|
57
|
+
hash = {
|
58
|
+
'domain_id' => domain_id,
|
59
|
+
'recipients' => recipients
|
60
|
+
}
|
61
|
+
response = client.http.post("#{API_URL}/suppressions/hard-bounces", json: hash.compact)
|
62
|
+
puts response
|
63
|
+
end
|
64
|
+
|
65
|
+
def delete_from_hard_bounces(ids: nil, all: nil)
|
66
|
+
hash = {
|
67
|
+
'ids' => ids,
|
68
|
+
'all' => all
|
69
|
+
}
|
70
|
+
response = client.http.delete("#{API_URL}/suppressions/hard-bounces", json: hash.compact)
|
71
|
+
puts response
|
72
|
+
end
|
73
|
+
|
74
|
+
def add_to_spam_complaints(domain_id: nil, recipients: nil)
|
75
|
+
hash = {
|
76
|
+
'domain_id' => domain_id,
|
77
|
+
'recipients' => recipients
|
78
|
+
}
|
79
|
+
response = client.http.post("#{API_URL}/suppressions/spam-complaints", json: hash.compact)
|
80
|
+
puts response
|
81
|
+
end
|
82
|
+
|
83
|
+
def delete_from_spam_complaints(ids: nil, all: nil)
|
84
|
+
hash = {
|
85
|
+
'ids' => ids,
|
86
|
+
'all' => all
|
87
|
+
}
|
88
|
+
response = client.http.delete("#{API_URL}/suppressions/spam-complaints", json: hash.compact)
|
89
|
+
puts response
|
90
|
+
end
|
91
|
+
|
92
|
+
def add_to_unsubscribers(domain_id: nil, recipients: nil)
|
93
|
+
hash = {
|
94
|
+
'domain_id' => domain_id,
|
95
|
+
'recipients' => recipients
|
96
|
+
}
|
97
|
+
response = client.http.post("#{API_URL}/suppressions/unsubscribes", json: hash.compact)
|
98
|
+
puts response
|
99
|
+
end
|
100
|
+
|
101
|
+
def delete_from_unsubscribers(ids: nil, all: nil)
|
102
|
+
hash = {
|
103
|
+
'ids' => ids,
|
104
|
+
'all' => all
|
105
|
+
}
|
106
|
+
response = client.http.delete("#{API_URL}/suppressions/unsubscribes", json: hash.compact)
|
107
|
+
puts response
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Mailersend
|
4
|
+
# Templates endpoint from MailerSend API.
|
5
|
+
class Templates
|
6
|
+
attr_accessor :client,
|
7
|
+
:page,
|
8
|
+
:limit,
|
9
|
+
:template_id
|
10
|
+
|
11
|
+
def initialize(client = Mailersend::Client.new)
|
12
|
+
@client = client
|
13
|
+
@page = page
|
14
|
+
@limit = limit
|
15
|
+
@template_id = template_id
|
16
|
+
end
|
17
|
+
|
18
|
+
def list(domain_id: nil, page: nil, limit: nil)
|
19
|
+
hash = {
|
20
|
+
'domain_id' => domain_id,
|
21
|
+
'page' => page,
|
22
|
+
'limit' => limit
|
23
|
+
}
|
24
|
+
|
25
|
+
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/templates',
|
26
|
+
query: URI.encode_www_form(hash)))
|
27
|
+
puts response
|
28
|
+
end
|
29
|
+
|
30
|
+
def single(template_id:)
|
31
|
+
response = client.http.get("#{API_URL}/templates/#{template_id}")
|
32
|
+
puts response
|
33
|
+
end
|
34
|
+
|
35
|
+
def delete(template_id:)
|
36
|
+
response = client.http.delete("#{API_URL}/templates/#{template_id}")
|
37
|
+
puts response
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -19,9 +19,9 @@ module Mailersend
|
|
19
19
|
|
20
20
|
def create(name:, scopes:, domain_id:)
|
21
21
|
json = {
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
'name' => name,
|
23
|
+
'scopes' => scopes,
|
24
|
+
'domain_id' => domain_id
|
25
25
|
}
|
26
26
|
response = client.http.post("#{API_URL}/token", json: json)
|
27
27
|
puts response
|
data/lib/mailersend/version.rb
CHANGED
@@ -22,9 +22,9 @@ module Mailersend
|
|
22
22
|
|
23
23
|
def list(domain_id:)
|
24
24
|
hash = {
|
25
|
-
|
25
|
+
'domain_id' => domain_id
|
26
26
|
}
|
27
|
-
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path:
|
27
|
+
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/webhooks',
|
28
28
|
query: URI.encode_www_form(hash)))
|
29
29
|
puts response
|
30
30
|
end
|
@@ -36,11 +36,11 @@ module Mailersend
|
|
36
36
|
|
37
37
|
def create(url:, name:, events:, domain_id:, enabled: nil)
|
38
38
|
hash = {
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
'url' => url,
|
40
|
+
'name' => name,
|
41
|
+
'events' => events,
|
42
|
+
'domain_id' => domain_id,
|
43
|
+
'enabled' => enabled.to_s == 'true'
|
44
44
|
}
|
45
45
|
|
46
46
|
response = client.http.post("#{API_URL}/webhooks", json: hash.compact)
|
@@ -49,10 +49,10 @@ module Mailersend
|
|
49
49
|
|
50
50
|
def update(webhook_id:, url: nil, name: nil, events: nil, enabled: nil)
|
51
51
|
hash = {
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
52
|
+
'url' => url,
|
53
|
+
'name' => name,
|
54
|
+
'events' => events,
|
55
|
+
'enabled' => enabled.to_s == 'true'
|
56
56
|
}
|
57
57
|
response = client.http.put("#{API_URL}/webhooks/#{webhook_id}", json: hash.compact)
|
58
58
|
puts response
|
data/lib/mailersend-ruby.rb
CHANGED
data/lib/mailersend.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
3
|
+
require_relative 'mailersend/client'
|
4
|
+
require_relative 'mailersend/activity/activity'
|
5
|
+
require_relative 'mailersend/analytics/analytics'
|
6
|
+
require_relative 'mailersend/domains/domains'
|
7
|
+
require_relative 'mailersend/email/email'
|
8
|
+
require_relative 'mailersend/messages/messages'
|
9
|
+
require_relative 'mailersend/recipients/recipients'
|
10
|
+
require_relative 'mailersend/suppressions/suppressions'
|
11
|
+
require_relative 'mailersend/templates/templates'
|
12
|
+
require_relative 'mailersend/tokens/tokens'
|
13
|
+
require_relative 'mailersend/webhooks/webhooks'
|
data/mailersend-ruby.gemspec
CHANGED
@@ -1,36 +1,36 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
lib = File.expand_path(
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require
|
5
|
+
require 'mailersend/version'
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
|
-
spec.name =
|
8
|
+
spec.name = 'mailersend-ruby'
|
9
9
|
spec.version = Mailersend::VERSION
|
10
|
-
spec.authors = [
|
11
|
-
spec.email = [
|
10
|
+
spec.authors = ['Nikola Milojević']
|
11
|
+
spec.email = ['info@mailersend.com']
|
12
12
|
|
13
13
|
spec.summary = "MailerSend's official Ruby SDK"
|
14
14
|
spec.description = "MailerSend's official Ruby SDK. Interacts with all endpoints at MailerSend API."
|
15
|
-
spec.homepage =
|
16
|
-
spec.license =
|
17
|
-
spec.required_ruby_version =
|
15
|
+
spec.homepage = 'https://www.mailersend.com'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
spec.required_ruby_version = '>= 2.5.0'
|
18
18
|
|
19
|
-
spec.metadata[
|
19
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
20
20
|
|
21
|
-
spec.metadata[
|
22
|
-
spec.metadata[
|
23
|
-
spec.metadata[
|
21
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
22
|
+
spec.metadata['source_code_uri'] = 'https://github.com/mailersend/mailersend-ruby'
|
23
|
+
spec.metadata['changelog_uri'] = 'https://github.com/mailersend/mailersend-ruby/blob/main/CHANGELOG.md'
|
24
24
|
|
25
25
|
spec.files = `git ls-files -z`.split("\x0")
|
26
26
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
27
|
-
spec.require_paths = [
|
27
|
+
spec.require_paths = ['lib']
|
28
28
|
|
29
|
-
spec.add_development_dependency
|
30
|
-
spec.add_development_dependency
|
31
|
-
spec.add_development_dependency
|
32
|
-
spec.add_dependency
|
33
|
-
spec.add_dependency
|
34
|
-
spec.add_dependency
|
35
|
-
spec.add_dependency
|
29
|
+
spec.add_development_dependency 'bundler', '~> 2.2.15'
|
30
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
31
|
+
spec.add_development_dependency 'rubocop', '~> 1.7'
|
32
|
+
spec.add_dependency 'dotenv', '~> 2.7'
|
33
|
+
spec.add_dependency 'http', '~> 5.0'
|
34
|
+
spec.add_dependency 'json', '~> 2.5'
|
35
|
+
spec.add_dependency 'uri', '~> 0.10.1'
|
36
36
|
end
|
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: 0.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nikola Milojević
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -138,10 +138,13 @@ files:
|
|
138
138
|
- lib/mailersend/email/email.rb
|
139
139
|
- lib/mailersend/messages/messages.rb
|
140
140
|
- lib/mailersend/recipients/recipients.rb
|
141
|
+
- lib/mailersend/suppressions/suppressions.rb
|
142
|
+
- lib/mailersend/templates/templates.rb
|
141
143
|
- lib/mailersend/tokens/tokens.rb
|
142
144
|
- lib/mailersend/version.rb
|
143
145
|
- lib/mailersend/webhooks/webhooks.rb
|
144
146
|
- mailersend-ruby.gemspec
|
147
|
+
- renovate.json
|
145
148
|
homepage: https://www.mailersend.com
|
146
149
|
licenses:
|
147
150
|
- MIT
|
@@ -165,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
168
|
- !ruby/object:Gem::Version
|
166
169
|
version: '0'
|
167
170
|
requirements: []
|
168
|
-
rubygems_version: 3.2.
|
171
|
+
rubygems_version: 3.2.31
|
169
172
|
signing_key:
|
170
173
|
specification_version: 4
|
171
174
|
summary: MailerSend's official Ruby SDK
|