orange_push_sms 0.0.1 → 1.0.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 +4 -4
- data/README.md +13 -8
- data/lib/orange_push_sms/configuration.rb +4 -4
- data/lib/orange_push_sms/message.rb +35 -51
- data/lib/orange_push_sms/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e23e086a46a98a23227b0ff26fba3a11a252b9e
|
4
|
+
data.tar.gz: bdab4d718b9a142cd8e641c7cd210eb97957bede
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c12acac855ac70c577eb0e5d382f49f787f939fae596257efafa969a99a07e2618651b0e6a02a00c32a980ec7435ff1915cb766e9a5ea40f2f4a6c289b63b0c
|
7
|
+
data.tar.gz: a3cc2f55caa9ecf6c1d66845b299609125bcf75227d1f4e8fc39d5835987b2a9af2c1b647daa341e2170c71b8c02687fbbcec2d1f5dd218d553b3749dccc9778
|
data/README.md
CHANGED
@@ -18,21 +18,26 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
$ gem install orange_push_sms
|
20
20
|
|
21
|
-
##
|
21
|
+
## Configuration
|
22
22
|
|
23
|
-
|
23
|
+
In config/initializers create a file orange_push_sms.rb:
|
24
24
|
|
25
25
|
```ruby
|
26
|
-
|
27
|
-
|
26
|
+
OrangePushSMS.configure do |config|
|
27
|
+
config.user = 'LOGIN'
|
28
|
+
config.token = 'TOKEN'
|
29
|
+
config.secret = 'API KEY'
|
30
|
+
end
|
28
31
|
```
|
29
|
-
|
32
|
+
|
33
|
+
## Usage
|
34
|
+
|
35
|
+
To send an SMS :
|
30
36
|
|
31
37
|
```ruby
|
32
|
-
message = OrangePushSMS::Message.new
|
33
|
-
message.send
|
38
|
+
message = OrangePushSMS::Message.new recipients: ['22177XXXXXXX'], content: 'Your message here', signature: 'SENDER', subject: 'Subject'
|
39
|
+
message.send #returns true if successful
|
34
40
|
```
|
35
|
-
|
36
41
|
## Contributing
|
37
42
|
|
38
43
|
1. Fork it ( https://github.com/divinwind/orange_push_sms/fork )
|
@@ -4,69 +4,53 @@ require 'http'
|
|
4
4
|
module OrangePushSMS
|
5
5
|
class Message
|
6
6
|
|
7
|
-
BASE_URL = 'https://
|
8
|
-
BASE_URL_XML = 'http://213.154.64.47/push_flux/xml.php'
|
7
|
+
BASE_URL = 'https://api.orangesmspro.sn:8443/api/xml'
|
9
8
|
|
10
9
|
def initialize(options = {})
|
11
|
-
@
|
12
|
-
@
|
13
|
-
@
|
14
|
-
@
|
15
|
-
@is_xml = options.has_key?(:is_xml) and options.delete(:is_xml)
|
16
|
-
@campaign = 'TESTPUSH'
|
10
|
+
@recipients = options.fetch(:recipients, [])
|
11
|
+
@content = options.fetch(:content, '')
|
12
|
+
@signature = options.fetch(:signature, 'Aphia')
|
13
|
+
@subject = options.fetch(:subject, '')
|
17
14
|
end
|
18
15
|
|
19
|
-
def
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
16
|
+
def config
|
17
|
+
OrangePushSMS.configuration
|
18
|
+
end
|
19
|
+
|
20
|
+
def timestamp
|
21
|
+
@timestamp ||= Time.now.to_i
|
26
22
|
end
|
27
23
|
|
28
|
-
def
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
msisdn: @msisdn,
|
34
|
-
wording: @wording,
|
35
|
-
campaign: @campaign}
|
24
|
+
def digest
|
25
|
+
d = OpenSSL::Digest.new('sha1')
|
26
|
+
OpenSSL::HMAC.hexdigest d,
|
27
|
+
config.secret,
|
28
|
+
"#{config.token}#{to_xml}#{timestamp}"
|
36
29
|
end
|
37
30
|
|
38
31
|
def to_xml
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
xml.
|
43
|
-
|
44
|
-
|
45
|
-
xml.
|
46
|
-
xml.END DateTime.now.strftime('%Y-%m-%d-%H-%M')
|
47
|
-
xml.TPOA @tpoa
|
48
|
-
if @numbers.size > 0
|
49
|
-
xml.GEN do
|
50
|
-
xml.WORDING @wording
|
51
|
-
xml.NUMBERS do
|
52
|
-
@numbers.each do |number|
|
53
|
-
xml.NUMBER number
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
else
|
58
|
-
xml.PERSO do
|
59
|
-
xml.MESSAGE do
|
60
|
-
xml.NUMBER @msisdn
|
61
|
-
xml.WORDING @wording
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
32
|
+
@builder ||= Nokogiri::XML::Builder.new do |xml|
|
33
|
+
xml.session do
|
34
|
+
xml.type 1
|
35
|
+
xml.content @content
|
36
|
+
xml.recipients do
|
37
|
+
@recipients.each do |recipient|
|
38
|
+
xml.recipient recipient
|
65
39
|
end
|
66
40
|
end
|
41
|
+
xml.signature @signature
|
42
|
+
xml.subject @subject
|
67
43
|
end
|
68
|
-
end
|
69
|
-
|
44
|
+
end.to_xml
|
45
|
+
end
|
46
|
+
|
47
|
+
def send
|
48
|
+
uri = "#{BASE_URL}?token=#{config.token}&key=#{digest}×tamp=#{timestamp}"
|
49
|
+
ctx = OpenSSL::SSL::SSLContext.new
|
50
|
+
ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
51
|
+
xml = Nokogiri::XML HTTP.basic_auth(user: config.user, pass: config.token)
|
52
|
+
.post(uri, body: to_xml, ssl_context: ctx)
|
53
|
+
puts xml
|
70
54
|
end
|
71
55
|
end
|
72
56
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: orange_push_sms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mustafa Sall
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
119
|
version: '0'
|
120
120
|
requirements: []
|
121
121
|
rubyforge_project:
|
122
|
-
rubygems_version: 2.
|
122
|
+
rubygems_version: 2.6.2
|
123
123
|
signing_key:
|
124
124
|
specification_version: 4
|
125
125
|
summary: Une gem pour envoyer des sms via l'api d'orange sénégal
|