jetsms 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/core-ext/hash.rb +8 -0
- data/lib/jetsms/configuration.rb +22 -0
- data/lib/jetsms/date.rb +15 -0
- data/lib/jetsms/sms.rb +46 -0
- data/lib/jetsms/xml_body.rb +17 -0
- metadata +6 -8
- data/.gitignore +0 -14
- data/Gemfile +0 -4
- data/LICENSE.txt +0 -22
- data/README.md +0 -31
- data/Rakefile +0 -2
- data/jetsms.gemspec +0 -23
- data/lib/jetsms/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d9d1a3727327988f35abb64100e7a19539a06b9
|
4
|
+
data.tar.gz: 1fd0ac385ebb0f631bd82598ae620a496eba7d9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3aa9da9c55c0a212051a91f1bf7ec12e0f1b7558bf82ba95f6fd3b036e1751927801de6be3ac8f305d1365c2b1e0aee94fd9446d75d2b81e44577c2889659d39
|
7
|
+
data.tar.gz: 4f57e9fd4bf759d90cbad8752993ec6e34a7fe9c1d259c111421c9a92077e897c8e44c09a6bfaac00a0f40fa3c26bcfd02f474eeace3b8df7a5674b3011e58e7
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module JetSMS
|
2
|
+
class Configuration
|
3
|
+
attr_accessor :host
|
4
|
+
attr_accessor :port
|
5
|
+
attr_accessor :usercode
|
6
|
+
attr_accessor :password
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@host = 'www.biotekno.biz'
|
10
|
+
@port = 8080
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class << self
|
15
|
+
attr_accessor :configuration
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.configure
|
19
|
+
self.configuration ||= Configuration.new
|
20
|
+
yield configuration
|
21
|
+
end
|
22
|
+
end
|
data/lib/jetsms/date.rb
ADDED
data/lib/jetsms/sms.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
module JetSMS
|
2
|
+
class SMS
|
3
|
+
def self.send_sms(recipient, message_text, opts={})
|
4
|
+
valid_options = opts.only(:from, :start_date, :stop_date, :turkish)
|
5
|
+
valid_options.merge!(:start_date => JetSMS::DATE.now) unless valid_options[:start_date]
|
6
|
+
valid_options.merge!(:stop_date => JetSMS::DATE.n_hour_from_now(1)) unless valid_options[:stop_date]
|
7
|
+
|
8
|
+
body = JetSMS::XmlBody.send_sms_body(recipient, message_text, valid_options)
|
9
|
+
|
10
|
+
response = send_request(body)
|
11
|
+
|
12
|
+
result = parse_response(response)
|
13
|
+
"result = #{result}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def sms_status
|
17
|
+
'OK status'
|
18
|
+
end
|
19
|
+
|
20
|
+
def check_balance
|
21
|
+
'OK Balance'
|
22
|
+
end
|
23
|
+
|
24
|
+
def initialize(auth_options={})
|
25
|
+
@auth_options = auth_options
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.send_request(body)
|
29
|
+
header = {
|
30
|
+
"Content-Type" => "text/xml; charset=utf-8",
|
31
|
+
"Content-Length" => body.bytesize.to_s,
|
32
|
+
"Accept" => "*/*"
|
33
|
+
}
|
34
|
+
|
35
|
+
request = Net::HTTP::Post.new('/SMS-Web8/xmlsms', header)
|
36
|
+
request.body = body
|
37
|
+
response = Net::HTTP.new(JetSMS.configuration.host, JetSMS.configuration.port).start {|http| http.request(request) }
|
38
|
+
|
39
|
+
return response.body
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.parse_response(body)
|
43
|
+
body.split(" ")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module JetSMS
|
2
|
+
class XmlBody
|
3
|
+
def self.send_sms_body(recipient, message_text, valid_options)
|
4
|
+
"<?xml version='1.0' #{ "encoding='iso-8859-9'" if valid_options[:turkish] } ?>
|
5
|
+
<message-context type='smmgsd'>
|
6
|
+
<username>#{JetSMS.configuration.usercode}</username>
|
7
|
+
<password>#{JetSMS.configuration.password}</password>
|
8
|
+
<outboxname>#{valid_options[:from]}</outbox-name>
|
9
|
+
<reference></reference>
|
10
|
+
<startdate>#{valid_options[:start_date]}</start-date>
|
11
|
+
<expire-date>#{valid_options[:stop_date]}</expire-date>
|
12
|
+
<text>#{message_text}</text>
|
13
|
+
<gsmnos>#{recipient}</gsmnos>
|
14
|
+
</message-context>"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jetsms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yasin Pehlivanlı
|
@@ -45,14 +45,12 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
-
-
|
49
|
-
- Gemfile
|
50
|
-
- LICENSE.txt
|
51
|
-
- README.md
|
52
|
-
- Rakefile
|
53
|
-
- jetsms.gemspec
|
48
|
+
- lib/core-ext/hash.rb
|
54
49
|
- lib/jetsms.rb
|
55
|
-
- lib/jetsms/
|
50
|
+
- lib/jetsms/configuration.rb
|
51
|
+
- lib/jetsms/date.rb
|
52
|
+
- lib/jetsms/sms.rb
|
53
|
+
- lib/jetsms/xml_body.rb
|
56
54
|
homepage: http://rubygems.org/gems/jetsms
|
57
55
|
licenses:
|
58
56
|
- MIT
|
data/.gitignore
DELETED
data/Gemfile
DELETED
data/LICENSE.txt
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2015 ysn1453
|
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
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# Jetsms
|
2
|
-
|
3
|
-
TODO: Write a gem description
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
```ruby
|
10
|
-
gem 'jetsms'
|
11
|
-
```
|
12
|
-
|
13
|
-
And then execute:
|
14
|
-
|
15
|
-
$ bundle
|
16
|
-
|
17
|
-
Or install it yourself as:
|
18
|
-
|
19
|
-
$ gem install jetsms
|
20
|
-
|
21
|
-
## Usage
|
22
|
-
|
23
|
-
TODO: Write usage instructions here
|
24
|
-
|
25
|
-
## Contributing
|
26
|
-
|
27
|
-
1. Fork it ( https://github.com/[my-github-username]/jetsms/fork )
|
28
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
-
5. Create a new Pull Request
|
data/Rakefile
DELETED
data/jetsms.gemspec
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'jetsms/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "jetsms"
|
8
|
-
spec.version = JetSMS::VERSION
|
9
|
-
spec.authors = ["Yasin Pehlivanlı"]
|
10
|
-
spec.email = ["ysn1988@hotmail.com"]
|
11
|
-
spec.summary = %q{SMS sender for Turkey JetSMS!}
|
12
|
-
spec.description = %q{This gem is for sending SMS using JetSMS services}
|
13
|
-
spec.homepage = "http://rubygems.org/gems/jetsms"
|
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
|
-
end
|
data/lib/jetsms/version.rb
DELETED