smess 2.0.8 → 2.2.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: 90d1e52ab3e6f1d8ae4640292cec28b848f3acedb32ec69d1b4b3a971f9d7b8e
4
- data.tar.gz: 230d748d26760a0387eab912dce1e7de92a5224edf4c75e3c32ad2b01795c56e
3
+ metadata.gz: 4a55b648177448474907c0d1e8a1236b602c5473709d6ff71c6e1b4f669a489c
4
+ data.tar.gz: 9e67c5b6066fb5298afe6d04296efc6f77a258c78d9d336312c129fbf25745f7
5
5
  SHA512:
6
- metadata.gz: 96e79778835ca11d3baecbbe4c3ca861a6030e1e4f0efd841ab1683803a2220cf9e8cfdefdf84c5dd8b7683bf61509bba9181456c261e180ee22b345087e365b
7
- data.tar.gz: 4fda0f5f94fc7ed8b1e29c535d825f520a6ffb4af2b079a9a5b8c646d883219b8e64f175790a8b0e8eb66636a81187b07023e269d7f311dcd82751c3b850b0b4
6
+ metadata.gz: 17fae43d95fdee89661a81f4ac1faa2a140375fdc88c454e9c4a8fad640eece26fa67c0c5f972a47944c24a89135685cb8577cf4fa272f20162db8dee0fe65ad
7
+ data.tar.gz: 31cc82823c4fefe06f10cabca2ac0909ea84b89ca9c0f4ddfad8e432d3765c9812c08b14505e450b5426a090548ae518b7227a5c7084f715825d871fc6f280fb
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smess (2.0.8)
4
+ smess (2.2.0)
5
5
  activesupport (>= 5.2.6, < 7.0.0)
6
6
  clickatell (~> 0)
7
7
  httpi (~> 1.1)
@@ -12,7 +12,7 @@ PATH
12
12
  GEM
13
13
  remote: https://rubygems.org/
14
14
  specs:
15
- activesupport (6.1.6)
15
+ activesupport (6.1.7)
16
16
  concurrent-ruby (~> 1.0, >= 1.0.2)
17
17
  i18n (>= 1.6, < 2)
18
18
  minitest (>= 5.1)
@@ -27,29 +27,40 @@ GEM
27
27
  diff-lcs (1.3)
28
28
  docile (1.3.2)
29
29
  dotenv (2.7.5)
30
- faraday (2.3.0)
31
- faraday-net_http (~> 2.0)
30
+ faraday (2.7.1)
31
+ faraday-net_http (>= 2.0, < 3.1)
32
32
  ruby2_keywords (>= 0.0.4)
33
- faraday-net_http (2.0.3)
33
+ faraday-net_http (3.0.2)
34
34
  gyoku (0.4.6)
35
35
  builder (>= 2.1.2)
36
36
  httpi (1.1.1)
37
37
  rack
38
- i18n (1.10.0)
38
+ i18n (1.12.0)
39
39
  concurrent-ruby (~> 1.0)
40
40
  json (2.3.0)
41
- jwt (2.4.1)
42
- mail (2.7.1)
41
+ jwt (2.5.0)
42
+ mail (2.8.0)
43
43
  mini_mime (>= 0.1.1)
44
+ net-imap
45
+ net-pop
46
+ net-smtp
44
47
  mini_mime (1.1.2)
45
48
  mini_portile2 (2.8.0)
46
- minitest (5.15.0)
47
- nokogiri (1.13.6)
49
+ minitest (5.16.3)
50
+ net-imap (0.3.1)
51
+ net-protocol
52
+ net-pop (0.1.2)
53
+ net-protocol
54
+ net-protocol (0.2.1)
55
+ timeout
56
+ net-smtp (0.3.3)
57
+ net-protocol
58
+ nokogiri (1.13.10)
48
59
  mini_portile2 (~> 2.8.0)
49
60
  racc (~> 1.4)
50
61
  nori (1.1.5)
51
- racc (1.6.0)
52
- rack (2.2.3.1)
62
+ racc (1.6.1)
63
+ rack (3.0.2)
53
64
  rspec (3.9.0)
54
65
  rspec-core (~> 3.9.0)
55
66
  rspec-expectations (~> 3.9.0)
@@ -77,16 +88,17 @@ GEM
77
88
  json (>= 1.8, < 3)
78
89
  simplecov-html (~> 0.10.0)
79
90
  simplecov-html (0.10.2)
80
- twilio-ruby (5.67.2)
91
+ timeout (0.3.1)
92
+ twilio-ruby (5.73.4)
81
93
  faraday (>= 0.9, < 3.0)
82
94
  jwt (>= 1.5, <= 2.5)
83
95
  nokogiri (>= 1.6, < 2.0)
84
- tzinfo (2.0.4)
96
+ tzinfo (2.0.5)
85
97
  concurrent-ruby (~> 1.0)
86
98
  wasabi (2.5.1)
87
99
  httpi (~> 1.0)
88
100
  nokogiri (>= 1.4.0)
89
- zeitwerk (2.5.4)
101
+ zeitwerk (2.6.6)
90
102
 
91
103
  PLATFORMS
92
104
  ruby
@@ -98,4 +110,4 @@ DEPENDENCIES
98
110
  smess!
99
111
 
100
112
  BUNDLED WITH
101
- 1.17.3
113
+ 2.3.25
data/lib/smess/output.rb CHANGED
@@ -19,5 +19,9 @@ module Smess
19
19
  raise NotImplementedError.new("You must define deliver in your Smess output class")
20
20
  end
21
21
 
22
+ def send_feedback(_message_sid)
23
+ nil
24
+ end
25
+
22
26
  end
23
27
  end
@@ -11,6 +11,11 @@ module Smess
11
11
  out.deliver.merge({sent_with: output_name})
12
12
  end
13
13
 
14
+ def send_feedback(message_sid)
15
+ out = output_for sms.to
16
+ out.send_feedback(message_sid)
17
+ end
18
+
14
19
  def get_output_name_for_msisdn(msisdn)
15
20
  3.downto(0).each do |index|
16
21
  return Smess.config.output_by_country_code[msisdn[0..index]] if Smess.config.output_by_country_code.key? msisdn[0..index]
@@ -10,6 +10,7 @@ module Smess
10
10
  end
11
11
 
12
12
  attr_accessor :sid, :auth_token, :from, :messaging_service_sid, :callback_url
13
+
13
14
  def validate_config
14
15
  @sid = config.fetch(:sid)
15
16
  @auth_token = config.fetch(:auth_token)
@@ -18,6 +19,10 @@ module Smess
18
19
  @callback_url = config.fetch(:callback_url)
19
20
  end
20
21
 
22
+ def send_feedback(message_sid)
23
+ client.messages(message_sid).feedback.create(outcome: "confirmed")
24
+ end
25
+
21
26
  def deliver
22
27
  send_one_sms sms.message
23
28
  end
@@ -31,22 +36,30 @@ module Smess
31
36
  end
32
37
 
33
38
  def split_parts
34
- Smess.separate_sms(sms.message).reject {|s| s.empty? }
39
+ Smess.separate_sms(sms.message).reject { |s| s.empty? }
40
+ end
41
+
42
+ def to
43
+ "+#{sms.to}"
44
+ end
45
+
46
+ def sender
47
+ if messaging_service_sid.present?
48
+ {messaging_service_sid: messaging_service_sid}
49
+ else
50
+ {from: from}
51
+ end
35
52
  end
36
53
 
37
54
  def send_one_sms(message)
38
55
  begin
39
56
  opts = {
40
- to: "+#{sms.to}",
57
+ to: to,
41
58
  body: message,
42
59
  status_callback: callback_url,
43
60
  provide_feedback: true
44
61
  }
45
- if messaging_service_sid.present?
46
- opts[:messaging_service_sid] = messaging_service_sid
47
- else
48
- opts[:from] = from
49
- end
62
+ opts.merge!(sender)
50
63
  response = create_client_message(opts)
51
64
  result = normal_result(response)
52
65
  rescue => e
@@ -0,0 +1,17 @@
1
+ require 'twilio-ruby'
2
+
3
+ module Smess
4
+ class TwilioWhatsapp < Twilio
5
+
6
+ private
7
+
8
+ def to
9
+ "whatsapp:+#{sms.to}"
10
+ end
11
+
12
+ def sender
13
+ {from: "whatsapp:+#{from}"}
14
+ end
15
+
16
+ end
17
+ end
data/lib/smess/sms.rb CHANGED
@@ -21,5 +21,12 @@ module Smess
21
21
  results[:response_code] == "0"
22
22
  end
23
23
 
24
+ def send_feedback(to, message_sid)
25
+ out = Smess.named_output_instance(output)
26
+ @to = to
27
+ out.sms = self
28
+ out.send_feedback(message_sid)
29
+ end
30
+
24
31
  end
25
32
  end
data/lib/smess/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Smess
2
- VERSION = '2.0.8'
2
+ VERSION = '2.2.0'
3
3
  end
data/lib/smess.rb CHANGED
@@ -23,6 +23,7 @@ require 'smess/outputs/global_mouth'
23
23
  require 'smess/outputs/link_mobility'
24
24
  require 'smess/outputs/mblox'
25
25
  require 'smess/outputs/twilio'
26
+ require 'smess/outputs/twilio_whatsapp'
26
27
  require 'smess/outputs/iconectiv'
27
28
  require 'smess/outputs/test'
28
29
 
@@ -59,7 +60,7 @@ module Smess
59
60
  @nothing = false
60
61
  @default_output = nil
61
62
  @default_sender_id = "Smess"
62
- @output_types = %i{auto card_board_fish clickatell global_mouth link_mobility iconectiv mblox smsglobal twilio}
63
+ @output_types = %i{auto card_board_fish clickatell global_mouth link_mobility iconectiv mblox smsglobal twilio twilio_whatsapp}
63
64
  @configured_outputs = {}
64
65
  @output_by_country_code = {}
65
66
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smess
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.8
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Westin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-09 00:00:00.000000000 Z
11
+ date: 2022-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -169,6 +169,7 @@ files:
169
169
  - lib/smess/outputs/smsglobal.rb
170
170
  - lib/smess/outputs/test.rb
171
171
  - lib/smess/outputs/twilio.rb
172
+ - lib/smess/outputs/twilio_whatsapp.rb
172
173
  - lib/smess/sms.rb
173
174
  - lib/smess/utils.rb
174
175
  - lib/smess/version.rb
@@ -193,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
194
  - !ruby/object:Gem::Version
194
195
  version: 1.3.7
195
196
  requirements: []
196
- rubygems_version: 3.0.3
197
+ rubygems_version: 3.1.6
197
198
  signing_key:
198
199
  specification_version: 4
199
200
  summary: A messy SMS messenger supporting every aggregator I have gotten my hands