mailersend-ruby 1.2.0 → 1.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '09a27b08a3b4c39332875fd10dd414301eeb58d5fcf06b5ec5001a3f76d51933'
4
- data.tar.gz: 3a687d31a6723878adec8bb954cf6091e3bcfa8a1c783a80cb9e1b9289ca1ac4
3
+ metadata.gz: 06fb33a6d3379015ec34d916945369c1b2604caa3f51a5fad5a20f0f22fc65ad
4
+ data.tar.gz: b14667b2ebade1bff4934506709593c5193ff8cccf5edcc68d4e61df8e4a43d9
5
5
  SHA512:
6
- metadata.gz: 34c6e84ebc65b91cb20d863ddec721ef9e03fb441fcec512fc0098dfc391937f10db637fa87e93812f10c01426ddaa6bb58c841f49242951b13578753208d51d
7
- data.tar.gz: 4a5beef9b3ed82618befff3655fe62866c4bff50a4c86a1a3a832ab5527d1d46bd7f0dcffccb0405edba4754d607ccacd7bad6a3126b991f0a196742753835eb
6
+ metadata.gz: 365e01c2144cc33fad981c05f4d53f708a20d020071906fc85a1f3b714fc650e434528a7f0199316abe560dbce444d464e17d0446e30d0cdfe84f5d56ab9ee20
7
+ data.tar.gz: a94ad79bfbf227265baeb848abe11fd3755e99416a41384b71786e98ca597c468cada072a4d6bcb330a08be4219ae916ea6215542cad6082027f878f1eef0535
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Released]
2
2
 
3
+ ## [1.3.0] - 2022-08-03
4
+
5
+ - SMS Personalization
6
+ - SMS Messages
7
+ - SMS Inbounds
8
+ - SMS Webhooks
9
+ - Email Verification
10
+
3
11
  ## [1.2.0] - 2022-06-15
4
12
 
5
13
  - SMS Sending
data/README.md CHANGED
@@ -67,10 +67,18 @@ MailerSend Ruby SDK
67
67
  - [Get templates](#get-templates)
68
68
  - [Get a single template](#get-a-single-template)
69
69
  - [Delete template](#delete-template)
70
+ - [Email Verification](#email-verification)
71
+ - [Get all email verification lists](#get-all-email-verification-lists)
72
+ - [Get an email verification list](#get-an-email-verification-list)
73
+ - [Create an email verification list](#create-an-email-verification-list)
74
+ - [Verify an email list](#verify-an-email-list)
75
+ - [Get email verification list results](#get-email-verification-list-results)
70
76
  - [SMS](#sms)
71
- - [Send an SMS](#send-an-sms)
77
+ - [SMS Messages](#sms-messages)
78
+ - [Get a list of SMS messages](#get-a-list-of-sms-messages)
79
+ - [Get info on an SMS message](#get-info-on-an-sms-message)
72
80
  - [SMS Activity](#sms-activity)
73
- - [Get a list of activities](#get-a-list-of-sms-activities)
81
+ - [Get a list of sms activities](#get-a-list-of-sms-activities)
74
82
  - [SMS Phone Numbers](#sms-phone-numbers)
75
83
  - [Get a list of SMS phone numbers](#get-a-list-of-sms-phone-numbers)
76
84
  - [Get an SMS phone number](#get-an-sms-phone-number)
@@ -80,6 +88,18 @@ MailerSend Ruby SDK
80
88
  - [Get a list of SMS recipients](#get-a-list-of-sms-recipients)
81
89
  - [Get an SMS recipient](#get-an-sms-recipient)
82
90
  - [Update a single SMS recipient](#update-a-single-sms-recipient)
91
+ - [SMS Inbounds](#sms-inbounds)
92
+ - [Get a list of SMS inbound routes](#get-a-list-of-sms-inbound-routes)
93
+ - [Get a single SMS inbound route](#get-a-single-sms-inbound-route)
94
+ - [Create an SMS inbound route](#create-an-sms-inbound-route)
95
+ - [Update an SMS inbound route](#update-an-sms-inbound-route)
96
+ - [Delete an SMS inbound route](#delete-an-sms-inbound-route)
97
+ - [SMS Webhooks](#sms-webhooks)
98
+ - [Get a list of SMS webhooks](#get-a-list-of-sms-webhooks)
99
+ - [Get an SMS webhook](#get-an-sms-webhook)
100
+ - [Create an SMS webhook](#create-an-sms-webhook)
101
+ - [Update an SMS webhook](#update-an-sms-webhook)
102
+ - [Delete an SMS webhook](#delete-an-sms-webhook)
83
103
  - [Support and Feedback](#support-and-feedback)
84
104
  - [License](#license)
85
105
 
@@ -695,6 +715,53 @@ ms_templates = Mailersend::Templates.new
695
715
  ms_templates.delete(template_id: "id124")
696
716
  ```
697
717
 
718
+ ## Email Verification
719
+
720
+ ### Get all email verification lists
721
+
722
+ ```ruby
723
+ require "mailersend-ruby"
724
+
725
+ ms_email_verification = Mailersend::EmailVerification.new
726
+ ms_email_verification.list(page: 1, limit: 10)
727
+ ```
728
+
729
+ ### Get an email verification list
730
+
731
+ ```ruby
732
+ require "mailersend-ruby"
733
+
734
+ ms_email_verification = Mailersend::EmailVerification.new
735
+ ms_email_verification.get_single_list(email_verification_id: 'your-email-verification-id')
736
+ ```
737
+
738
+ ### Create an email verification list
739
+
740
+ ```ruby
741
+ require "mailersend-ruby"
742
+
743
+ ms_email_verification = Mailersend::EmailVerification.new
744
+ ms_email_verification.create_a_list(name: "name-your-list", emails: ["example@email.com"])
745
+ ```
746
+
747
+ ### Verify an email list
748
+
749
+ ```ruby
750
+ require "mailersend-ruby"
751
+
752
+ ms_email_verification = Mailersend::EmailVerification.new
753
+ ms_email_verification.verify_a_list(email_verification_id: 'your-email-verification-id')
754
+ ```
755
+
756
+ ### Get email verification list results
757
+
758
+ ```ruby
759
+ require "mailersend-ruby"
760
+
761
+ ms_email_verification = Mailersend::EmailVerification.new
762
+ ms_email_verification.get_list_results(email_verification_id: 'your-email-verification-id')
763
+ ```
764
+
698
765
  ## SMS
699
766
 
700
767
  ### Send an SMS
@@ -709,14 +776,47 @@ ms_sms = Mailersend::SMS.new
709
776
  ms_sms.add_from('your-number')
710
777
  ms_sms.add_to('client-number')
711
778
  ms_sms.add_text('This is the message content')
779
+ personalization = {
780
+ phone_number: 'client-number',
781
+ data: {
782
+ test: 'Test Value'
783
+ }
784
+ }
785
+ ms_sms.add_personalization(personalization)
712
786
 
713
787
  # Send the SMS
714
788
  ms_sms.send
715
789
  ```
716
790
 
791
+ ## SMS Messages
792
+
793
+ ### Get a list of SMS messages
794
+
795
+ ```ruby
796
+ require "mailersend-ruby"
797
+
798
+ # Intialize the SMS Messages class
799
+ ms_sms_messages = Mailersend::SMSMessages.new
800
+
801
+ # Add parameters
802
+ ms_sms_messages.list(page: 1, limit: 10)
803
+ ```
804
+
805
+ ### Get info on an SMS message
806
+
807
+ ```ruby
808
+ require "mailersend-ruby"
809
+
810
+ # Intialize the SMS Messages class
811
+ ms_sms_messages = Mailersend::SMSMessages.new
812
+
813
+ # Add parameters
814
+ ms_sms_messages.get_single_route(sms_message_id: 'your-sms-message-id')
815
+ ```
816
+
717
817
  ## SMS Activity
718
818
 
719
- ### Get a list of activities
819
+ ### Get a list of sms activities
720
820
 
721
821
  ```ruby
722
822
  require "mailersend-ruby"
@@ -816,6 +916,157 @@ ms_sms_recipient = Mailersend::SMSRecipient.new
816
916
  ms_sms_recipient.update(sms_recipient_id: 'your-sms-recipient-id', status: 'opt_out')
817
917
  ```
818
918
 
919
+ ## SMS Inbounds
920
+
921
+ ### Get a list of SMS inbound routes
922
+
923
+ ```ruby
924
+ require "mailersend-ruby"
925
+
926
+ # Intialize the SMS Inbounds class
927
+ ms_sms_inbounds = Mailersend::SMSInbounds.new
928
+
929
+ ms_sms_inbounds.list
930
+ ```
931
+
932
+ ### Get a single SMS inbound route
933
+
934
+ ```ruby
935
+ require "mailersend-ruby"
936
+
937
+ # Intialize the SMS Inbounds class
938
+ ms_sms_inbounds = Mailersend::SMSInbounds.new
939
+
940
+ # Add parameters
941
+ ms_sms_inbounds.get_sms_inbound_route(sms_inbound_id: 'your-sms-inbound-id')
942
+ ```
943
+
944
+ ### Create an SMS inbound route
945
+
946
+ ```ruby
947
+ require "mailersend-ruby"
948
+
949
+ # Intialize the SMS Inbounds class
950
+ ms_sms_inbounds = Mailersend::SMSInbounds.new
951
+
952
+ # Add parameters
953
+ ms_sms_inbounds.settings =
954
+ {
955
+ 'forward_url' => 'https://your-forward-url',
956
+ 'name' => 'name',
957
+ 'events' => ['sms.sent', 'sms.delivered'],
958
+ 'sms_number_id' => 'your-sms-number-id'
959
+ }
960
+ puts ms_sms_inbounds.add_sms_inbound_route
961
+ ```
962
+
963
+ ### Update an SMS inbound route
964
+
965
+ ```ruby
966
+ require "mailersend-ruby"
967
+
968
+ # Intialize the SMS Inbounds class
969
+ ms_sms_inbounds = Mailersend::SMSInbounds.new
970
+
971
+ # Add parameters
972
+ ms_sms_inbounds.settings =
973
+ {
974
+ 'forward_url' => 'https://your-forward-url',
975
+ 'name' => 'name',
976
+ 'events' => ['sms.sent', 'sms.delivered'],
977
+ 'sms_number_id' => 'your-sms-number-id'
978
+ }
979
+ puts ms_sms_inbounds.update_sms_inbound_route(sms_inbound_id: 'your-sms-inbound-id')
980
+ ```
981
+
982
+ ### Delete an SMS inbound route
983
+
984
+ ```ruby
985
+ require "mailersend-ruby"
986
+
987
+ # Intialize the SMS Inbounds class
988
+ ms_sms_inbounds = Mailersend::SMSInbounds.new
989
+
990
+ # Add parameters
991
+ ms_sms_inbounds.delete_sms_inbound_route(sms_inbound_id: 'your-sms-inbound-id')
992
+ ```
993
+
994
+ ## SMS Webhooks
995
+
996
+ ### Get a list of SMS webhooks
997
+
998
+ ```ruby
999
+ require "mailersend-ruby"
1000
+
1001
+ # Intialize the SMS Webhooks class
1002
+ ms_sms_webhooks = Mailersend::SMSWebhooks.new
1003
+
1004
+ # Add parameters
1005
+ ms_sms_webhooks.list(sms_number_id: 'your-sms-number-id')
1006
+ ```
1007
+
1008
+ ### Get an SMS webhook
1009
+
1010
+ ```ruby
1011
+ require "mailersend-ruby"
1012
+
1013
+ # Intialize the SMS Webhooks class
1014
+ ms_sms_webhooks = Mailersend::SMSWebhooks.new
1015
+
1016
+ # Add parameters
1017
+ ms_sms_webhooks.get_sms_webhook_route(sms_webhook_id: 'your-sms-webhook-id')
1018
+ ```
1019
+
1020
+ ### Create an SMS webhook
1021
+
1022
+ ```ruby
1023
+ require "mailersend-ruby"
1024
+
1025
+ # Intialize the SMS Webhooks class
1026
+ ms_sms_webhooks = Mailersend::SMSWebhooks.new
1027
+
1028
+ # Add parameters
1029
+ ms_sms_webhooks.settings =
1030
+ {
1031
+ 'sms_number_id' => 'your-sms-number-id',
1032
+ 'name' => 'your-name',
1033
+ 'url' => 'https://your-url.com',
1034
+ 'events' => ['sms.sent', 'sms.delivered']
1035
+ }
1036
+ puts ms_sms_webhooks.add_sms_webhook_route
1037
+ ```
1038
+
1039
+ ### Update an SMS webhook
1040
+
1041
+ ```ruby
1042
+ require "mailersend-ruby"
1043
+
1044
+ # Intialize the SMS Webhooks class
1045
+ ms_sms_webhooks = Mailersend::SMSWebhooks.new
1046
+
1047
+ # Add parameters
1048
+ ms_sms_webhooks.settings =
1049
+ {
1050
+ 'sms_number_id' => 'your-sms-number-id',
1051
+ 'name' => 'your-name',
1052
+ 'url' => 'https://your-url.com',
1053
+ 'events' => ['sms.sent', 'sms.delivered']
1054
+ }
1055
+ puts ms_sms_webhooks.update_sms_webhook_route(sms_webhook_id: 'your-sms-webhook-id')
1056
+ ```
1057
+
1058
+ ### Delete an SMS webhook
1059
+
1060
+ ```ruby
1061
+ require "mailersend-ruby"
1062
+
1063
+ # Intialize the SMS Webhooks class
1064
+ ms_sms_webhooks = Mailersend::SMSWebhooks.new
1065
+
1066
+ # Add parameters
1067
+ ms_sms_webhooks.delete_sms_webhook_route(sms_webhook_id: 'your-sms-webhook-id')
1068
+ ```
1069
+
819
1070
  # Support and Feedback
820
1071
 
821
1072
  In case you find any bugs, submit an issue directly here in GitHub.
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mailersend
4
+ # Email verification endpoint from MailerSend API.
5
+ class EmailVerification
6
+ attr_accessor :client,
7
+ :page,
8
+ :limit,
9
+ :email_verification_id
10
+
11
+ def initialize(client = Mailersend::Client.new)
12
+ @client = client
13
+ @page = page
14
+ @limit = limit
15
+ @email_verification_id = email_verification_id
16
+ end
17
+
18
+ def list(page: nil, limit: nil)
19
+ hash = {
20
+ 'page' => page,
21
+ 'limit' => limit
22
+ }
23
+ client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/email-verification',
24
+ query: URI.encode_www_form(hash)))
25
+ end
26
+
27
+ def get_single_list(email_verification_id:)
28
+ client.http.get("#{API_URL}/email-verification/#{email_verification_id}")
29
+ end
30
+
31
+ def create_a_list(name: nil, emails: nil)
32
+ hash = {
33
+ 'name' => name,
34
+ 'emails' => emails
35
+ }
36
+ client.http.post("#{API_URL}/email-verification", json: hash.compact)
37
+ end
38
+
39
+ def verify_a_list(email_verification_id:)
40
+ client.http.get("#{API_URL}/email-verification/#{email_verification_id}/verify")
41
+ end
42
+
43
+ def get_list_results(email_verification_id:)
44
+ client.http.get("#{API_URL}/email-verification/#{email_verification_id}/results")
45
+ end
46
+ end
47
+ end
@@ -6,13 +6,15 @@ module Mailersend
6
6
  attr_accessor :client,
7
7
  :from,
8
8
  :to,
9
- :text
9
+ :text,
10
+ :personalization
10
11
 
11
12
  def initialize(client = Mailersend::Client.new)
12
13
  @client = client
13
14
  @from = {}
14
15
  @to = []
15
16
  @text = {}
17
+ @personalization = []
16
18
  end
17
19
 
18
20
  def add_from(from)
@@ -27,14 +29,20 @@ module Mailersend
27
29
  @text = text
28
30
  end
29
31
 
32
+ def add_personalization(personalization)
33
+ @personalization << personalization
34
+ end
35
+
30
36
  def send
31
37
  message = {
32
38
  'from' => @from,
33
39
  'to' => @to,
34
- 'text' => @text
40
+ 'text' => @text,
41
+ 'personalization' => @personalization
35
42
  }
36
43
 
37
- client.http.post("#{API_URL}/sms", json: message.delete_if { |_, value| value.to_s.strip == '' || value == [] || value == {} })
44
+ response = client.http.post("#{API_URL}/sms", json: message.delete_if { |_, value| value.to_s.strip == '' || value == [] || value == {} })
45
+ puts response
38
46
  end
39
47
  end
40
48
  end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mailersend
4
+ # SMS Inbound endpoint from MailerSend API.
5
+ class SMSInbounds
6
+ attr_accessor :client,
7
+ :page,
8
+ :limit,
9
+ :sms_number_id,
10
+ :sms_inbound_id,
11
+ :settings
12
+
13
+ def initialize(client = Mailersend::Client.new)
14
+ @client = client
15
+ @page = page
16
+ @limit = limit
17
+ @sms_number_id = sms_number_id
18
+ @sms_inbound_id = sms_inbound_id
19
+ @settings = []
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-inbounds',
29
+ query: URI.encode_www_form(hash)))
30
+ end
31
+
32
+ def get_sms_inbound_route(sms_inbound_id:)
33
+ client.http.get("#{API_URL}/sms-inbounds/#{sms_inbound_id}")
34
+ end
35
+
36
+ def add_sms_inbound_route
37
+ client.http.post("#{API_URL}/sms-inbounds", json: @settings)
38
+ end
39
+
40
+ def update_sms_inbound_route(sms_inbound_id:)
41
+ client.http.put("#{API_URL}/sms-inbounds/#{sms_inbound_id}", json: @settings)
42
+ end
43
+
44
+ def delete_sms_inbound_route(sms_inbound_id:)
45
+ client.http.delete("#{API_URL}/sms-inbounds/#{sms_inbound_id}")
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mailersend
4
+ # SMS Messages endpoint from MailerSend API.
5
+ class SMSMessages
6
+ attr_accessor :client,
7
+ :page,
8
+ :limit,
9
+ :sms_message_id
10
+
11
+ def initialize(client = Mailersend::Client.new)
12
+ @client = client
13
+ @page = page
14
+ @limit = limit
15
+ @sms_message_id = sms_message_id
16
+ end
17
+
18
+ def list(page: nil, limit: nil)
19
+ hash = {
20
+ 'page' => page,
21
+ 'limit' => limit
22
+ }
23
+
24
+ client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/sms-messages',
25
+ query: URI.encode_www_form(hash)))
26
+ end
27
+
28
+ def get(sms_message_id:)
29
+ client.http.get_single_route("#{API_URL}/sms-messages/#{sms_message_id}")
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mailersend
4
+ # SMS Webhook endpoint from MailerSend API.
5
+ class SMSWebhooks
6
+ attr_accessor :client,
7
+ :page,
8
+ :limit,
9
+ :sms_webhook_id,
10
+ :settings
11
+
12
+ def initialize(client = Mailersend::Client.new)
13
+ @client = client
14
+ @page = page
15
+ @limit = limit
16
+ @sms_webhook_id = sms_webhook_id
17
+ @settings = []
18
+ end
19
+
20
+ def list(sms_number_id:)
21
+ hash = {
22
+ 'sms_number_id' => sms_number_id
23
+ }
24
+ client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/sms-webhooks',
25
+ query: URI.encode_www_form(hash)))
26
+ end
27
+
28
+ def get_sms_webhook_route(sms_webhook_id:)
29
+ client.http.get("#{API_URL}/sms-webhooks/#{sms_webhook_id}")
30
+ end
31
+
32
+ def add_sms_webhook_route
33
+ client.http.post("#{API_URL}/sms-webhooks", json: @settings)
34
+ end
35
+
36
+ def update_sms_webhook_route(sms_webhook_id:)
37
+ client.http.put("#{API_URL}/sms-webhooks/#{sms_webhook_id}", json: @settings)
38
+ end
39
+
40
+ def delete_sms_webhook_route(sms_webhook_id:)
41
+ client.http.delete("#{API_URL}/sms-webhooks/#{sms_webhook_id}")
42
+ end
43
+ end
44
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mailersend
4
- VERSION = '1.2.0'
4
+ VERSION = '1.3.0'
5
5
  end
data/lib/mailersend.rb CHANGED
@@ -7,14 +7,18 @@ require_relative 'mailersend/analytics/analytics'
7
7
  require_relative 'mailersend/bulk_email/bulk_email'
8
8
  require_relative 'mailersend/domains/domains'
9
9
  require_relative 'mailersend/email/email'
10
+ require_relative 'mailersend/email_verification/email_verification'
10
11
  require_relative 'mailersend/inbound_routing/inbound_routing'
11
12
  require_relative 'mailersend/messages/messages'
12
13
  require_relative 'mailersend/recipients/recipients'
13
14
  require_relative 'mailersend/scheduled_messages/scheduled_messages'
14
15
  require_relative 'mailersend/sms/sms'
15
16
  require_relative 'mailersend/sms_activity/sms_activity'
17
+ require_relative 'mailersend/sms_messages/sms_messages'
16
18
  require_relative 'mailersend/sms_number/sms_number'
17
19
  require_relative 'mailersend/sms_recipient/sms_recipient'
20
+ require_relative 'mailersend/sms_inbounds/sms_inbounds'
21
+ require_relative 'mailersend/sms_webhooks/sms_webhooks'
18
22
  require_relative 'mailersend/suppressions/suppressions'
19
23
  require_relative 'mailersend/templates/templates'
20
24
  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.2.0
4
+ version: 1.3.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-06-15 00:00:00.000000000 Z
11
+ date: 2022-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -138,14 +138,18 @@ files:
138
138
  - lib/mailersend/client.rb
139
139
  - lib/mailersend/domains/domains.rb
140
140
  - lib/mailersend/email/email.rb
141
+ - lib/mailersend/email_verification/email_verification.rb
141
142
  - lib/mailersend/inbound_routing/inbound_routing.rb
142
143
  - lib/mailersend/messages/messages.rb
143
144
  - lib/mailersend/recipients/recipients.rb
144
145
  - lib/mailersend/scheduled_messages/scheduled_messages.rb
145
146
  - lib/mailersend/sms/sms.rb
146
147
  - lib/mailersend/sms_activity/sms_activity.rb
148
+ - lib/mailersend/sms_inbounds/sms_inbounds.rb
149
+ - lib/mailersend/sms_messages/sms_messages.rb
147
150
  - lib/mailersend/sms_number/sms_number.rb
148
151
  - lib/mailersend/sms_recipient/sms_recipient.rb
152
+ - lib/mailersend/sms_webhooks/sms_webhooks.rb
149
153
  - lib/mailersend/suppressions/suppressions.rb
150
154
  - lib/mailersend/templates/templates.rb
151
155
  - lib/mailersend/tokens/tokens.rb