arolitec_sms 0.1.1 → 0.1.2
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 +4 -4
- data/Gemfile.lock +1 -1
- data/arolitec_sms.gemspec +1 -1
- data/lib/arolitec_sms.rb +1 -1
- data/lib/arolitec_sms/client.rb +43 -24
- data/lib/arolitec_sms/exceptions.rb +1 -0
- data/lib/arolitec_sms/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 527ccc3c7019ae61e583f17e67ec14c21f45656878c9dff6b553073d6c3d9488
|
|
4
|
+
data.tar.gz: 581955fc3eb7df93858eca7d270e0d9555062d7fca1bff5eb7e642342dca0942
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d86b3a1ffe0e6e2ad0ff183f64caca68ca5659c470756746e06c9009a5c0eaa3514bc2b32da772dba481f795ee5650f342ea4a528b54d5b2c2d12776ad97cea8
|
|
7
|
+
data.tar.gz: b623a2e0768c65931dc2a6550d6988048c2547eb99371c043e40052fdf68ed78afe5b7deb4fbf10aecf69593a164a3bf2f34b7b01c4f72759d0259a661f829a9
|
data/Gemfile.lock
CHANGED
data/arolitec_sms.gemspec
CHANGED
|
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
|
|
|
7
7
|
spec.name = "arolitec_sms"
|
|
8
8
|
spec.version = ArolitecSms::VERSION
|
|
9
9
|
spec.authors = ["thkernel"]
|
|
10
|
-
spec.email = ["a.dembele@
|
|
10
|
+
spec.email = ["a.dembele@upcase.net"]
|
|
11
11
|
|
|
12
12
|
spec.summary = %q{Arolitec SMS API HTTP client.}
|
|
13
13
|
spec.description = %q{Ruby HTTP client to interact with Arolitec SMS Gateway.}
|
data/lib/arolitec_sms.rb
CHANGED
data/lib/arolitec_sms/client.rb
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
require "uri"
|
|
1
2
|
require_relative "exceptions"
|
|
2
3
|
|
|
3
4
|
module ArolitecSms
|
|
4
5
|
class Client
|
|
5
6
|
|
|
6
7
|
def send(sender, receiver, content)
|
|
8
|
+
raise ArolitecSms::ArolitecSmsConfigurationError unless api_configured?
|
|
9
|
+
|
|
7
10
|
message = {}
|
|
8
11
|
|
|
9
|
-
message[:charset] = ArolitecSms.configuration.charset
|
|
10
|
-
message[:flash] = ArolitecSms.configuration.flash
|
|
12
|
+
message[:charset] = ArolitecSms.configuration.charset.nil?
|
|
13
|
+
message[:flash] = ArolitecSms.configuration.flash.nil? ? "" : ArolitecSms.configuration.flash
|
|
11
14
|
message[:climsgid] = Time.now.strftime("%Y%m%d%H%M%S")
|
|
12
15
|
message[:numericsender] = ""
|
|
13
16
|
message[:sender] = sender
|
|
@@ -16,40 +19,56 @@ module ArolitecSms
|
|
|
16
19
|
|
|
17
20
|
puts "MESSAGE: #{message}"
|
|
18
21
|
|
|
19
|
-
|
|
22
|
+
send_sms(message)
|
|
20
23
|
|
|
21
|
-
rescue => e
|
|
22
24
|
|
|
23
25
|
end
|
|
24
26
|
|
|
25
27
|
|
|
26
|
-
def api_configured?
|
|
27
28
|
|
|
28
|
-
api_base_url = ArolitecSms.configuration.api_base_url
|
|
29
|
-
send_sms_endpoint = ArolitecSms.configuration.send_sms_endpoint
|
|
30
|
-
api_user_name = ArolitecSms.configuration.api_user_name
|
|
31
|
-
api_user_password = ArolitecSms.configuration.api_user_password
|
|
32
29
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
def api_configured?
|
|
33
|
+
|
|
34
|
+
if ArolitecSms.configuration != nil
|
|
35
|
+
|
|
36
|
+
api_base_url = ArolitecSms.configuration.api_base_url
|
|
37
|
+
send_sms_endpoint = ArolitecSms.configuration.send_sms_endpoint
|
|
38
|
+
api_user_name = ArolitecSms.configuration.api_user_name
|
|
39
|
+
api_user_password = ArolitecSms.configuration.api_user_password
|
|
40
|
+
|
|
41
|
+
if api_base_url.nil? || send_sms_endpoint.nil? || api_user_name.nil? || api_user_password.nil?
|
|
42
|
+
|
|
43
|
+
return false
|
|
44
|
+
|
|
45
|
+
else
|
|
46
|
+
|
|
47
|
+
return true
|
|
48
|
+
end
|
|
49
|
+
else
|
|
50
|
+
return false
|
|
51
|
+
end
|
|
52
|
+
rescue StandardError => e
|
|
53
|
+
e.to_s
|
|
54
|
+
|
|
37
55
|
end
|
|
38
|
-
|
|
39
|
-
end
|
|
56
|
+
|
|
40
57
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if api_configured?
|
|
58
|
+
|
|
59
|
+
def send_sms(message)
|
|
44
60
|
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
endpoint = ArolitecSms.configuration.send_sms_endpoint
|
|
45
64
|
# Inialize a new connection.
|
|
46
65
|
connexion = Faraday.new(ArolitecSms.configuration.api_base_url)
|
|
47
66
|
|
|
48
|
-
payload = "?user=#{ArolitecSms.configuration.api_user_name}&password=#{ArolitecSms.configuration.api_user_password}&sender=#{message[:sender]}&
|
|
49
|
-
er=#{message[:receiver]}&content=#{message[:content]}"
|
|
67
|
+
payload = "?user=#{ArolitecSms.configuration.api_user_name}&password=#{ArolitecSms.configuration.api_user_password}&sender=#{message[:sender]}&receiver=#{message[:receiver]}&content=#{message[:content]}"
|
|
50
68
|
|
|
69
|
+
puts "LE PAYLOAD: #{URI.encode(payload)}"
|
|
51
70
|
response = connexion.post do |req|
|
|
52
|
-
req.url
|
|
71
|
+
req.url endpoint + URI.encode(payload)
|
|
53
72
|
#req.headers['Content-Type'] = 'application/json'
|
|
54
73
|
#req.headers['Authorization'] = 'Bearer ' + ArolitecSms.configuration.access_token
|
|
55
74
|
#req.body = payload.to_json
|
|
@@ -63,12 +82,12 @@ module ArolitecSms
|
|
|
63
82
|
|
|
64
83
|
elsif response.status == 401
|
|
65
84
|
puts "LA REPONSE DE LA REQUETTE EST: #{response.body}"
|
|
85
|
+
return response
|
|
66
86
|
|
|
67
87
|
end
|
|
68
|
-
|
|
69
|
-
|
|
88
|
+
|
|
89
|
+
|
|
70
90
|
end
|
|
71
|
-
end
|
|
72
91
|
|
|
73
92
|
end
|
|
74
93
|
end
|
data/lib/arolitec_sms/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: arolitec_sms
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- thkernel
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-04-
|
|
11
|
+
date: 2020-04-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -54,7 +54,7 @@ dependencies:
|
|
|
54
54
|
version: '10.0'
|
|
55
55
|
description: Ruby HTTP client to interact with Arolitec SMS Gateway.
|
|
56
56
|
email:
|
|
57
|
-
- a.dembele@
|
|
57
|
+
- a.dembele@upcase.net
|
|
58
58
|
executables: []
|
|
59
59
|
extensions: []
|
|
60
60
|
extra_rdoc_files: []
|