mailersend-ruby 1.1.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: e8d67b989e26722f62ec3b556872643721be50947b67392f899f75115bb5dd9b
4
- data.tar.gz: 5b9ee2fe25d34a07f71f38ff5a88137abcf22cfd1619b88b4505646e1f8facc2
3
+ metadata.gz: '09a27b08a3b4c39332875fd10dd414301eeb58d5fcf06b5ec5001a3f76d51933'
4
+ data.tar.gz: 3a687d31a6723878adec8bb954cf6091e3bcfa8a1c783a80cb9e1b9289ca1ac4
5
5
  SHA512:
6
- metadata.gz: 5f59c4b41f8134c36df9e0dd8c3365444719d942a6a6c57e1643bd58c3973dfbb768c922b3df2291eb1e2fbb8d99df14df40e3a4dd26ebb0caade3c999cb45d0
7
- data.tar.gz: ebcb98375a4a56f3d6033dd93fecd22bef6019ac58d2338701aaa061a6579306ccf44311a202df5194a142ac0ae55f2bc880aa6595f98e09774503ce2359a298
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,12 @@
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
+
3
10
  ## [1.1.0] - 2022-02-18
4
11
 
5
12
  - Domains endpoint improvements
data/README.md CHANGED
@@ -67,6 +67,19 @@ 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
+ - [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)
70
83
  - [Support and Feedback](#support-and-feedback)
71
84
  - [License](#license)
72
85
 
@@ -682,6 +695,127 @@ ms_templates = Mailersend::Templates.new
682
695
  ms_templates.delete(template_id: "id124")
683
696
  ```
684
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
+
685
819
  # Support and Feedback
686
820
 
687
821
  In case you find any bugs, submit an issue directly here in GitHub.
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mailersend
4
- VERSION = '1.1.0'
4
+ VERSION = '1.2.0'
5
5
  end
data/lib/mailersend.rb CHANGED
@@ -11,6 +11,10 @@ require_relative 'mailersend/inbound_routing/inbound_routing'
11
11
  require_relative 'mailersend/messages/messages'
12
12
  require_relative 'mailersend/recipients/recipients'
13
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'
14
18
  require_relative 'mailersend/suppressions/suppressions'
15
19
  require_relative 'mailersend/templates/templates'
16
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.1.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-18 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
@@ -142,6 +142,10 @@ files:
142
142
  - lib/mailersend/messages/messages.rb
143
143
  - lib/mailersend/recipients/recipients.rb
144
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
145
149
  - lib/mailersend/suppressions/suppressions.rb
146
150
  - lib/mailersend/templates/templates.rb
147
151
  - lib/mailersend/tokens/tokens.rb
@@ -173,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
177
  - !ruby/object:Gem::Version
174
178
  version: '0'
175
179
  requirements: []
176
- rubygems_version: 3.3.3
180
+ rubygems_version: 3.3.7
177
181
  signing_key:
178
182
  specification_version: 4
179
183
  summary: MailerSend's official Ruby SDK