promotexter 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +42 -0
- data/lib/promotexter.rb +7 -0
- data/lib/promotexter/base.rb +22 -0
- data/lib/promotexter/http_client.rb +16 -0
- data/lib/promotexter/messenger.rb +27 -0
- data/lib/promotexter/version.rb +3 -0
- data/lib/tasks/promotexter_tasks.rake +4 -0
- data/test/promotexter_test.rb +20 -0
- data/test/sms_test.rb +19 -0
- data/test/test_helper.rb +20 -0
- metadata +87 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 80820699b0b7d984b951894de550f80053e4690f
|
4
|
+
data.tar.gz: 6aaeb880f5dad98a9cf1683805d53b88070d02c0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 974d4adbd1991e3088111caf10acd0d9337eb17c09acd6cc2b239d1ae50a603dd55c190a74363c7ffc77af80c112bf33edb65fb40ea394b5fbba3d97db25f48c
|
7
|
+
data.tar.gz: e71c7694b6c9c01c15789493108c46c1e75a79c4ca4e5acde45ff0b5fbb9862fc9913ca2d5aac4ef1fa20e50d338d55f82f5a74bd39e5364fd4f9e1e5db93de8
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2016 Den Mark Meralpis
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
= Promotexter
|
2
|
+
|
3
|
+
This project rocks and uses MIT-LICENSE.
|
4
|
+
|
5
|
+
<b>initialize</b>
|
6
|
+
|
7
|
+
clientid = ''
|
8
|
+
senderid = ''
|
9
|
+
passkey = ''
|
10
|
+
|
11
|
+
restprovider = Promotexter::Base.new(clientid, senderid, passkey)
|
12
|
+
|
13
|
+
<b>Sending SMS</b>
|
14
|
+
response = restprovider.send_sms(message, recipient)
|
15
|
+
|
16
|
+
<b>Get Available Balance</b>
|
17
|
+
response = restprovider.get_balance
|
data/Rakefile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new
|
5
|
+
|
6
|
+
task :default => :spec
|
7
|
+
task :test => :spec
|
8
|
+
|
9
|
+
# begin
|
10
|
+
# require 'bundler/setup'
|
11
|
+
# rescue LoadError
|
12
|
+
# puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# require 'rdoc/task'
|
16
|
+
#
|
17
|
+
# RDoc::Task.new(:rdoc) do |rdoc|
|
18
|
+
# rdoc.rdoc_dir = 'rdoc'
|
19
|
+
# rdoc.title = 'Promotexter'
|
20
|
+
# rdoc.options << '--line-numbers'
|
21
|
+
# rdoc.rdoc_files.include('README.rdoc')
|
22
|
+
# rdoc.rdoc_files.include('lib/**/*.rb')
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
#
|
26
|
+
#
|
27
|
+
#
|
28
|
+
#
|
29
|
+
#
|
30
|
+
# Bundler::GemHelper.install_tasks
|
31
|
+
#
|
32
|
+
# require 'rake/testtask'
|
33
|
+
#
|
34
|
+
# Rake::TestTask.new(:test) do |t|
|
35
|
+
# t.libs << 'lib'
|
36
|
+
# t.libs << 'test'
|
37
|
+
# t.pattern = 'test/**/*_test.rb'
|
38
|
+
# t.verbose = false
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
#
|
42
|
+
# task default: :test
|
data/lib/promotexter.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
module Promotexter
|
2
|
+
class Base
|
3
|
+
|
4
|
+
def initialize clientid, senderid, passkey
|
5
|
+
@domain = "http://promotexter.com"
|
6
|
+
@clientid = clientid
|
7
|
+
@senderid = senderid
|
8
|
+
@passkey = passkey
|
9
|
+
end
|
10
|
+
|
11
|
+
def send_sms(message, recipient)
|
12
|
+
messenger = Messenger.new @domain, @clientid, @senderid, @passkey
|
13
|
+
messenger.send_sms(message, recipient)
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_balance
|
17
|
+
messenger = Messenger.new @domain, @clientid, @senderid, @passkey
|
18
|
+
messenger.get_balance
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
3
|
+
module Promotexter
|
4
|
+
module HttpClient
|
5
|
+
def get(url)
|
6
|
+
uri = URI(url)
|
7
|
+
|
8
|
+
req = Net::HTTP::Get.new(uri)
|
9
|
+
|
10
|
+
Net::HTTP.start(uri.host, uri.port,
|
11
|
+
:use_ssl => uri.scheme == 'https') do |http|
|
12
|
+
response = http.request req # Net::HTTPResponse object
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'http_client.rb')
|
2
|
+
|
3
|
+
module Promotexter
|
4
|
+
class Messenger
|
5
|
+
|
6
|
+
include HttpClient
|
7
|
+
|
8
|
+
def initialize domain, clientid, senderid, passkey
|
9
|
+
@domain = domain
|
10
|
+
@clientid = clientid
|
11
|
+
@senderid = senderid
|
12
|
+
@passkey = passkey
|
13
|
+
end
|
14
|
+
|
15
|
+
def send_sms message, recipient
|
16
|
+
message = URI.encode(message)
|
17
|
+
url = "#{@domain}/sendsms.php?clientid=#{@clientid}&passkey=#{@passkey}&msisdn=#{recipient}&message=#{message}&senderid=#{@senderid}&encoding=url"
|
18
|
+
get(url)
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_balance
|
22
|
+
url = "#{@domain}/getbalance.php?clientid=#{@clientid}&passkey=#{@passkey}"
|
23
|
+
get(url)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class PromotexterTest < ActiveSupport::TestCase
|
4
|
+
# test "truth" do
|
5
|
+
# assert_kind_of Module, Promotexter
|
6
|
+
# end
|
7
|
+
|
8
|
+
test "Send SMS" do
|
9
|
+
clientid = '20000739'
|
10
|
+
passkey = 'E5CD404AB8CE31EB7E4906D3D90271D8'
|
11
|
+
msisdn = '639778198061'
|
12
|
+
senderid = 'Demo'
|
13
|
+
message = URI.escape(message)
|
14
|
+
|
15
|
+
rest_provider = Promotexter::Base.new(clientid, senderid, passkey)
|
16
|
+
response = rest_provider.send_sms('Testing Promotexter Gem 0.0.2', '639778198061')
|
17
|
+
assert_not_equal(response.body.to_s, '-1')
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
data/test/sms_test.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# require 'uri'
|
2
|
+
# require 'test_helper'
|
3
|
+
#
|
4
|
+
# class SmsTest < ActiveSupport::TestCase
|
5
|
+
#
|
6
|
+
# def test_to_send_sms
|
7
|
+
# clientid='20000739'
|
8
|
+
# passkey='E5CD404AB8CE31EB7E4906D3D90271D8'
|
9
|
+
# msisdn='639778198061'
|
10
|
+
# message='Hello World!'
|
11
|
+
# senderid='Demo'
|
12
|
+
# message = URI.escape(message)
|
13
|
+
# domain = "http://promotexter.com"
|
14
|
+
#
|
15
|
+
# restprovider = Promotexter::Base.new(clientid, senderid, passkey)
|
16
|
+
# response = restprovider.send_sms(message, msisdn)
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
# require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
|
5
|
+
# ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]
|
6
|
+
require "rails/test_help"
|
7
|
+
|
8
|
+
# Filter out Minitest backtrace while allowing backtrace from other libraries
|
9
|
+
# to be shown.
|
10
|
+
Minitest.backtrace_filter = Minitest::BacktraceFilter.new
|
11
|
+
|
12
|
+
# Load support files
|
13
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
14
|
+
|
15
|
+
# Load fixtures from the engine
|
16
|
+
if ActiveSupport::TestCase.respond_to?(:fixture_path=)
|
17
|
+
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
|
18
|
+
ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
|
19
|
+
ActiveSupport::TestCase.fixtures :all
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: promotexter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- denmarkmeralpis
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-10-03 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.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
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
|
+
description: The gem provides a simple way of sending SMS via Promotexter API
|
42
|
+
email:
|
43
|
+
- denmark@nueca.net
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- MIT-LICENSE
|
49
|
+
- README.rdoc
|
50
|
+
- Rakefile
|
51
|
+
- lib/promotexter.rb
|
52
|
+
- lib/promotexter/base.rb
|
53
|
+
- lib/promotexter/http_client.rb
|
54
|
+
- lib/promotexter/messenger.rb
|
55
|
+
- lib/promotexter/version.rb
|
56
|
+
- lib/tasks/promotexter_tasks.rake
|
57
|
+
- test/promotexter_test.rb
|
58
|
+
- test/sms_test.rb
|
59
|
+
- test/test_helper.rb
|
60
|
+
homepage: http://genmcrg.com
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.4.8
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: Simple way of sending SMS via Promotexter API
|
84
|
+
test_files:
|
85
|
+
- test/promotexter_test.rb
|
86
|
+
- test/sms_test.rb
|
87
|
+
- test/test_helper.rb
|