mailersend-ruby 3.0.0 → 3.1.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 +1 -1
- data/.github/workflows/publish_gem.yml +1 -1
- data/CHANGELOG.md +6 -0
- data/README.md +111 -0
- data/fixtures/dmarc_monitoring/add_favorite.yml +31 -0
- data/fixtures/dmarc_monitoring/create.yml +34 -0
- data/fixtures/dmarc_monitoring/delete.yml +31 -0
- data/fixtures/dmarc_monitoring/list.yml +32 -0
- data/fixtures/dmarc_monitoring/remove_favorite.yml +31 -0
- data/fixtures/dmarc_monitoring/report.yml +31 -0
- data/fixtures/dmarc_monitoring/report_by_ip.yml +31 -0
- data/fixtures/dmarc_monitoring/report_sources.yml +31 -0
- data/fixtures/dmarc_monitoring/update.yml +34 -0
- data/lib/mailersend/dmarc_monitoring/dmarc_monitoring.rb +59 -0
- data/lib/mailersend/email/email.rb +14 -0
- data/lib/mailersend/version.rb +1 -1
- data/lib/mailersend.rb +1 -0
- data/spec/dmarc_monitoring_rspec.rb +100 -0
- metadata +14 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9b3bfbc4f6cab77294426741f5420ade91c52721573bd3885d384ccbcceb9045
|
|
4
|
+
data.tar.gz: e9c86c9b59c128fb303c7a28c39282d17b4c14f27c1503ed8495098e16387b45
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 24128c89d8b0206843c001f438c6258acb29a9319ffa63819c7d4390040efb9b344402442af1379dad411e16724abe3f021eb4b1029e2607a26026cfb87cd24e
|
|
7
|
+
data.tar.gz: 05652e0beb32b924ad15e2c3f251ac3b5659853172d1bdafa35c8ad4d01d0e558b4c06744285bd5a7830ff51fdc388706a5dd3013dbfd846d6471606ad90886d
|
data/.github/workflows/main.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
## [Released]
|
|
2
2
|
|
|
3
|
+
## [3.1.0] - 2026-04-24
|
|
4
|
+
- DMARC Monitoring support (list, create, update, delete monitors; aggregated reports, IP-specific reports, report sources, mark/remove IP favorites)
|
|
5
|
+
|
|
6
|
+
## [3.0.1] - 2025-04-10
|
|
7
|
+
- Adding missing parameters
|
|
8
|
+
|
|
3
9
|
## [3.0.0] - 2024-12-20
|
|
4
10
|
- *BREAKING CHANGE* - Updated the minimal required Ruby version from 2.5 to 3.1
|
|
5
11
|
- Adding tests
|
data/README.md
CHANGED
|
@@ -42,6 +42,16 @@ MailerSend Ruby SDK
|
|
|
42
42
|
- [Update domain settings](#update-domain-settings)
|
|
43
43
|
- [Get DNS Records](#get-dns-records)
|
|
44
44
|
- [Get verification status](#get-verification-status)
|
|
45
|
+
- [DMARC Monitoring](#dmarc-monitoring)
|
|
46
|
+
- [Get a list of monitors](#get-a-list-of-monitors)
|
|
47
|
+
- [Create a monitor](#create-a-monitor)
|
|
48
|
+
- [Update a monitor](#update-a-monitor)
|
|
49
|
+
- [Delete a monitor](#delete-a-monitor)
|
|
50
|
+
- [Get aggregated reports](#get-aggregated-reports)
|
|
51
|
+
- [Get IP-specific reports](#get-ip-specific-reports)
|
|
52
|
+
- [Get report sources](#get-report-sources)
|
|
53
|
+
- [Mark IP as favorite](#mark-ip-as-favorite)
|
|
54
|
+
- [Remove IP from favorites](#remove-ip-from-favorites)
|
|
45
55
|
- [Sender Identities](#sender-identities)
|
|
46
56
|
- [Get a list of sender identities](#get-a-list-of-sender-identities)
|
|
47
57
|
- [Get a single sender identity](#get-a-single-sender-identity)
|
|
@@ -544,6 +554,107 @@ ms_domains = Mailersend::Domains.new(ms_client)
|
|
|
544
554
|
ms_domains.verify(domain_id: "idofdomain12412")
|
|
545
555
|
```
|
|
546
556
|
|
|
557
|
+
## DMARC Monitoring
|
|
558
|
+
|
|
559
|
+
### Get a list of monitors
|
|
560
|
+
|
|
561
|
+
```ruby
|
|
562
|
+
require "mailersend-ruby"
|
|
563
|
+
|
|
564
|
+
ms_client = Mailersend::Client.new('your_mailersend_token')
|
|
565
|
+
|
|
566
|
+
ms_dmarc = Mailersend::DmarcMonitoring.new(ms_client)
|
|
567
|
+
ms_dmarc.list
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
### Create a monitor
|
|
571
|
+
|
|
572
|
+
```ruby
|
|
573
|
+
require "mailersend-ruby"
|
|
574
|
+
|
|
575
|
+
ms_client = Mailersend::Client.new('your_mailersend_token')
|
|
576
|
+
|
|
577
|
+
ms_dmarc = Mailersend::DmarcMonitoring.new(ms_client)
|
|
578
|
+
ms_dmarc.create(domain_id: "idofdomain12412")
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
### Update a monitor
|
|
582
|
+
|
|
583
|
+
```ruby
|
|
584
|
+
require "mailersend-ruby"
|
|
585
|
+
|
|
586
|
+
ms_client = Mailersend::Client.new('your_mailersend_token')
|
|
587
|
+
|
|
588
|
+
ms_dmarc = Mailersend::DmarcMonitoring.new(ms_client)
|
|
589
|
+
ms_dmarc.update(monitor_id: "idofmonitor12412", wanted_dmarc_record: "v=DMARC1; p=reject;")
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
### Delete a monitor
|
|
593
|
+
|
|
594
|
+
```ruby
|
|
595
|
+
require "mailersend-ruby"
|
|
596
|
+
|
|
597
|
+
ms_client = Mailersend::Client.new('your_mailersend_token')
|
|
598
|
+
|
|
599
|
+
ms_dmarc = Mailersend::DmarcMonitoring.new(ms_client)
|
|
600
|
+
ms_dmarc.delete(monitor_id: "idofmonitor12412")
|
|
601
|
+
```
|
|
602
|
+
|
|
603
|
+
### Get aggregated reports
|
|
604
|
+
|
|
605
|
+
```ruby
|
|
606
|
+
require "mailersend-ruby"
|
|
607
|
+
|
|
608
|
+
ms_client = Mailersend::Client.new('your_mailersend_token')
|
|
609
|
+
|
|
610
|
+
ms_dmarc = Mailersend::DmarcMonitoring.new(ms_client)
|
|
611
|
+
ms_dmarc.report(monitor_id: "idofmonitor12412")
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
### Get IP-specific reports
|
|
615
|
+
|
|
616
|
+
```ruby
|
|
617
|
+
require "mailersend-ruby"
|
|
618
|
+
|
|
619
|
+
ms_client = Mailersend::Client.new('your_mailersend_token')
|
|
620
|
+
|
|
621
|
+
ms_dmarc = Mailersend::DmarcMonitoring.new(ms_client)
|
|
622
|
+
ms_dmarc.report_by_ip(monitor_id: "idofmonitor12412", ip: "1.2.3.4")
|
|
623
|
+
```
|
|
624
|
+
|
|
625
|
+
### Get report sources
|
|
626
|
+
|
|
627
|
+
```ruby
|
|
628
|
+
require "mailersend-ruby"
|
|
629
|
+
|
|
630
|
+
ms_client = Mailersend::Client.new('your_mailersend_token')
|
|
631
|
+
|
|
632
|
+
ms_dmarc = Mailersend::DmarcMonitoring.new(ms_client)
|
|
633
|
+
ms_dmarc.report_sources(monitor_id: "idofmonitor12412")
|
|
634
|
+
```
|
|
635
|
+
|
|
636
|
+
### Mark IP as favorite
|
|
637
|
+
|
|
638
|
+
```ruby
|
|
639
|
+
require "mailersend-ruby"
|
|
640
|
+
|
|
641
|
+
ms_client = Mailersend::Client.new('your_mailersend_token')
|
|
642
|
+
|
|
643
|
+
ms_dmarc = Mailersend::DmarcMonitoring.new(ms_client)
|
|
644
|
+
ms_dmarc.add_favorite(monitor_id: "idofmonitor12412", ip: "1.2.3.4")
|
|
645
|
+
```
|
|
646
|
+
|
|
647
|
+
### Remove IP from favorites
|
|
648
|
+
|
|
649
|
+
```ruby
|
|
650
|
+
require "mailersend-ruby"
|
|
651
|
+
|
|
652
|
+
ms_client = Mailersend::Client.new('your_mailersend_token')
|
|
653
|
+
|
|
654
|
+
ms_dmarc = Mailersend::DmarcMonitoring.new(ms_client)
|
|
655
|
+
ms_dmarc.remove_favorite(monitor_id: "idofmonitor12412", ip: "1.2.3.4")
|
|
656
|
+
```
|
|
657
|
+
|
|
547
658
|
## Sender Identities
|
|
548
659
|
|
|
549
660
|
### Get a list of sender identities
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: put
|
|
5
|
+
uri: https://api.mailersend.com/v1/dmarc-monitoring/example_monitor_id/favorite/1.2.3.4
|
|
6
|
+
body:
|
|
7
|
+
encoding: UTF-8
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
Authorization:
|
|
11
|
+
- "<AUTH>"
|
|
12
|
+
User-Agent:
|
|
13
|
+
- MailerSend-client-ruby/3.0.1
|
|
14
|
+
Accept:
|
|
15
|
+
- application/json
|
|
16
|
+
Connection:
|
|
17
|
+
- close
|
|
18
|
+
Host:
|
|
19
|
+
- api.mailersend.com
|
|
20
|
+
response:
|
|
21
|
+
status:
|
|
22
|
+
code: 200
|
|
23
|
+
message: OK
|
|
24
|
+
headers:
|
|
25
|
+
Content-Type:
|
|
26
|
+
- application/json
|
|
27
|
+
body:
|
|
28
|
+
encoding: UTF-8
|
|
29
|
+
string: ''
|
|
30
|
+
recorded_at: Mon, 01 Jan 2024 00:00:00 GMT
|
|
31
|
+
recorded_with: VCR 6.3.1
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: post
|
|
5
|
+
uri: https://api.mailersend.com/v1/dmarc-monitoring
|
|
6
|
+
body:
|
|
7
|
+
encoding: UTF-8
|
|
8
|
+
string: '{"domain_id":"example_domain_id"}'
|
|
9
|
+
headers:
|
|
10
|
+
Authorization:
|
|
11
|
+
- "<AUTH>"
|
|
12
|
+
User-Agent:
|
|
13
|
+
- MailerSend-client-ruby/3.0.1
|
|
14
|
+
Accept:
|
|
15
|
+
- application/json
|
|
16
|
+
Connection:
|
|
17
|
+
- close
|
|
18
|
+
Content-Type:
|
|
19
|
+
- application/json; charset=utf-8
|
|
20
|
+
Host:
|
|
21
|
+
- api.mailersend.com
|
|
22
|
+
response:
|
|
23
|
+
status:
|
|
24
|
+
code: 201
|
|
25
|
+
message: Created
|
|
26
|
+
headers:
|
|
27
|
+
Content-Type:
|
|
28
|
+
- application/json
|
|
29
|
+
body:
|
|
30
|
+
encoding: UTF-8
|
|
31
|
+
string: '{"data":{"id":"example_monitor_id","dmarc_record":"v=DMARC1; p=none;","wanted_dmarc_record":null,"dmarc_record_valid":false,"spf_record":"v=spf1
|
|
32
|
+
include:spf.example.com ~all","spf_record_valid":true,"domain":{"id":"example_domain_id","name":"example.com"},"created_at":"2024-01-01T00:00:00.000000Z","updated_at":"2024-01-01T00:00:00.000000Z"}}'
|
|
33
|
+
recorded_at: Mon, 01 Jan 2024 00:00:00 GMT
|
|
34
|
+
recorded_with: VCR 6.3.1
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: delete
|
|
5
|
+
uri: https://api.mailersend.com/v1/dmarc-monitoring/example_monitor_id
|
|
6
|
+
body:
|
|
7
|
+
encoding: UTF-8
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
Authorization:
|
|
11
|
+
- "<AUTH>"
|
|
12
|
+
User-Agent:
|
|
13
|
+
- MailerSend-client-ruby/3.0.1
|
|
14
|
+
Accept:
|
|
15
|
+
- application/json
|
|
16
|
+
Connection:
|
|
17
|
+
- close
|
|
18
|
+
Host:
|
|
19
|
+
- api.mailersend.com
|
|
20
|
+
response:
|
|
21
|
+
status:
|
|
22
|
+
code: 204
|
|
23
|
+
message: No Content
|
|
24
|
+
headers:
|
|
25
|
+
Content-Type:
|
|
26
|
+
- application/json
|
|
27
|
+
body:
|
|
28
|
+
encoding: UTF-8
|
|
29
|
+
string: ''
|
|
30
|
+
recorded_at: Mon, 01 Jan 2024 00:00:00 GMT
|
|
31
|
+
recorded_with: VCR 6.3.1
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: https://api.mailersend.com/v1/dmarc-monitoring
|
|
6
|
+
body:
|
|
7
|
+
encoding: UTF-8
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
Authorization:
|
|
11
|
+
- "<AUTH>"
|
|
12
|
+
User-Agent:
|
|
13
|
+
- MailerSend-client-ruby/3.0.1
|
|
14
|
+
Accept:
|
|
15
|
+
- application/json
|
|
16
|
+
Connection:
|
|
17
|
+
- close
|
|
18
|
+
Host:
|
|
19
|
+
- api.mailersend.com
|
|
20
|
+
response:
|
|
21
|
+
status:
|
|
22
|
+
code: 200
|
|
23
|
+
message: OK
|
|
24
|
+
headers:
|
|
25
|
+
Content-Type:
|
|
26
|
+
- application/json
|
|
27
|
+
body:
|
|
28
|
+
encoding: UTF-8
|
|
29
|
+
string: '{"data":[{"id":"example_monitor_id","dmarc_record":"v=DMARC1; p=none;","wanted_dmarc_record":"v=DMARC1;
|
|
30
|
+
p=reject;","dmarc_record_valid":false,"spf_record":"v=spf1 include:spf.example.com ~all","spf_record_valid":true,"domain":{"id":"example_domain_id","name":"example.com"},"created_at":"2024-01-01T00:00:00.000000Z","updated_at":"2024-01-01T00:00:00.000000Z"}]}'
|
|
31
|
+
recorded_at: Mon, 01 Jan 2024 00:00:00 GMT
|
|
32
|
+
recorded_with: VCR 6.3.1
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: delete
|
|
5
|
+
uri: https://api.mailersend.com/v1/dmarc-monitoring/example_monitor_id/favorite/1.2.3.4
|
|
6
|
+
body:
|
|
7
|
+
encoding: UTF-8
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
Authorization:
|
|
11
|
+
- "<AUTH>"
|
|
12
|
+
User-Agent:
|
|
13
|
+
- MailerSend-client-ruby/3.0.1
|
|
14
|
+
Accept:
|
|
15
|
+
- application/json
|
|
16
|
+
Connection:
|
|
17
|
+
- close
|
|
18
|
+
Host:
|
|
19
|
+
- api.mailersend.com
|
|
20
|
+
response:
|
|
21
|
+
status:
|
|
22
|
+
code: 200
|
|
23
|
+
message: OK
|
|
24
|
+
headers:
|
|
25
|
+
Content-Type:
|
|
26
|
+
- application/json
|
|
27
|
+
body:
|
|
28
|
+
encoding: UTF-8
|
|
29
|
+
string: ''
|
|
30
|
+
recorded_at: Mon, 01 Jan 2024 00:00:00 GMT
|
|
31
|
+
recorded_with: VCR 6.3.1
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: https://api.mailersend.com/v1/dmarc-monitoring/example_monitor_id/report
|
|
6
|
+
body:
|
|
7
|
+
encoding: UTF-8
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
Authorization:
|
|
11
|
+
- "<AUTH>"
|
|
12
|
+
User-Agent:
|
|
13
|
+
- MailerSend-client-ruby/3.0.1
|
|
14
|
+
Accept:
|
|
15
|
+
- application/json
|
|
16
|
+
Connection:
|
|
17
|
+
- close
|
|
18
|
+
Host:
|
|
19
|
+
- api.mailersend.com
|
|
20
|
+
response:
|
|
21
|
+
status:
|
|
22
|
+
code: 200
|
|
23
|
+
message: OK
|
|
24
|
+
headers:
|
|
25
|
+
Content-Type:
|
|
26
|
+
- application/json
|
|
27
|
+
body:
|
|
28
|
+
encoding: UTF-8
|
|
29
|
+
string: '{"data":[{"ip":"1.2.3.4","dmarc_pass_rate":95,"spf_pass_rate":98,"dkim_pass_rate":97,"message_count":1000,"is_favorite":false,"country":"US"}]}'
|
|
30
|
+
recorded_at: Mon, 01 Jan 2024 00:00:00 GMT
|
|
31
|
+
recorded_with: VCR 6.3.1
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: https://api.mailersend.com/v1/dmarc-monitoring/example_monitor_id/report/1.2.3.4
|
|
6
|
+
body:
|
|
7
|
+
encoding: UTF-8
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
Authorization:
|
|
11
|
+
- "<AUTH>"
|
|
12
|
+
User-Agent:
|
|
13
|
+
- MailerSend-client-ruby/3.0.1
|
|
14
|
+
Accept:
|
|
15
|
+
- application/json
|
|
16
|
+
Connection:
|
|
17
|
+
- close
|
|
18
|
+
Host:
|
|
19
|
+
- api.mailersend.com
|
|
20
|
+
response:
|
|
21
|
+
status:
|
|
22
|
+
code: 200
|
|
23
|
+
message: OK
|
|
24
|
+
headers:
|
|
25
|
+
Content-Type:
|
|
26
|
+
- application/json
|
|
27
|
+
body:
|
|
28
|
+
encoding: UTF-8
|
|
29
|
+
string: '{"data":[{"source_name":"google.com","message_count":500,"dmarc_pass":490,"spf_pass":495,"dkim_pass":492,"policy_applied":"none","disposition":"none","date":"2024-01-01"}]}'
|
|
30
|
+
recorded_at: Mon, 01 Jan 2024 00:00:00 GMT
|
|
31
|
+
recorded_with: VCR 6.3.1
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: https://api.mailersend.com/v1/dmarc-monitoring/example_monitor_id/report-sources
|
|
6
|
+
body:
|
|
7
|
+
encoding: UTF-8
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
Authorization:
|
|
11
|
+
- "<AUTH>"
|
|
12
|
+
User-Agent:
|
|
13
|
+
- MailerSend-client-ruby/3.0.1
|
|
14
|
+
Accept:
|
|
15
|
+
- application/json
|
|
16
|
+
Connection:
|
|
17
|
+
- close
|
|
18
|
+
Host:
|
|
19
|
+
- api.mailersend.com
|
|
20
|
+
response:
|
|
21
|
+
status:
|
|
22
|
+
code: 200
|
|
23
|
+
message: OK
|
|
24
|
+
headers:
|
|
25
|
+
Content-Type:
|
|
26
|
+
- application/json
|
|
27
|
+
body:
|
|
28
|
+
encoding: UTF-8
|
|
29
|
+
string: '{"data":[{"name":"google.com","report_count":12},{"name":"yahoo.com","report_count":5}]}'
|
|
30
|
+
recorded_at: Mon, 01 Jan 2024 00:00:00 GMT
|
|
31
|
+
recorded_with: VCR 6.3.1
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: put
|
|
5
|
+
uri: https://api.mailersend.com/v1/dmarc-monitoring/example_monitor_id
|
|
6
|
+
body:
|
|
7
|
+
encoding: UTF-8
|
|
8
|
+
string: '{"wanted_dmarc_record":"v=DMARC1; p=reject;"}'
|
|
9
|
+
headers:
|
|
10
|
+
Authorization:
|
|
11
|
+
- "<AUTH>"
|
|
12
|
+
User-Agent:
|
|
13
|
+
- MailerSend-client-ruby/3.0.1
|
|
14
|
+
Accept:
|
|
15
|
+
- application/json
|
|
16
|
+
Connection:
|
|
17
|
+
- close
|
|
18
|
+
Content-Type:
|
|
19
|
+
- application/json; charset=utf-8
|
|
20
|
+
Host:
|
|
21
|
+
- api.mailersend.com
|
|
22
|
+
response:
|
|
23
|
+
status:
|
|
24
|
+
code: 200
|
|
25
|
+
message: OK
|
|
26
|
+
headers:
|
|
27
|
+
Content-Type:
|
|
28
|
+
- application/json
|
|
29
|
+
body:
|
|
30
|
+
encoding: UTF-8
|
|
31
|
+
string: '{"data":{"id":"example_monitor_id","dmarc_record":"v=DMARC1; p=none;","wanted_dmarc_record":"v=DMARC1;
|
|
32
|
+
p=reject;","dmarc_record_valid":false,"spf_record":"v=spf1 include:spf.example.com ~all","spf_record_valid":true,"domain":{"id":"example_domain_id","name":"example.com"},"created_at":"2024-01-01T00:00:00.000000Z","updated_at":"2024-01-02T00:00:00.000000Z"}}'
|
|
33
|
+
recorded_at: Mon, 01 Jan 2024 00:00:00 GMT
|
|
34
|
+
recorded_with: VCR 6.3.1
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mailersend
|
|
4
|
+
# DMARC Monitoring endpoint from MailerSend API.
|
|
5
|
+
class DmarcMonitoring
|
|
6
|
+
attr_accessor :client, :monitor_id, :ip, :page, :limit
|
|
7
|
+
|
|
8
|
+
def initialize(client = Mailersend::Client.new)
|
|
9
|
+
@client = client
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def list(page: nil, limit: nil)
|
|
13
|
+
hash = { 'page' => page, 'limit' => limit }
|
|
14
|
+
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST,
|
|
15
|
+
path: '/v1/dmarc-monitoring',
|
|
16
|
+
query: URI.encode_www_form(hash.compact)))
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def create(domain_id:)
|
|
20
|
+
client.http.post("#{MAILERSEND_API_URL}/dmarc-monitoring",
|
|
21
|
+
json: { 'domain_id' => domain_id })
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def update(monitor_id:, wanted_dmarc_record:)
|
|
25
|
+
client.http.put("#{MAILERSEND_API_URL}/dmarc-monitoring/#{monitor_id}",
|
|
26
|
+
json: { 'wanted_dmarc_record' => wanted_dmarc_record })
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def delete(monitor_id:)
|
|
30
|
+
client.http.delete("#{MAILERSEND_API_URL}/dmarc-monitoring/#{monitor_id}")
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def report(monitor_id:, page: nil, limit: nil)
|
|
34
|
+
hash = { 'page' => page, 'limit' => limit }
|
|
35
|
+
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST,
|
|
36
|
+
path: "/v1/dmarc-monitoring/#{monitor_id}/report",
|
|
37
|
+
query: URI.encode_www_form(hash.compact)))
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def report_by_ip(monitor_id:, ip:, page: nil, limit: nil)
|
|
41
|
+
hash = { 'page' => page, 'limit' => limit }
|
|
42
|
+
client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST,
|
|
43
|
+
path: "/v1/dmarc-monitoring/#{monitor_id}/report/#{ip}",
|
|
44
|
+
query: URI.encode_www_form(hash.compact)))
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def report_sources(monitor_id:)
|
|
48
|
+
client.http.get("#{MAILERSEND_API_URL}/dmarc-monitoring/#{monitor_id}/report-sources")
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def add_favorite(monitor_id:, ip:)
|
|
52
|
+
client.http.put("#{MAILERSEND_API_URL}/dmarc-monitoring/#{monitor_id}/favorite/#{ip}")
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def remove_favorite(monitor_id:, ip:)
|
|
56
|
+
client.http.delete("#{MAILERSEND_API_URL}/dmarc-monitoring/#{monitor_id}/favorite/#{ip}")
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -19,6 +19,8 @@ module Mailersend
|
|
|
19
19
|
:tags,
|
|
20
20
|
:variables,
|
|
21
21
|
:personalization,
|
|
22
|
+
:headers,
|
|
23
|
+
:list_unsubscribe,
|
|
22
24
|
:send_at
|
|
23
25
|
|
|
24
26
|
def initialize(client = Mailersend::Client.new)
|
|
@@ -35,6 +37,8 @@ module Mailersend
|
|
|
35
37
|
@personalization = []
|
|
36
38
|
@attachments = []
|
|
37
39
|
@tags = []
|
|
40
|
+
@headers = {}
|
|
41
|
+
@list_unsubscribe = nil
|
|
38
42
|
@send_at = send_at
|
|
39
43
|
end
|
|
40
44
|
|
|
@@ -102,6 +106,14 @@ module Mailersend
|
|
|
102
106
|
@attachments << { 'content' => base64_encoded, 'filename' => filename, 'disposition' => disposition }
|
|
103
107
|
end
|
|
104
108
|
|
|
109
|
+
def add_headers(headers)
|
|
110
|
+
@headers = headers
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def add_list_unsubscribe(list_unsubscribe)
|
|
114
|
+
@list_unsubscribe = list_unsubscribe
|
|
115
|
+
end
|
|
116
|
+
|
|
105
117
|
def add_send_at(send_at)
|
|
106
118
|
@send_at = send_at
|
|
107
119
|
end
|
|
@@ -120,6 +132,8 @@ module Mailersend
|
|
|
120
132
|
'personalization' => @personalization,
|
|
121
133
|
'template_id' => @template_id,
|
|
122
134
|
'attachments' => @attachments,
|
|
135
|
+
'headers' => @headers,
|
|
136
|
+
'list_unsubscribe' => @list_unsubscribe,
|
|
123
137
|
'send_at' => @send_at,
|
|
124
138
|
'tags' => @tags
|
|
125
139
|
}
|
data/lib/mailersend/version.rb
CHANGED
data/lib/mailersend.rb
CHANGED
|
@@ -6,6 +6,7 @@ require_relative 'mailersend/activity/activity'
|
|
|
6
6
|
require_relative 'mailersend/api_quota/api_quota'
|
|
7
7
|
require_relative 'mailersend/analytics/analytics'
|
|
8
8
|
require_relative 'mailersend/bulk_email/bulk_email'
|
|
9
|
+
require_relative 'mailersend/dmarc_monitoring/dmarc_monitoring'
|
|
9
10
|
require_relative 'mailersend/domains/domains'
|
|
10
11
|
require_relative 'mailersend/email/email'
|
|
11
12
|
require_relative 'mailersend/email_verification/email_verification'
|
|
@@ -0,0 +1,100 @@
|
|
|
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::DmarcMonitoring do
|
|
14
|
+
let(:client) { Mailersend::Client.new(API_TOKEN) }
|
|
15
|
+
let(:dmarc) { Mailersend::DmarcMonitoring.new(client) }
|
|
16
|
+
|
|
17
|
+
it 'returns a list of monitors' do
|
|
18
|
+
VCR.use_cassette('dmarc_monitoring/list') do
|
|
19
|
+
response = dmarc.list
|
|
20
|
+
parsed_response = JSON.parse(response.body)
|
|
21
|
+
|
|
22
|
+
expect(response.status).to eq(200)
|
|
23
|
+
expect(parsed_response['data']).to be_an(Array)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'creates a monitor' do
|
|
28
|
+
VCR.use_cassette('dmarc_monitoring/create') do
|
|
29
|
+
response = dmarc.create(domain_id: 'example_domain_id')
|
|
30
|
+
parsed_response = JSON.parse(response.body)
|
|
31
|
+
|
|
32
|
+
expect(response.status).to eq(201)
|
|
33
|
+
expect(parsed_response['data']).to be_a(Hash)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'updates a monitor' do
|
|
38
|
+
VCR.use_cassette('dmarc_monitoring/update') do
|
|
39
|
+
response = dmarc.update(monitor_id: 'example_monitor_id', wanted_dmarc_record: 'v=DMARC1; p=reject;')
|
|
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 a monitor' do
|
|
48
|
+
VCR.use_cassette('dmarc_monitoring/delete') do
|
|
49
|
+
response = dmarc.delete(monitor_id: 'example_monitor_id')
|
|
50
|
+
|
|
51
|
+
expect(response.status).to eq(204)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it 'returns aggregated report' do
|
|
56
|
+
VCR.use_cassette('dmarc_monitoring/report') do
|
|
57
|
+
response = dmarc.report(monitor_id: 'example_monitor_id')
|
|
58
|
+
parsed_response = JSON.parse(response.body)
|
|
59
|
+
|
|
60
|
+
expect(response.status).to eq(200)
|
|
61
|
+
expect(parsed_response['data']).to be_an(Array)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it 'returns IP-specific report' do
|
|
66
|
+
VCR.use_cassette('dmarc_monitoring/report_by_ip') do
|
|
67
|
+
response = dmarc.report_by_ip(monitor_id: 'example_monitor_id', ip: '1.2.3.4')
|
|
68
|
+
parsed_response = JSON.parse(response.body)
|
|
69
|
+
|
|
70
|
+
expect(response.status).to eq(200)
|
|
71
|
+
expect(parsed_response['data']).to be_an(Array)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it 'returns report sources' do
|
|
76
|
+
VCR.use_cassette('dmarc_monitoring/report_sources') do
|
|
77
|
+
response = dmarc.report_sources(monitor_id: 'example_monitor_id')
|
|
78
|
+
parsed_response = JSON.parse(response.body)
|
|
79
|
+
|
|
80
|
+
expect(response.status).to eq(200)
|
|
81
|
+
expect(parsed_response['data']).to be_an(Array)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it 'marks an IP as favorite' do
|
|
86
|
+
VCR.use_cassette('dmarc_monitoring/add_favorite') do
|
|
87
|
+
response = dmarc.add_favorite(monitor_id: 'example_monitor_id', ip: '1.2.3.4')
|
|
88
|
+
|
|
89
|
+
expect(response.status).to eq(200)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it 'removes an IP from favorites' do
|
|
94
|
+
VCR.use_cassette('dmarc_monitoring/remove_favorite') do
|
|
95
|
+
response = dmarc.remove_favorite(monitor_id: 'example_monitor_id', ip: '1.2.3.4')
|
|
96
|
+
|
|
97
|
+
expect(response.status).to eq(200)
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mailersend-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nikola Milojević
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: http
|
|
@@ -80,6 +79,15 @@ files:
|
|
|
80
79
|
- fixtures/api_quota/api_quota_get.yml
|
|
81
80
|
- fixtures/bulk_email/bulk_email_send.yml
|
|
82
81
|
- fixtures/bulk_email/bulk_email_status.yml
|
|
82
|
+
- fixtures/dmarc_monitoring/add_favorite.yml
|
|
83
|
+
- fixtures/dmarc_monitoring/create.yml
|
|
84
|
+
- fixtures/dmarc_monitoring/delete.yml
|
|
85
|
+
- fixtures/dmarc_monitoring/list.yml
|
|
86
|
+
- fixtures/dmarc_monitoring/remove_favorite.yml
|
|
87
|
+
- fixtures/dmarc_monitoring/report.yml
|
|
88
|
+
- fixtures/dmarc_monitoring/report_by_ip.yml
|
|
89
|
+
- fixtures/dmarc_monitoring/report_sources.yml
|
|
90
|
+
- fixtures/dmarc_monitoring/update.yml
|
|
83
91
|
- fixtures/domains/domains_add.yml
|
|
84
92
|
- fixtures/domains/domains_delete.yml
|
|
85
93
|
- fixtures/domains/domains_dns.yml
|
|
@@ -148,6 +156,7 @@ files:
|
|
|
148
156
|
- lib/mailersend/api_quota/api_quota.rb
|
|
149
157
|
- lib/mailersend/bulk_email/bulk_email.rb
|
|
150
158
|
- lib/mailersend/client.rb
|
|
159
|
+
- lib/mailersend/dmarc_monitoring/dmarc_monitoring.rb
|
|
151
160
|
- lib/mailersend/domains/domains.rb
|
|
152
161
|
- lib/mailersend/email/email.rb
|
|
153
162
|
- lib/mailersend/email_verification/email_verification.rb
|
|
@@ -173,6 +182,7 @@ files:
|
|
|
173
182
|
- spec/activity_rspec.rb
|
|
174
183
|
- spec/api_quota_rspec.rb
|
|
175
184
|
- spec/bulk_email_rspec.rb
|
|
185
|
+
- spec/dmarc_monitoring_rspec.rb
|
|
176
186
|
- spec/domains_rspec.rb
|
|
177
187
|
- spec/email_rspec.rb
|
|
178
188
|
- spec/inbound_routing_rspec.rb
|
|
@@ -199,7 +209,6 @@ metadata:
|
|
|
199
209
|
source_code_uri: https://github.com/mailersend/mailersend-ruby
|
|
200
210
|
changelog_uri: https://github.com/mailersend/mailersend-ruby/blob/main/CHANGELOG.md
|
|
201
211
|
rubygems_mfa_required: 'true'
|
|
202
|
-
post_install_message:
|
|
203
212
|
rdoc_options: []
|
|
204
213
|
require_paths:
|
|
205
214
|
- lib
|
|
@@ -214,8 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
214
223
|
- !ruby/object:Gem::Version
|
|
215
224
|
version: '0'
|
|
216
225
|
requirements: []
|
|
217
|
-
rubygems_version: 3.
|
|
218
|
-
signing_key:
|
|
226
|
+
rubygems_version: 3.6.9
|
|
219
227
|
specification_version: 4
|
|
220
228
|
summary: MailerSend's official Ruby SDK
|
|
221
229
|
test_files: []
|