mailersend-ruby 1.0.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 42f9a5e46d23e87c1624883d5bdff3c8979885245ee2efb9a6d60b2d51f2598b
4
- data.tar.gz: 47db5c300727257e6c3a96e1a65bd4bd8e285948e01c83e74d02439310343b83
3
+ metadata.gz: '09a27b08a3b4c39332875fd10dd414301eeb58d5fcf06b5ec5001a3f76d51933'
4
+ data.tar.gz: 3a687d31a6723878adec8bb954cf6091e3bcfa8a1c783a80cb9e1b9289ca1ac4
5
5
  SHA512:
6
- metadata.gz: 7a82321fba8995153b7288d3cde80c1b420c4f4fb5a3eab0fbd6ec341272b406fe7b198961bf3292db9b7b41a23486487db308f596a27c3dad4b4b15801044ae
7
- data.tar.gz: 82ae19286af3357b4102c05afeabed5efb8b99127ad5443d09c8ce43f20b245268856ccc55b59e896e23d9e2f377a731b7b1c605a8cfd200b5ab8976feeb0beb
6
+ metadata.gz: 34c6e84ebc65b91cb20d863ddec721ef9e03fb441fcec512fc0098dfc391937f10db637fa87e93812f10c01426ddaa6bb58c841f49242951b13578753208d51d
7
+ data.tar.gz: 4a5beef9b3ed82618befff3655fe62866c4bff50a4c86a1a3a832ab5527d1d46bd7f0dcffccb0405edba4754d607ccacd7bad6a3126b991f0a196742753835eb
@@ -6,7 +6,7 @@ jobs:
6
6
  build:
7
7
  runs-on: ubuntu-latest
8
8
  steps:
9
- - uses: actions/checkout@v2
9
+ - uses: actions/checkout@v3
10
10
  - name: Set up Ruby
11
11
  uses: ruby/setup-ruby@v1
12
12
  with:
@@ -9,7 +9,7 @@ jobs:
9
9
  runs-on: ubuntu-latest
10
10
 
11
11
  steps:
12
- - uses: actions/checkout@v2
12
+ - uses: actions/checkout@v3
13
13
 
14
14
  - name: Release Gem
15
15
  if: contains(github.ref, 'refs/tags/v')
data/.rubocop.yml CHANGED
@@ -23,3 +23,6 @@ Metrics/AbcSize:
23
23
 
24
24
  Naming/FileName:
25
25
  Enabled: false
26
+
27
+ Style/FetchEnvVar:
28
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  ## [Released]
2
2
 
3
+ ## [1.2.0] - 2022-06-15
4
+
5
+ - SMS Sending
6
+ - SMS Activity
7
+ - SMS Phone Numbers
8
+ - SMS Recipients
9
+
10
+ ## [1.1.0] - 2022-02-18
11
+
12
+ - Domains endpoint improvements
13
+ - Added schedule an email parameter
14
+ - Added inbound routes endpoint
15
+ - Added scheduled messages endpoint
16
+
17
+ ## [1.0.1] - 2022-02-16
18
+
19
+ - Removed puts from request response
20
+ - Added dynamic User-Agent based on SDK version
21
+
3
22
  ## [1.0.0] - 2022-02-15
4
23
 
5
24
  - BREAKING CHANGE: Renamed `API_TOKEN` variable to `MAILERSEND_API_TOKEN`
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)
@@ -55,6 +67,19 @@ MailerSend Ruby SDK
55
67
  - [Get templates](#get-templates)
56
68
  - [Get a single template](#get-a-single-template)
57
69
  - [Delete template](#delete-template)
70
+ - [SMS](#sms)
71
+ - [Send an SMS](#send-an-sms)
72
+ - [SMS Activity](#sms-activity)
73
+ - [Get a list of activities](#get-a-list-of-sms-activities)
74
+ - [SMS Phone Numbers](#sms-phone-numbers)
75
+ - [Get a list of SMS phone numbers](#get-a-list-of-sms-phone-numbers)
76
+ - [Get an SMS phone number](#get-an-sms-phone-number)
77
+ - [Update a single SMS phone number](#update-a-single-sms-phone-number)
78
+ - [Delete an SMS phone number](#delete-an-sms-phone-number)
79
+ - [SMS Recipients](#sms-recipients)
80
+ - [Get a list of SMS recipients](#get-a-list-of-sms-recipients)
81
+ - [Get an SMS recipient](#get-an-sms-recipient)
82
+ - [Update a single SMS recipient](#update-a-single-sms-recipient)
58
83
  - [Support and Feedback](#support-and-feedback)
59
84
  - [License](#license)
60
85
 
@@ -328,6 +353,69 @@ ms_analytics = Mailersend::Analytics.new
328
353
  ms_analytics.ua_type(date_from: 1620643567, date_to: 1623321967)
329
354
  ```
330
355
 
356
+ ## Inbound Routes
357
+
358
+ ### Get a list of inbound routes
359
+
360
+ ```ruby
361
+ require "mailersend-ruby"
362
+
363
+ ms_inbound_routes = Mailersend::InboundRouting.new
364
+ ms_inbound_routes.get_inbound_routes
365
+ ```
366
+
367
+ ### Get a single inbound route
368
+
369
+ ```ruby
370
+ require "mailersend-ruby"
371
+
372
+ ms_inbound_routes = Mailersend::InboundRouting.new
373
+ ms_inbound_routes.get_single_route(inbound_id: 'idofroute12412')
374
+ ```
375
+
376
+ ### Add an inbound route
377
+
378
+ ```ruby
379
+ require "mailersend-ruby"
380
+
381
+ ms_inbound_routes = Mailersend::InboundRouting.new
382
+ ms_inbound_routes.settings =
383
+ {
384
+ 'domain_id' => 'yourdomainid',
385
+ 'name' => 'inbound_name',
386
+ 'domain_enabled' => false,
387
+ 'match_filter' => { 'type' => 'match_all' },
388
+ 'forwards' => [{ 'type' => 'webhook', 'value' => 'https://example.com' }]
389
+ }
390
+ puts ms_inbound_routes.add_inbound_route
391
+ ```
392
+
393
+ ### Update an inbound route
394
+
395
+ ```ruby
396
+ require "mailersend-ruby"
397
+
398
+ ms_inbound_routes = Mailersend::InboundRouting.new
399
+ ms_inbound_routes.settings =
400
+ {
401
+ 'domain_id' => 'yourdomainid',
402
+ 'name' => 'inbound_updated',
403
+ 'domain_enabled' => false,
404
+ 'match_filter' => { 'type' => 'match_all' },
405
+ 'forwards' => [{ 'type' => 'webhook', 'value' => 'https://example.com' }]
406
+ }
407
+ puts ms_inbound_routes.update_inbound_route(inbound_id: 'idofroute12412')
408
+ ```
409
+
410
+ ### Delete an inbound route
411
+
412
+ ```ruby
413
+ require "mailersend-ruby"
414
+
415
+ ms_inbound_routes = Mailersend::InboundRouting.new
416
+ ms_inbound_routes.delete_route(inbound_id: 'idofroute12412')
417
+ ```
418
+
331
419
  ## Domains
332
420
 
333
421
  ### Get a list of domains
@@ -375,6 +463,24 @@ ms_domains = Mailersend::Domains.new
375
463
  ms_domains.settings(domain_id: "idofdomain12412", track_clicks: true, track_unsubscribe: false)
376
464
  ```
377
465
 
466
+ ### Get DNS Records
467
+
468
+ ```ruby
469
+ require "mailersend-ruby"
470
+
471
+ ms_domains = Mailersend::Domains.new
472
+ ms_domains.dns(domain_id: "idofdomain12412")
473
+ ```
474
+
475
+ ### Get verification status
476
+
477
+ ```ruby
478
+ require "mailersend-ruby"
479
+
480
+ ms_domains = Mailersend::Domains.new
481
+ ms_domains.verify(domain_id: "idofdomain12412")
482
+ ```
483
+
378
484
  ## Messages
379
485
 
380
486
  ### Get a list of messages
@@ -395,6 +501,35 @@ ms_messages = Mailersend::Messages.new
395
501
  ms_messages.single(message_id: "mess11454")
396
502
  ```
397
503
 
504
+ ## Scheduled Messages
505
+
506
+ ### Get a list of scheduled messages
507
+
508
+ ```ruby
509
+ require "mailersend-ruby"
510
+
511
+ ms_scheduled_messages = Mailersend::ScheduledMessages.new
512
+ ms_scheduled_messages.get_list
513
+ ```
514
+
515
+ ### Get a single scheduled message
516
+
517
+ ```ruby
518
+ require "mailersend-ruby"
519
+
520
+ ms_scheduled_messages = Mailersend::ScheduledMessages.new
521
+ ms_scheduled_messages.get_signle(message_id: 'mess11454')
522
+ ```
523
+
524
+ ### Delete a scheduled message
525
+
526
+ ```ruby
527
+ require "mailersend-ruby"
528
+
529
+ ms_scheduled_messages = Mailersend::ScheduledMessages.new
530
+ ms_scheduled_messages.delete(message_id: 'mess11454')
531
+ ```
532
+
398
533
  ## Recipients
399
534
 
400
535
  ### Get recipients
@@ -560,6 +695,127 @@ ms_templates = Mailersend::Templates.new
560
695
  ms_templates.delete(template_id: "id124")
561
696
  ```
562
697
 
698
+ ## SMS
699
+
700
+ ### Send an SMS
701
+
702
+ ```ruby
703
+ require "mailersend-ruby"
704
+
705
+ # Intialize the SMS class
706
+ ms_sms = Mailersend::SMS.new
707
+
708
+ # Add parameters
709
+ ms_sms.add_from('your-number')
710
+ ms_sms.add_to('client-number')
711
+ ms_sms.add_text('This is the message content')
712
+
713
+ # Send the SMS
714
+ ms_sms.send
715
+ ```
716
+
717
+ ## SMS Activity
718
+
719
+ ### Get a list of activities
720
+
721
+ ```ruby
722
+ require "mailersend-ruby"
723
+
724
+ # Intialize the SMS Recipient class
725
+ ms_sms_activity = Mailersend::SMSActivity.new
726
+
727
+ # Add parameters
728
+ ms_sms_activity.list(page: 1, limit: 10)
729
+ ```
730
+
731
+ ## SMS phone numbers
732
+
733
+ ### Get a list of SMS phone numbers
734
+
735
+ ```ruby
736
+ require "mailersend-ruby"
737
+
738
+ # Intialize the SMS Recipient class
739
+ ms_sms_number = Mailersend::SMSNumber.new
740
+
741
+ # Add parameters
742
+ ms_sms_number.list(page: 1, limit: 10)
743
+ ```
744
+
745
+ ### Get an SMS phone number
746
+
747
+ ```ruby
748
+ require "mailersend-ruby"
749
+
750
+ # Intialize the SMS Recipient class
751
+ ms_sms_number = Mailersend::SMSNumber.new
752
+
753
+ # Add parameters
754
+ ms_sms_number.get(sms_number_id: 'your-sms-number-id')
755
+ ```
756
+
757
+ ### Update a single SMS phone number
758
+
759
+ ```ruby
760
+ require "mailersend-ruby"
761
+
762
+ # Intialize the SMS Recipient class
763
+ ms_sms_number = Mailersend::SMSNumber.new
764
+
765
+ # Add parameters
766
+ ms_sms_number.update(sms_number_id: 'your-sms-number-id', paused: false)
767
+ ```
768
+
769
+ ### Delete an SMS phone number
770
+
771
+ ```ruby
772
+ require "mailersend-ruby"
773
+
774
+ # Intialize the SMS Recipient class
775
+ ms_sms_number = Mailersend::SMSNumber.new
776
+
777
+ # Add parameters
778
+ ms_sms_number.delete(sms_number_id: 'your-sms-number-id')
779
+ ```
780
+
781
+ ## SMS recipients
782
+
783
+ ### Get a list of SMS recipients
784
+
785
+ ```ruby
786
+ require "mailersend-ruby"
787
+
788
+ # Intialize the SMS Recipient class
789
+ ms_sms_recipient = Mailersend::SMSRecipient.new
790
+
791
+ # Add parameters
792
+ ms_sms_recipient.list(page: 1, limit: 10)
793
+ ```
794
+
795
+ ### Get an SMS recipient
796
+
797
+ ```ruby
798
+ require "mailersend-ruby"
799
+
800
+ # Intialize the SMS Recipient class
801
+ ms_sms_recipient = Mailersend::SMSRecipient.new
802
+
803
+ # Add parameters
804
+ ms_sms_recipient.get(sms_recipient_id: 'your-sms-recipient-id')
805
+ ```
806
+
807
+ ### Update a single SMS recipient
808
+
809
+ ```ruby
810
+ require "mailersend-ruby"
811
+
812
+ # Intialize the SMS Recipient class
813
+ ms_sms_recipient = Mailersend::SMSRecipient.new
814
+
815
+ # Add parameters
816
+ ms_sms_recipient.update(sms_recipient_id: 'your-sms-recipient-id', status: 'opt_out')
817
+ ```
818
+
563
819
  # Support and Feedback
564
820
 
565
821
  In case you find any bugs, submit an issue directly here in GitHub.
@@ -27,9 +27,8 @@ module Mailersend
27
27
  date_to: date_to
28
28
  }
29
29
 
30
- response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/activity/#{domain_id}",
31
- query: URI.encode_www_form(hash.compact)))
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
- response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/analytics/date',
38
- query: URI.encode_www_form(hash.compact)))
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
- response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/analytics/country',
52
- query: URI.encode_www_form(hash.compact)))
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
- response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/analytics/ua-name',
66
- query: URI.encode_www_form(hash.compact)))
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
- response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/analytics/ua-type',
80
- query: URI.encode_www_form(hash.compact)))
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
@@ -23,14 +23,11 @@ module Mailersend
23
23
  end
24
24
 
25
25
  def send
26
- response = client.http.post("#{API_URL}/bulk-email", json: @messages)
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
- response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/bulk-email/#{bulk_email_id}"))
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
@@ -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' => 'MailerSend-client-ruby/1.0.0',
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
- response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/domains',
27
- query: URI.encode_www_form(hash.compact)))
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
- response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/domains/#{domain_id}",
38
- query: URI.encode_www_form(hash.compact)))
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
- response = client.http.delete(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/domains/#{domain_id}"))
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
- response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/domains/#{domain_id}/recipients",
53
- query: URI.encode_www_form(hash.compact)))
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
- response = client.http.put("#{API_URL}/domains/#{domain_id}/settings", json: hash.compact)
70
- puts response
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)
@@ -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
- response = client.http.post("#{API_URL}/email", json: message.delete_if { |_, value| value.to_s.strip == '' || value == [] || value == {} })
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
- response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/messages',
25
- query: URI.encode_www_form(hash)))
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
- response = client.http.get("#{API_URL}/messages/#{message_id}")
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
- response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/recipients',
25
- query: URI.encode_www_form(hash)))
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
- response = client.http.get("#{API_URL}/recipients/#{recipient_id}")
31
- puts response
29
+ client.http.get("#{API_URL}/recipients/#{recipient_id}")
32
30
  end
33
31
 
34
32
  def delete(recipient_id:)
35
- response = client.http.delete("#{API_URL}/recipients/#{recipient_id}")
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
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mailersend
4
+ # Send an SMS through MailerSend API
5
+ class SMS
6
+ attr_accessor :client,
7
+ :from,
8
+ :to,
9
+ :text
10
+
11
+ def initialize(client = Mailersend::Client.new)
12
+ @client = client
13
+ @from = {}
14
+ @to = []
15
+ @text = {}
16
+ end
17
+
18
+ def add_from(from)
19
+ @from = from
20
+ end
21
+
22
+ def add_to(to)
23
+ @to << to
24
+ end
25
+
26
+ def add_text(text)
27
+ @text = text
28
+ end
29
+
30
+ def send
31
+ message = {
32
+ 'from' => @from,
33
+ 'to' => @to,
34
+ 'text' => @text
35
+ }
36
+
37
+ client.http.post("#{API_URL}/sms", json: message.delete_if { |_, value| value.to_s.strip == '' || value == [] || value == {} })
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mailersend
4
+ # SMS Activity endpoint from MailerSend API.
5
+ class SMSActivity
6
+ attr_accessor :client,
7
+ :page,
8
+ :limit
9
+
10
+ def initialize(client = Mailersend::Client.new)
11
+ @client = client
12
+ @page = page
13
+ @limit = limit
14
+ end
15
+
16
+ def list(page: nil, limit: nil)
17
+ hash = {
18
+ 'page' => page,
19
+ 'limit' => limit
20
+ }
21
+
22
+ client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/sms-activity',
23
+ query: URI.encode_www_form(hash)))
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mailersend
4
+ # SMS Number endpoint from MailerSend API.
5
+ class SMSNumber
6
+ attr_accessor :client,
7
+ :paused,
8
+ :page,
9
+ :limit,
10
+ :sms_number_id
11
+
12
+ def initialize(client = Mailersend::Client.new)
13
+ @client = client
14
+ @paused = paused
15
+ @page = page
16
+ @limit = limit
17
+ @sms_number_id = sms_number_id
18
+ end
19
+
20
+ def list(page: nil, limit: nil)
21
+ hash = {
22
+ 'page' => page,
23
+ 'limit' => limit
24
+ }
25
+
26
+ client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/sms-numbers',
27
+ query: URI.encode_www_form(hash)))
28
+ end
29
+
30
+ def get(sms_number_id:)
31
+ client.http.get("#{API_URL}/sms-numbers/#{sms_number_id}")
32
+ end
33
+
34
+ def update(sms_number_id:, paused: nil)
35
+ hash = {
36
+ 'paused' => paused
37
+ }
38
+ client.http.put("#{API_URL}/sms-numbers/#{sms_number_id}", json: hash.compact)
39
+ end
40
+
41
+ def delete(sms_number_id:)
42
+ client.http.delete("#{API_URL}/sms-numbers/#{sms_number_id}")
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mailersend
4
+ # SMS Recipient endpoint from MailerSend API.
5
+ class SMSRecipient
6
+ attr_accessor :client,
7
+ :status,
8
+ :sms_number_id,
9
+ :sms_recipient_id,
10
+ :page,
11
+ :limit
12
+
13
+ def initialize(client = Mailersend::Client.new)
14
+ @client = client
15
+ @status = status
16
+ @sms_number_id = sms_number_id
17
+ @sms_recipient_id = sms_recipient_id
18
+ @page = page
19
+ @limit = limit
20
+ end
21
+
22
+ def list(page: nil, limit: nil)
23
+ hash = {
24
+ 'page' => page,
25
+ 'limit' => limit
26
+ }
27
+
28
+ client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/sms-recipients',
29
+ query: URI.encode_www_form(hash)))
30
+ end
31
+
32
+ def get(sms_recipient_id:)
33
+ client.http.get("#{API_URL}/sms-recipients/#{sms_recipient_id}")
34
+ end
35
+
36
+ def update(sms_recipient_id:, status: nil)
37
+ hash = {
38
+ 'status' => status
39
+ }
40
+ client.http.put("#{API_URL}/sms-recipients/#{sms_recipient_id}", json: hash.compact)
41
+ end
42
+ end
43
+ end
@@ -16,23 +16,19 @@ module Mailersend
16
16
  end
17
17
 
18
18
  def get_from_blocklist(*)
19
- response = client.http.get("#{API_URL}/suppressions/blocklist")
20
- puts response
19
+ client.http.get("#{API_URL}/suppressions/blocklist")
21
20
  end
22
21
 
23
22
  def get_hard_bounces(*)
24
- response = client.http.get("#{API_URL}/suppressions/hard-bounces")
25
- puts response
23
+ client.http.get("#{API_URL}/suppressions/hard-bounces")
26
24
  end
27
25
 
28
26
  def get_spam_complaints(*)
29
- response = client.http.get("#{API_URL}/suppressions/spam-complaints")
30
- puts response
27
+ client.http.get("#{API_URL}/suppressions/spam-complaints")
31
28
  end
32
29
 
33
30
  def get_unsubscribes(*)
34
- response = client.http.get("#{API_URL}/suppressions/unsubscribes")
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,8 +36,7 @@ module Mailersend
40
36
  'recipients' => recipients,
41
37
  'patterns' => patterns
42
38
  }
43
- response = client.http.post("#{API_URL}/suppressions/blocklist", json: hash.compact)
44
- puts response
39
+ client.http.post("#{API_URL}/suppressions/blocklist", json: hash.compact)
45
40
  end
46
41
 
47
42
  def delete_from_blocklist(domain_id: nil, ids: nil, all: nil)
@@ -50,8 +45,7 @@ module Mailersend
50
45
  'ids' => ids,
51
46
  'all' => all
52
47
  }
53
- response = client.http.delete("#{API_URL}/suppressions/blocklist", json: hash.compact)
54
- puts response
48
+ client.http.delete("#{API_URL}/suppressions/blocklist", json: hash.compact)
55
49
  end
56
50
 
57
51
  def add_to_hard_bounces(domain_id: nil, recipients: nil)
@@ -59,8 +53,7 @@ module Mailersend
59
53
  'domain_id' => domain_id,
60
54
  'recipients' => recipients
61
55
  }
62
- response = client.http.post("#{API_URL}/suppressions/hard-bounces", json: hash.compact)
63
- puts response
56
+ client.http.post("#{API_URL}/suppressions/hard-bounces", json: hash.compact)
64
57
  end
65
58
 
66
59
  def delete_from_hard_bounces(domain_id: nil, ids: nil, all: nil)
@@ -69,8 +62,7 @@ module Mailersend
69
62
  'ids' => ids,
70
63
  'all' => all
71
64
  }
72
- response = client.http.delete("#{API_URL}/suppressions/hard-bounces", json: hash.compact)
73
- puts response
65
+ client.http.delete("#{API_URL}/suppressions/hard-bounces", json: hash.compact)
74
66
  end
75
67
 
76
68
  def add_to_spam_complaints(domain_id: nil, recipients: nil)
@@ -78,8 +70,7 @@ module Mailersend
78
70
  'domain_id' => domain_id,
79
71
  'recipients' => recipients
80
72
  }
81
- response = client.http.post("#{API_URL}/suppressions/spam-complaints", json: hash.compact)
82
- puts response
73
+ client.http.post("#{API_URL}/suppressions/spam-complaints", json: hash.compact)
83
74
  end
84
75
 
85
76
  def delete_from_spam_complaints(domain_id: nil, ids: nil, all: nil)
@@ -88,8 +79,7 @@ module Mailersend
88
79
  'ids' => ids,
89
80
  'all' => all
90
81
  }
91
- response = client.http.delete("#{API_URL}/suppressions/spam-complaints", json: hash.compact)
92
- puts response
82
+ client.http.delete("#{API_URL}/suppressions/spam-complaints", json: hash.compact)
93
83
  end
94
84
 
95
85
  def add_to_unsubscribers(domain_id: nil, recipients: nil)
@@ -97,8 +87,7 @@ module Mailersend
97
87
  'domain_id' => domain_id,
98
88
  'recipients' => recipients
99
89
  }
100
- response = client.http.post("#{API_URL}/suppressions/unsubscribes", json: hash.compact)
101
- puts response
90
+ client.http.post("#{API_URL}/suppressions/unsubscribes", json: hash.compact)
102
91
  end
103
92
 
104
93
  def delete_from_unsubscribers(domain_id: nil, ids: nil, all: nil)
@@ -107,8 +96,7 @@ module Mailersend
107
96
  'ids' => ids,
108
97
  'all' => all
109
98
  }
110
- response = client.http.delete("#{API_URL}/suppressions/unsubscribes", json: hash.compact)
111
- puts response
99
+ client.http.delete("#{API_URL}/suppressions/unsubscribes", json: hash.compact)
112
100
  end
113
101
  end
114
102
  end
@@ -22,19 +22,16 @@ module Mailersend
22
22
  'limit' => limit
23
23
  }
24
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
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
- response = client.http.get("#{API_URL}/templates/#{template_id}")
32
- puts response
30
+ client.http.get("#{API_URL}/templates/#{template_id}")
33
31
  end
34
32
 
35
33
  def delete(template_id:)
36
- response = client.http.delete("#{API_URL}/templates/#{template_id}")
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
- response = client.http.post("#{API_URL}/token", json: json)
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
- response = client.http.put("#{API_URL}/token/#{token_id}/settings", json: status)
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
- response = client.http.delete("#{API_URL}/token/#{token_id}")
40
- puts response
37
+ client.http.delete("#{API_URL}/token/#{token_id}")
41
38
  end
42
39
  end
43
40
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mailersend
4
- VERSION = '1.0.0'
4
+ VERSION = '1.2.0'
5
5
  end
@@ -24,14 +24,12 @@ module Mailersend
24
24
  hash = {
25
25
  'domain_id' => domain_id
26
26
  }
27
- response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/webhooks',
28
- query: URI.encode_www_form(hash)))
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
- response = client.http.get("#{API_URL}/webhooks/#{webhook_id}")
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
- response = client.http.post("#{API_URL}/webhooks", json: hash.compact)
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
- response = client.http.put("#{API_URL}/webhooks/#{webhook_id}", json: hash.compact)
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
- response = client.http.delete("#{API_URL}/webhooks/#{webhook_id}")
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,20 @@
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'
14
+ require_relative 'mailersend/sms/sms'
15
+ require_relative 'mailersend/sms_activity/sms_activity'
16
+ require_relative 'mailersend/sms_number/sms_number'
17
+ require_relative 'mailersend/sms_recipient/sms_recipient'
11
18
  require_relative 'mailersend/suppressions/suppressions'
12
19
  require_relative 'mailersend/templates/templates'
13
20
  require_relative 'mailersend/tokens/tokens'
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: 1.0.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikola Milojević
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-15 00:00:00.000000000 Z
11
+ date: 2022-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -138,8 +138,14 @@ files:
138
138
  - lib/mailersend/client.rb
139
139
  - lib/mailersend/domains/domains.rb
140
140
  - lib/mailersend/email/email.rb
141
+ - lib/mailersend/inbound_routing/inbound_routing.rb
141
142
  - lib/mailersend/messages/messages.rb
142
143
  - lib/mailersend/recipients/recipients.rb
144
+ - lib/mailersend/scheduled_messages/scheduled_messages.rb
145
+ - lib/mailersend/sms/sms.rb
146
+ - lib/mailersend/sms_activity/sms_activity.rb
147
+ - lib/mailersend/sms_number/sms_number.rb
148
+ - lib/mailersend/sms_recipient/sms_recipient.rb
143
149
  - lib/mailersend/suppressions/suppressions.rb
144
150
  - lib/mailersend/templates/templates.rb
145
151
  - lib/mailersend/tokens/tokens.rb
@@ -171,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
177
  - !ruby/object:Gem::Version
172
178
  version: '0'
173
179
  requirements: []
174
- rubygems_version: 3.3.3
180
+ rubygems_version: 3.3.7
175
181
  signing_key:
176
182
  specification_version: 4
177
183
  summary: MailerSend's official Ruby SDK