mailersend-ruby 3.0.1 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.envrc +2 -0
  3. data/.github/workflows/main.yml +1 -1
  4. data/.github/workflows/publish_gem.yml +1 -1
  5. data/.gitignore +2 -1
  6. data/CHANGELOG.md +12 -0
  7. data/README.md +534 -0
  8. data/fixtures/dmarc_monitoring/add_favorite.yml +31 -0
  9. data/fixtures/dmarc_monitoring/create.yml +34 -0
  10. data/fixtures/dmarc_monitoring/delete.yml +31 -0
  11. data/fixtures/dmarc_monitoring/list.yml +32 -0
  12. data/fixtures/dmarc_monitoring/remove_favorite.yml +31 -0
  13. data/fixtures/dmarc_monitoring/report.yml +31 -0
  14. data/fixtures/dmarc_monitoring/report_by_ip.yml +31 -0
  15. data/fixtures/dmarc_monitoring/report_sources.yml +31 -0
  16. data/fixtures/dmarc_monitoring/update.yml +34 -0
  17. data/fixtures/email/email_send_template_language.yml +56 -0
  18. data/fixtures/emails/emails_list_emails.yml +35 -0
  19. data/fixtures/emails/emails_list_emails_empty_page.yml +35 -0
  20. data/fixtures/emails/emails_single_email.yml +35 -0
  21. data/fixtures/whatsapp/whatsapp_send.yml +47 -0
  22. data/fixtures/whatsapp/whatsapp_send_multiple_recipients.yml +47 -0
  23. data/fixtures/whatsapp/whatsapp_send_personalization.yml +47 -0
  24. data/fixtures/whatsapp_activities/whatsapp_activities_list.yml +43 -0
  25. data/fixtures/whatsapp_inbound_messages/whatsapp_inbound_messages_get.yml +43 -0
  26. data/fixtures/whatsapp_inbound_messages/whatsapp_inbound_messages_list.yml +43 -0
  27. data/fixtures/whatsapp_items/whatsapp_items_get.yml +43 -0
  28. data/fixtures/whatsapp_items/whatsapp_items_list.yml +43 -0
  29. data/fixtures/whatsapp_messages/whatsapp_messages_get.yml +43 -0
  30. data/fixtures/whatsapp_messages/whatsapp_messages_list.yml +43 -0
  31. data/fixtures/whatsapp_recipient/whatsapp_recipient_get.yml +43 -0
  32. data/fixtures/whatsapp_recipient/whatsapp_recipient_list.yml +43 -0
  33. data/fixtures/whatsapp_templates/whatsapp_templates_get.yml +43 -0
  34. data/fixtures/whatsapp_templates/whatsapp_templates_list.yml +43 -0
  35. data/flake.lock +27 -0
  36. data/flake.nix +25 -0
  37. data/lefthook.yml +14 -0
  38. data/lib/mailersend/dmarc_monitoring/dmarc_monitoring.rb +59 -0
  39. data/lib/mailersend/email/email.rb +10 -0
  40. data/lib/mailersend/emails/emails.rb +44 -0
  41. data/lib/mailersend/version.rb +1 -1
  42. data/lib/mailersend/whatsapp/whatsapp.rb +47 -0
  43. data/lib/mailersend/whatsapp_activities/whatsapp_activities.rb +45 -0
  44. data/lib/mailersend/whatsapp_inbound_messages/whatsapp_inbound_messages.rb +47 -0
  45. data/lib/mailersend/whatsapp_items/whatsapp_items.rb +57 -0
  46. data/lib/mailersend/whatsapp_messages/whatsapp_messages.rb +47 -0
  47. data/lib/mailersend/whatsapp_recipient/whatsapp_recipient.rb +38 -0
  48. data/lib/mailersend/whatsapp_templates/whatsapp_templates.rb +44 -0
  49. data/lib/mailersend.rb +9 -0
  50. data/spec/dmarc_monitoring_rspec.rb +100 -0
  51. data/spec/email_rspec.rb +15 -0
  52. data/spec/emails_rspec.rb +175 -0
  53. data/spec/whatsapp_activities_rspec.rb +38 -0
  54. data/spec/whatsapp_inbound_messages_rspec.rb +49 -0
  55. data/spec/whatsapp_items_rspec.rb +52 -0
  56. data/spec/whatsapp_messages_rspec.rb +50 -0
  57. data/spec/whatsapp_recipient_rspec.rb +40 -0
  58. data/spec/whatsapp_rspec.rb +65 -0
  59. data/spec/whatsapp_templates_rspec.rb +48 -0
  60. metadata +52 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17f9c7e1443d5719db627034223fe14c686120821832531d97ba1bddfd9baa3d
4
- data.tar.gz: d796dcdb8473272add457f118eb3ec0db7f671d79a5cc58c682c5544bad95753
3
+ metadata.gz: 84cfcecb512ca3be82b1060018748424960c07fb2c1f4f37b2fd0e5b495f8623
4
+ data.tar.gz: e2737c666d5fe36e12338faf2816dc755fbbdf8a2003eb552acc45bd19a0abe4
5
5
  SHA512:
6
- metadata.gz: db2485ea6a3e44cdd2be3609ab515cc2c71192da8256dcb31d55f3d96e60324e9be5c8c378c2b6cea203b8b98ad7df30bdafc4bb4722cd7e5b52344dc2371e4b
7
- data.tar.gz: cbbead7b4a7b9dc7c9d51af70bcad38f3e4915506ecd9deb2428b41b9496cef5b1fb4158c5426bc4ddfa8eee1be5c5c481c15a85792398ef1cbd575080380fa3
6
+ metadata.gz: 79b0ae2b3cb61881a245ee793d13cb588838846e51488a35142755fa9cdcd7376932efe6e7b5c73c8706b3409cc1a4bca7ca4c8ceec669af72e66b00d39a7b07
7
+ data.tar.gz: 457825d4c739fd5be6fe2e7864bead0d3838fdbfaf26cb7675fe15be9448e6a655388791faed2c317085ccaa6b9e2e476a9de7a1a1df809cb26ff290eee82e78
data/.envrc ADDED
@@ -0,0 +1,2 @@
1
+ use flake
2
+ lefthook install >/dev/null
@@ -6,7 +6,7 @@ jobs:
6
6
  build:
7
7
  runs-on: ubuntu-latest
8
8
  steps:
9
- - uses: actions/checkout@v4
9
+ - uses: actions/checkout@v7
10
10
 
11
11
  - name: Set up Ruby
12
12
  uses: ruby/setup-ruby@v1
@@ -9,7 +9,7 @@ jobs:
9
9
  runs-on: ubuntu-latest
10
10
 
11
11
  steps:
12
- - uses: actions/checkout@v4
12
+ - uses: actions/checkout@v7
13
13
 
14
14
  - name: Set up Ruby
15
15
  uses: ruby/setup-ruby@v1
data/.gitignore CHANGED
@@ -9,4 +9,5 @@
9
9
  .env
10
10
  .idea
11
11
  Gemfile.lock
12
- .DS_Store
12
+ .DS_Store
13
+ .direnv
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  ## [Released]
2
2
 
3
+ ## [3.4.0] - 2026-10-26
4
+ - WhatsApp read endpoints: messages, items, activities, inbound messages, recipients and templates (list with filters, and get by ID)
5
+
6
+ ## [3.3.0] - 2026-09-01
7
+ - WhatsApp support (send template-based WhatsApp messages)
8
+
9
+ ## [3.2.0] - 2026-07-09
10
+ - Add optional language field to email send
11
+
12
+ ## [3.1.0] - 2026-04-24
13
+ - DMARC Monitoring support (list, create, update, delete monitors; aggregated reports, IP-specific reports, report sources, mark/remove IP favorites)
14
+
3
15
  ## [3.0.1] - 2025-04-10
4
16
  - Adding missing parameters
5
17
 
data/README.md CHANGED
@@ -20,6 +20,10 @@ MailerSend Ruby SDK
20
20
  - [Update a token](#update-a-token)
21
21
  - [Delete a token](#delete-a-token)
22
22
  - [Send email with attachment](#send-email-with-attachment)
23
+ - [Emails](#emails)
24
+ - [Get a list of emails](#get-a-list-of-emails)
25
+ - [Pagination](#pagination)
26
+ - [Get a single email](#get-a-single-email)
23
27
  - [Activity](#activity)
24
28
  - [Get a list of activities](#get-a-list-of-activities)
25
29
  - [Analytics](#analytics)
@@ -42,6 +46,16 @@ MailerSend Ruby SDK
42
46
  - [Update domain settings](#update-domain-settings)
43
47
  - [Get DNS Records](#get-dns-records)
44
48
  - [Get verification status](#get-verification-status)
49
+ - [DMARC Monitoring](#dmarc-monitoring)
50
+ - [Get a list of monitors](#get-a-list-of-monitors)
51
+ - [Create a monitor](#create-a-monitor)
52
+ - [Update a monitor](#update-a-monitor)
53
+ - [Delete a monitor](#delete-a-monitor)
54
+ - [Get aggregated reports](#get-aggregated-reports)
55
+ - [Get IP-specific reports](#get-ip-specific-reports)
56
+ - [Get report sources](#get-report-sources)
57
+ - [Mark IP as favorite](#mark-ip-as-favorite)
58
+ - [Remove IP from favorites](#remove-ip-from-favorites)
45
59
  - [Sender Identities](#sender-identities)
46
60
  - [Get a list of sender identities](#get-a-list-of-sender-identities)
47
61
  - [Get a single sender identity](#get-a-single-sender-identity)
@@ -83,6 +97,26 @@ MailerSend Ruby SDK
83
97
  - [Create an email verification list](#create-an-email-verification-list)
84
98
  - [Verify an email list](#verify-an-email-list)
85
99
  - [Get email verification list results](#get-email-verification-list-results)
100
+ - [WhatsApp](#whatsapp)
101
+ - [Send a WhatsApp message](#send-a-whatsapp-message)
102
+ - [Send a WhatsApp message with personalization](#send-a-whatsapp-message-with-personalization)
103
+ - [WhatsApp Messages](#whatsapp-messages)
104
+ - [Get a list of WhatsApp messages](#get-a-list-of-whatsapp-messages)
105
+ - [Get a WhatsApp message](#get-a-whatsapp-message)
106
+ - [WhatsApp Items](#whatsapp-items)
107
+ - [Get a list of WhatsApp items](#get-a-list-of-whatsapp-items)
108
+ - [Get a WhatsApp item](#get-a-whatsapp-item)
109
+ - [WhatsApp Activities](#whatsapp-activities)
110
+ - [Get a list of WhatsApp activities](#get-a-list-of-whatsapp-activities)
111
+ - [WhatsApp Inbound Messages](#whatsapp-inbound-messages)
112
+ - [Get a list of WhatsApp inbound messages](#get-a-list-of-whatsapp-inbound-messages)
113
+ - [Get a WhatsApp inbound message](#get-a-whatsapp-inbound-message)
114
+ - [WhatsApp Recipients](#whatsapp-recipients)
115
+ - [Get a list of WhatsApp recipients](#get-a-list-of-whatsapp-recipients)
116
+ - [Get a WhatsApp recipient](#get-a-whatsapp-recipient)
117
+ - [WhatsApp Templates](#whatsapp-templates)
118
+ - [Get a list of WhatsApp templates](#get-a-list-of-whatsapp-templates)
119
+ - [Get a WhatsApp template](#get-a-whatsapp-template)
86
120
  - [SMS](#sms)
87
121
  - [SMS Messages](#sms-messages)
88
122
  - [Get a list of SMS messages](#get-a-list-of-sms-messages)
@@ -190,6 +224,11 @@ ms_email.add_from("email" => "april@parksandrec.com", "name" => "April")
190
224
  ms_email.add_subject("Time")
191
225
  ms_email.add_template_id(12415125)
192
226
 
227
+ # Optional: send the template in a specific language (language code).
228
+ # Only applies to template-based emails; ignored for raw html/text sends.
229
+ # Supported: de, en, es, fr, it, lt, nl, pl, pt-BR
230
+ ms_email.add_language("de")
231
+
193
232
  # Send the email
194
233
  ms_email.send
195
234
  ```
@@ -322,6 +361,145 @@ ms.add_attachment(content: "/Users/Jerry/Desktop/pic.png", filename: "pic.png",
322
361
  ms_email.send
323
362
  ```
324
363
 
364
+ ## Emails
365
+
366
+ An email is the record of a message delivered to one recipient. Use these endpoints to build a searchable sending log,
367
+ and to retrieve a single email together with its activity events.
368
+
369
+ ### Get a list of emails
370
+
371
+ ```ruby
372
+ require "mailersend-ruby"
373
+
374
+ ms_client = Mailersend::Client.new('your_mailersend_token')
375
+
376
+ ms_emails = Mailersend::Emails.new(ms_client)
377
+ ms_emails.list(domain_id: "xxx2241ll", date_from: 1620643567, date_to: 1623321967, page: 1, limit: 50, status: %w[sent delivered], interaction: %w[opened])
378
+ ```
379
+
380
+ `domain_id`, `date_from` and `date_to` are required. Emails are returned newest first.
381
+
382
+ | Keyword argument | Type | Required | Details |
383
+ |--------------------|-----------------|----------|------------------------------------------------------------------------------------------------------------------|
384
+ | `domain_id` | `String` | yes | A domain that belongs to your account. An unknown domain returns `404`. |
385
+ | `date_from` | `Integer\|String` | yes | Unix timestamp (`1620643567`) or datetime (`"2015-10-01 00:00:00"`), assumed `UTC`. Must be lower than `date_to`. |
386
+ | `date_to` | `Integer\|String` | yes | Unix timestamp or datetime. Must be higher than `date_from` and must not be in the future. |
387
+ | `limit` | `Integer` | no | Min: `10`, Max: `1000`, Default: `25`. |
388
+ | `page` | `Integer` | no | Min: `1`, Max: `100`. See [Pagination](#pagination). |
389
+ | `status` | `Array<String>` | no | Any of `queued`, `sent`, `rejected`, `delivered`. Sent as `status[]`. |
390
+ | `interaction` | `Array<String>` | no | Any of `opened`, `clicked`, `unsubscribed`, `complained`, `no_interaction`. Sent as `interaction[]`. |
391
+ | `recipient_email` | `String` | no | Exact, case-insensitive match. An unknown address returns `200` with an empty `data` array. |
392
+ | `message_id` | `String` | no | Exact match. |
393
+ | `template_id` | `String` | no | Exact match. |
394
+ | `subject` | `String` | no | Min: `3` characters. Partial, case-insensitive match. |
395
+ | `tag` | `String` | no | Exact match against a value in the email's `tags` array. |
396
+
397
+ Values inside `status` are combined with `OR`, values inside `interaction` are combined with `OR`, and the two filters
398
+ are combined with `AND`. Pass them as arrays (`%w[sent delivered]`) — the API rejects a scalar value with `422`.
399
+
400
+ > **Note:** This endpoint requires a token with one of the `activity_read` or `activity_full` scopes, and is limited to
401
+ > 10 requests/minute shared with [`GET` /v1/activity](#get-a-list-of-activities). Requests to either endpoint count
402
+ > against the same budget.
403
+
404
+ Each row in `data` describes one email. `text` and `html` are always `null` in list rows — retrieve the content with
405
+ [`single`](#get-a-single-email):
406
+
407
+ ```json
408
+ {
409
+ "data": [
410
+ {
411
+ "id": "5ee0b166b251345e407c9201",
412
+ "from": "no-reply@your-domain.com",
413
+ "to": "recipient@example.com",
414
+ "subject": "Your order has shipped",
415
+ "text": null,
416
+ "html": null,
417
+ "template_id": null,
418
+ "domain_id": "xxx2241ll",
419
+ "message_id": "5ee0b174ac2b8a35e407c9210",
420
+ "status": "delivered",
421
+ "tags": ["orders"],
422
+ "interaction": ["opened"],
423
+ "suppression_reason": null,
424
+ "created_at": "2021-05-10T10:06:14.482000Z",
425
+ "updated_at": "2021-05-10T10:06:18.114000Z",
426
+ "headers": [{ "name": "X-Custom", "value": "foo" }]
427
+ }
428
+ ],
429
+ "links": {
430
+ "first": "https://api.mailersend.com/v1/emails?page=1",
431
+ "last": null,
432
+ "prev": null,
433
+ "next": "https://api.mailersend.com/v1/emails?page=2"
434
+ },
435
+ "meta": {
436
+ "current_page": 1,
437
+ "current_page_url": "https://api.mailersend.com/v1/emails?page=1",
438
+ "from": 1,
439
+ "path": "https://api.mailersend.com/v1/emails",
440
+ "per_page": 10,
441
+ "to": 3
442
+ }
443
+ }
444
+ ```
445
+
446
+ ### Pagination
447
+
448
+ `Mailersend::Emails#list` paginates by page number, the same way as
449
+ [`Mailersend::Activity#get`](#get-a-list-of-activities). Pass `page:` to request a page, and read `meta.current_page`
450
+ to see which page you received.
451
+
452
+ The response carries no `total` and no `last_page`, and `links.last` is always `null`, so the number of pages is not
453
+ known up front. Walk the result set by requesting the next page until `links.next` is `null`:
454
+
455
+ ```ruby
456
+ require "mailersend-ruby"
457
+ require "json"
458
+
459
+ ms_client = Mailersend::Client.new('your_mailersend_token')
460
+ ms_emails = Mailersend::Emails.new(ms_client)
461
+
462
+ page = 1
463
+
464
+ loop do
465
+ response = ms_emails.list(domain_id: "xxx2241ll", date_from: 1620643567, date_to: 1623321967, limit: 100, page: page)
466
+ parsed_response = JSON.parse(response.body)
467
+
468
+ parsed_response['data'].each do |email|
469
+ puts email['id']
470
+ end
471
+
472
+ break if parsed_response['links']['next'].nil?
473
+
474
+ page += 1
475
+ end
476
+ ```
477
+
478
+ Pass the same required parameters and filters on every page — changing them mid-walk restarts the result set. `page`
479
+ accepts values from `1` to `100` and `limit` from `10` to `1000`; a value outside those ranges returns `422`. To
480
+ retrieve a longer history, split it into several `date_from`/`date_to` windows instead of paging deeper.
481
+
482
+ ### Get a single email
483
+
484
+ ```ruby
485
+ require "mailersend-ruby"
486
+
487
+ ms_client = Mailersend::Client.new('your_mailersend_token')
488
+
489
+ ms_emails = Mailersend::Emails.new(ms_client)
490
+ ms_emails.single(email_id: "5ee0b166b251345e407c9201")
491
+ ```
492
+
493
+ Pass an `id` returned by [`list`](#get-a-list-of-emails). The response contains everything a list row carries — plus
494
+ the `text` and `html` content, the `recipient` object, and an `activity` array of the events recorded for the email.
495
+ `template_id` is `null` when the email was not sent from a template.
496
+
497
+ > **Note:** `activity` events are returned newest first and capped at 200 per email — use
498
+ > [`Mailersend::Activity#get`](#get-a-list-of-activities) if you need the complete event history for a domain.
499
+ > `deferred` and `suppressed` events are only included if your plan has those features enabled, and `suppressed` events
500
+ > also carry a `suppression_reason`. The `junk` event type is reported as `soft_bounced`. The array is returned even when
501
+ > content tracking is disabled for the domain, in which case `html` and `text` are `null`.
502
+
325
503
  ## Activity
326
504
 
327
505
  ### Get a list of activities
@@ -544,6 +722,107 @@ ms_domains = Mailersend::Domains.new(ms_client)
544
722
  ms_domains.verify(domain_id: "idofdomain12412")
545
723
  ```
546
724
 
725
+ ## DMARC Monitoring
726
+
727
+ ### Get a list of monitors
728
+
729
+ ```ruby
730
+ require "mailersend-ruby"
731
+
732
+ ms_client = Mailersend::Client.new('your_mailersend_token')
733
+
734
+ ms_dmarc = Mailersend::DmarcMonitoring.new(ms_client)
735
+ ms_dmarc.list
736
+ ```
737
+
738
+ ### Create a monitor
739
+
740
+ ```ruby
741
+ require "mailersend-ruby"
742
+
743
+ ms_client = Mailersend::Client.new('your_mailersend_token')
744
+
745
+ ms_dmarc = Mailersend::DmarcMonitoring.new(ms_client)
746
+ ms_dmarc.create(domain_id: "idofdomain12412")
747
+ ```
748
+
749
+ ### Update a monitor
750
+
751
+ ```ruby
752
+ require "mailersend-ruby"
753
+
754
+ ms_client = Mailersend::Client.new('your_mailersend_token')
755
+
756
+ ms_dmarc = Mailersend::DmarcMonitoring.new(ms_client)
757
+ ms_dmarc.update(monitor_id: "idofmonitor12412", wanted_dmarc_record: "v=DMARC1; p=reject;")
758
+ ```
759
+
760
+ ### Delete a monitor
761
+
762
+ ```ruby
763
+ require "mailersend-ruby"
764
+
765
+ ms_client = Mailersend::Client.new('your_mailersend_token')
766
+
767
+ ms_dmarc = Mailersend::DmarcMonitoring.new(ms_client)
768
+ ms_dmarc.delete(monitor_id: "idofmonitor12412")
769
+ ```
770
+
771
+ ### Get aggregated reports
772
+
773
+ ```ruby
774
+ require "mailersend-ruby"
775
+
776
+ ms_client = Mailersend::Client.new('your_mailersend_token')
777
+
778
+ ms_dmarc = Mailersend::DmarcMonitoring.new(ms_client)
779
+ ms_dmarc.report(monitor_id: "idofmonitor12412")
780
+ ```
781
+
782
+ ### Get IP-specific reports
783
+
784
+ ```ruby
785
+ require "mailersend-ruby"
786
+
787
+ ms_client = Mailersend::Client.new('your_mailersend_token')
788
+
789
+ ms_dmarc = Mailersend::DmarcMonitoring.new(ms_client)
790
+ ms_dmarc.report_by_ip(monitor_id: "idofmonitor12412", ip: "1.2.3.4")
791
+ ```
792
+
793
+ ### Get report sources
794
+
795
+ ```ruby
796
+ require "mailersend-ruby"
797
+
798
+ ms_client = Mailersend::Client.new('your_mailersend_token')
799
+
800
+ ms_dmarc = Mailersend::DmarcMonitoring.new(ms_client)
801
+ ms_dmarc.report_sources(monitor_id: "idofmonitor12412")
802
+ ```
803
+
804
+ ### Mark IP as favorite
805
+
806
+ ```ruby
807
+ require "mailersend-ruby"
808
+
809
+ ms_client = Mailersend::Client.new('your_mailersend_token')
810
+
811
+ ms_dmarc = Mailersend::DmarcMonitoring.new(ms_client)
812
+ ms_dmarc.add_favorite(monitor_id: "idofmonitor12412", ip: "1.2.3.4")
813
+ ```
814
+
815
+ ### Remove IP from favorites
816
+
817
+ ```ruby
818
+ require "mailersend-ruby"
819
+
820
+ ms_client = Mailersend::Client.new('your_mailersend_token')
821
+
822
+ ms_dmarc = Mailersend::DmarcMonitoring.new(ms_client)
823
+ ms_dmarc.remove_favorite(monitor_id: "idofmonitor12412", ip: "1.2.3.4")
824
+ ```
825
+
547
826
  ## Sender Identities
548
827
 
549
828
  ### Get a list of sender identities
@@ -1301,6 +1580,261 @@ ms_sms_webhooks = Mailersend::SMSWebhooks.new(ms_client)
1301
1580
  ms_sms_webhooks.delete_sms_webhook_route(sms_webhook_id: 'your-sms-webhook-id')
1302
1581
  ```
1303
1582
 
1583
+ ## WhatsApp
1584
+
1585
+ ### Send a WhatsApp message
1586
+
1587
+ ```ruby
1588
+ require "mailersend-ruby"
1589
+
1590
+ ms_client = Mailersend::Client.new('your_mailersend_token')
1591
+
1592
+ # Initialize the WhatsApp class
1593
+ ms_whatsapp = Mailersend::WhatsApp.new(ms_client)
1594
+
1595
+ ms_whatsapp.add_from('your-number')
1596
+ ms_whatsapp.add_to('recipient-number')
1597
+ ms_whatsapp.add_template_id('your-template-id')
1598
+
1599
+ ms_whatsapp.send
1600
+ ```
1601
+
1602
+ ### Send a WhatsApp message with personalization
1603
+
1604
+ ```ruby
1605
+ require "mailersend-ruby"
1606
+
1607
+ ms_client = Mailersend::Client.new('your_mailersend_token')
1608
+
1609
+ # Initialize the WhatsApp class
1610
+ ms_whatsapp = Mailersend::WhatsApp.new(ms_client)
1611
+
1612
+ ms_whatsapp.add_from('your-number')
1613
+ ms_whatsapp.add_to('recipient-number')
1614
+ ms_whatsapp.add_template_id('your-template-id')
1615
+
1616
+ personalization = {
1617
+ to: 'recipient-number',
1618
+ data: {
1619
+ header: ['John'],
1620
+ body: ['order #1234', 'tomorrow'],
1621
+ buttons: ['orders/1234']
1622
+ }
1623
+ }
1624
+ ms_whatsapp.add_personalization(personalization)
1625
+
1626
+ ms_whatsapp.send
1627
+ ```
1628
+
1629
+ ## WhatsApp Messages
1630
+
1631
+ ### Get a list of WhatsApp messages
1632
+
1633
+ ```ruby
1634
+ require "mailersend-ruby"
1635
+
1636
+ ms_client = Mailersend::Client.new('your_mailersend_token')
1637
+
1638
+ # Intialize the WhatsApp Messages class
1639
+ ms_whatsapp_messages = Mailersend::WhatsAppMessages.new(ms_client)
1640
+
1641
+ # Add parameters
1642
+ ms_whatsapp_messages.list(
1643
+ whatsapp_account_id: 'your-whatsapp-account-id',
1644
+ from: '15550001234',
1645
+ template_id: 'your-template-id',
1646
+ date_from: 1791936000,
1647
+ date_to: 1792022400,
1648
+ page: 1,
1649
+ limit: 25
1650
+ )
1651
+ ```
1652
+
1653
+ ### Get a WhatsApp message
1654
+
1655
+ ```ruby
1656
+ require "mailersend-ruby"
1657
+
1658
+ ms_client = Mailersend::Client.new('your_mailersend_token')
1659
+
1660
+ # Intialize the WhatsApp Messages class
1661
+ ms_whatsapp_messages = Mailersend::WhatsAppMessages.new(ms_client)
1662
+
1663
+ # Add parameters
1664
+ ms_whatsapp_messages.get(whatsapp_message_id: 'your-whatsapp-message-id')
1665
+ ```
1666
+
1667
+ ## WhatsApp Items
1668
+
1669
+ ### Get a list of WhatsApp items
1670
+
1671
+ ```ruby
1672
+ require "mailersend-ruby"
1673
+
1674
+ ms_client = Mailersend::Client.new('your_mailersend_token')
1675
+
1676
+ # Intialize the WhatsApp Items class
1677
+ ms_whatsapp_items = Mailersend::WhatsAppItems.new(ms_client)
1678
+
1679
+ # Add parameters
1680
+ ms_whatsapp_items.list(
1681
+ recipient: '48600000002',
1682
+ whatsapp_message_id: 'your-whatsapp-message-id',
1683
+ status: %w[delivered read],
1684
+ whatsapp_account_id: 'your-whatsapp-account-id',
1685
+ from: '15550001234',
1686
+ template_id: 'your-template-id',
1687
+ date_from: 1791936000,
1688
+ date_to: 1792022400,
1689
+ page: 1,
1690
+ limit: 25
1691
+ )
1692
+ ```
1693
+
1694
+ ### Get a WhatsApp item
1695
+
1696
+ ```ruby
1697
+ require "mailersend-ruby"
1698
+
1699
+ ms_client = Mailersend::Client.new('your_mailersend_token')
1700
+
1701
+ # Intialize the WhatsApp Items class
1702
+ ms_whatsapp_items = Mailersend::WhatsAppItems.new(ms_client)
1703
+
1704
+ # Add parameters
1705
+ ms_whatsapp_items.get(whatsapp_item_id: 'your-whatsapp-item-id')
1706
+ ```
1707
+
1708
+ ## WhatsApp Activities
1709
+
1710
+ ### Get a list of WhatsApp activities
1711
+
1712
+ ```ruby
1713
+ require "mailersend-ruby"
1714
+
1715
+ ms_client = Mailersend::Client.new('your_mailersend_token')
1716
+
1717
+ # Intialize the WhatsApp Activities class
1718
+ ms_whatsapp_activities = Mailersend::WhatsAppActivities.new(ms_client)
1719
+
1720
+ # Add parameters
1721
+ ms_whatsapp_activities.list(
1722
+ whatsapp_item_id: 'your-whatsapp-item-id',
1723
+ whatsapp_message_id: 'your-whatsapp-message-id',
1724
+ recipient: '48600000001',
1725
+ type: %w[delivered read],
1726
+ date_from: 1791936000,
1727
+ date_to: 1792022400,
1728
+ page: 1,
1729
+ limit: 25
1730
+ )
1731
+ ```
1732
+
1733
+ ## WhatsApp Inbound Messages
1734
+
1735
+ ### Get a list of WhatsApp inbound messages
1736
+
1737
+ ```ruby
1738
+ require "mailersend-ruby"
1739
+
1740
+ ms_client = Mailersend::Client.new('your_mailersend_token')
1741
+
1742
+ # Intialize the WhatsApp Inbound Messages class
1743
+ ms_whatsapp_inbound_messages = Mailersend::WhatsAppInboundMessages.new(ms_client)
1744
+
1745
+ # Add parameters
1746
+ ms_whatsapp_inbound_messages.list(
1747
+ whatsapp_account_id: 'your-whatsapp-account-id',
1748
+ from: '48600000001',
1749
+ type: %w[text image],
1750
+ date_from: 1791936000,
1751
+ date_to: 1792022400,
1752
+ page: 1,
1753
+ limit: 25
1754
+ )
1755
+ ```
1756
+
1757
+ ### Get a WhatsApp inbound message
1758
+
1759
+ ```ruby
1760
+ require "mailersend-ruby"
1761
+
1762
+ ms_client = Mailersend::Client.new('your_mailersend_token')
1763
+
1764
+ # Intialize the WhatsApp Inbound Messages class
1765
+ ms_whatsapp_inbound_messages = Mailersend::WhatsAppInboundMessages.new(ms_client)
1766
+
1767
+ # Add parameters
1768
+ ms_whatsapp_inbound_messages.get(whatsapp_inbound_message_id: 'your-whatsapp-inbound-message-id')
1769
+ ```
1770
+
1771
+ ## WhatsApp Recipients
1772
+
1773
+ ### Get a list of WhatsApp recipients
1774
+
1775
+ ```ruby
1776
+ require "mailersend-ruby"
1777
+
1778
+ ms_client = Mailersend::Client.new('your_mailersend_token')
1779
+
1780
+ # Intialize the WhatsApp Recipient class
1781
+ ms_whatsapp_recipient = Mailersend::WhatsAppRecipient.new(ms_client)
1782
+
1783
+ # Add parameters
1784
+ ms_whatsapp_recipient.list(status: 'active', phone_number: '48600000001', page: 1, limit: 25)
1785
+ ```
1786
+
1787
+ ### Get a WhatsApp recipient
1788
+
1789
+ ```ruby
1790
+ require "mailersend-ruby"
1791
+
1792
+ ms_client = Mailersend::Client.new('your_mailersend_token')
1793
+
1794
+ # Intialize the WhatsApp Recipient class
1795
+ ms_whatsapp_recipient = Mailersend::WhatsAppRecipient.new(ms_client)
1796
+
1797
+ # Add parameters
1798
+ ms_whatsapp_recipient.get(whatsapp_recipient_id: 'your-whatsapp-recipient-id')
1799
+ ```
1800
+
1801
+ ## WhatsApp Templates
1802
+
1803
+ ### Get a list of WhatsApp templates
1804
+
1805
+ ```ruby
1806
+ require "mailersend-ruby"
1807
+
1808
+ ms_client = Mailersend::Client.new('your_mailersend_token')
1809
+
1810
+ # Intialize the WhatsApp Templates class
1811
+ ms_whatsapp_templates = Mailersend::WhatsAppTemplates.new(ms_client)
1812
+
1813
+ # Add parameters
1814
+ ms_whatsapp_templates.list(
1815
+ whatsapp_account_id: 'your-whatsapp-account-id',
1816
+ status: 'approved',
1817
+ category: 'UTILITY',
1818
+ language: 'en_US',
1819
+ page: 1,
1820
+ limit: 25
1821
+ )
1822
+ ```
1823
+
1824
+ ### Get a WhatsApp template
1825
+
1826
+ ```ruby
1827
+ require "mailersend-ruby"
1828
+
1829
+ ms_client = Mailersend::Client.new('your_mailersend_token')
1830
+
1831
+ # Intialize the WhatsApp Templates class
1832
+ ms_whatsapp_templates = Mailersend::WhatsAppTemplates.new(ms_client)
1833
+
1834
+ # Add parameters
1835
+ ms_whatsapp_templates.get(whatsapp_template_id: 'your-whatsapp-template-id')
1836
+ ```
1837
+
1304
1838
  ## Other endpoints
1305
1839
 
1306
1840
  ### Get API quota
@@ -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