orange_push_sms 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f69a3e1e7c1117911542f46a7fbf3363d115a185
4
+ data.tar.gz: 4b87844d5c4a3ad74d1717956a1c8036fde51a9f
5
+ SHA512:
6
+ metadata.gz: d50cef004a27be03c919b90ea3f160dd214da4661a3d37c782fb056767e1ed3538aeeeeb352f5f5fd7c9ebf726f6fabe35f01807a56092c9658c1f2d72b26f46
7
+ data.tar.gz: d1a8ca2167f810ec6e07f8d559d50d3e09ddddcb8365437d2045af9de8d8daff45471d9a818220a74ed79f283632315c2cc1d45bcf067d904dd5b6579c7ab1bb
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /.idea
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ /spec/orange_push_sms_spec.rb
12
+ *.bundle
13
+ *.so
14
+ *.o
15
+ *.a
16
+ *.gem
17
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in orange_push_sms.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Mustafa Sall
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # OrangePushSMS
2
+
3
+ This is a gem written to send SMS through Orange Senegal API
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'orange_push_sms'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install orange_push_sms
20
+
21
+ ## Usage
22
+
23
+ To send an SMS to single recipient use:
24
+
25
+ ```ruby
26
+ message = OrangePushSMS::Message.new msisdn: '22177XXXXXXX', wording: 'Your message here', tpoa: 'SENDER', is_xml: true
27
+ message.send #returns true if successful
28
+ ```
29
+ To multiple recipients
30
+
31
+ ```ruby
32
+ message = OrangePushSMS::Message.new numbers: ['22177XXXXXXX', '22177YYYYYYY', '22176ZZZZZZZ'], wording: "Sending to multiple recipients", tpoa: 'SENDER'
33
+ message.send
34
+ ```
35
+
36
+ ## Contributing
37
+
38
+ 1. Fork it ( https://github.com/divinwind/orange_push_sms/fork )
39
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
40
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
41
+ 4. Push to the branch (`git push origin my-new-feature`)
42
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
@@ -0,0 +1,21 @@
1
+ require 'orange_push_sms/version'
2
+ require 'orange_push_sms/configuration'
3
+ require 'orange_push_sms/message'
4
+ require 'digest'
5
+ require 'nokogiri'
6
+ require 'http'
7
+
8
+ module OrangePushSMS
9
+
10
+ class << self
11
+ attr_accessor :configuration
12
+ end
13
+
14
+ def self.configure
15
+ yield(configuration)
16
+ end
17
+
18
+ def self.configuration
19
+ @configuration ||= Configuration.new
20
+ end
21
+ end
@@ -0,0 +1,12 @@
1
+ module OrangePushSMS
2
+ class Configuration
3
+
4
+ attr_accessor :login
5
+ attr_accessor :pass
6
+
7
+ def initialize
8
+ @login = ''
9
+ @pass = ''
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,72 @@
1
+ require 'nokogiri'
2
+ require 'http'
3
+
4
+ module OrangePushSMS
5
+ class Message
6
+
7
+ BASE_URL = 'https://gsm.orange.sn/push_flux/http.php'
8
+ BASE_URL_XML = 'http://213.154.64.47/push_flux/xml.php'
9
+
10
+ def initialize(options = {})
11
+ @msisdn = options.fetch(:msisdn, '221770000000')
12
+ @wording = options.fetch(:wording, '')
13
+ @tpoa = options.fetch(:tpoa, 'Aphia')
14
+ @numbers = options.fetch(:numbers, [])
15
+ @is_xml = options.has_key?(:is_xml) and options.delete(:is_xml)
16
+ @campaign = 'TESTPUSH'
17
+ end
18
+
19
+ def send
20
+ if @is_xml or @numbers.size > 0
21
+ xml = Nokogiri::XML HTTP.post( BASE_URL_XML, form: {xml: to_xml}).to_s
22
+ xml.xpath("//STATUS_CODE").first.text == "100"
23
+ else
24
+ !(/Return:1/ =~ HTTP.get(BASE_URL, params: to_h).to_s).nil?
25
+ end
26
+ end
27
+
28
+ def to_h
29
+ pass = Digest::MD5.hexdigest(OrangePushSMS.configuration.pass)
30
+ {login: OrangePushSMS.configuration.login,
31
+ pass: pass,
32
+ tpoa: @tpoa,
33
+ msisdn: @msisdn,
34
+ wording: @wording,
35
+ campaign: @campaign}
36
+ end
37
+
38
+ def to_xml
39
+ pass = Digest::MD5.hexdigest(OrangePushSMS.configuration.pass)
40
+ builder = Nokogiri::XML::Builder.new do |xml|
41
+ xml.SESSION(login: OrangePushSMS.configuration.login, pass: pass) do
42
+ xml.CREATE do
43
+ xml.CAMPAIGN(type: '3') do
44
+ xml.NAME @campaign
45
+ xml.START DateTime.now.strftime('%Y-%m-%d-%H-%M')
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
65
+ end
66
+ end
67
+ end
68
+ end
69
+ builder.to_xml
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,3 @@
1
+ module OrangePushSMS
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'orange_push_sms/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'orange_push_sms'
8
+ spec.version = OrangePushSMS::VERSION
9
+ spec.authors = ['Mustafa Sall']
10
+ spec.email = ['taphasall@gmail.com']
11
+ spec.summary = "Une gem pour envoyer des sms via l'api d'orange sénégal"
12
+ spec.description = ""
13
+ spec.homepage = 'https://github.com/divinwind/orange_push_sms'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.7'
22
+ spec.add_development_dependency 'rake', '~> 10.0'
23
+ spec.add_development_dependency 'rspec', '~> 2.99'
24
+ spec.add_runtime_dependency 'http', '~> 1.0'
25
+ spec.add_runtime_dependency 'nokogiri', '~> 1.6'
26
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+
4
+ describe OrangePushSMS do
5
+ describe "#configure" do
6
+ before do
7
+ OrangePushSMS.configure do |config|
8
+ config.login = '*******'
9
+ config.pass = '*******'
10
+ end
11
+ end
12
+
13
+ it 'sends an sms' do
14
+ message = OrangePushSMS::Message.new msisdn: '221775555555', wording: 'A texte message', tpoa: 'orange_push_sms', is_xml: true
15
+ response = message.send
16
+ puts "Message is sent ? - #{response}"
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1 @@
1
+ require 'orange_push_sms'
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: orange_push_sms
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mustafa Sall
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-01-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.99'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.99'
55
+ - !ruby/object:Gem::Dependency
56
+ name: http
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: nokogiri
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.6'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.6'
83
+ description: ''
84
+ email:
85
+ - taphasall@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - Gemfile
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - lib/orange_push_sms.rb
96
+ - lib/orange_push_sms/configuration.rb
97
+ - lib/orange_push_sms/message.rb
98
+ - lib/orange_push_sms/version.rb
99
+ - orange_push_sms.gemspec
100
+ - spec/orange_push_sms_spec_tpl.rb
101
+ - spec/spec_helper.rb
102
+ homepage: https://github.com/divinwind/orange_push_sms
103
+ licenses:
104
+ - MIT
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 2.4.6
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: Une gem pour envoyer des sms via l'api d'orange sénégal
126
+ test_files:
127
+ - spec/orange_push_sms_spec_tpl.rb
128
+ - spec/spec_helper.rb
129
+ has_rdoc: