jetsms 0.0.2 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 78966181765dc441935b8a449b560d35d8c04974
4
- data.tar.gz: 1224b8f985da58aeac3c22ffbb89d165f03564db
3
+ metadata.gz: 9d9d1a3727327988f35abb64100e7a19539a06b9
4
+ data.tar.gz: 1fd0ac385ebb0f631bd82598ae620a496eba7d9c
5
5
  SHA512:
6
- metadata.gz: ec25f2b31072cd55689478c46b2e33c7306ae6eaf12e2025f1937ea5ffc56c3c82589b165e4b78ef7f21fdd3bc2e1292520fefd582348ec3737785fc2f569df0
7
- data.tar.gz: c8fadcc2a40ee73e574bb01c39f8e04392600d2f1a827008bf3b8904d8d06d7f114705191073fcd13b0cab7cc50a4674287224ec506d992c8731aef06bb56dac
6
+ metadata.gz: 3aa9da9c55c0a212051a91f1bf7ec12e0f1b7558bf82ba95f6fd3b036e1751927801de6be3ac8f305d1365c2b1e0aee94fd9446d75d2b81e44577c2889659d39
7
+ data.tar.gz: 4f57e9fd4bf759d90cbad8752993ec6e34a7fe9c1d259c111421c9a92077e897c8e44c09a6bfaac00a0f40fa3c26bcfd02f474eeace3b8df7a5674b3011e58e7
@@ -0,0 +1,8 @@
1
+ class Hash
2
+ def only(*keys)
3
+ inject( {} ) do |new_hash, (key, value)|
4
+ new_hash[key] = value if keys.include?(key)
5
+ new_hash
6
+ end
7
+ end
8
+ end
@@ -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
@@ -0,0 +1,15 @@
1
+ module JetSMS
2
+ class DATE
3
+ def self.now
4
+ format_date(Time.now)
5
+ end
6
+
7
+ def self.n_hour_from_now(duration)
8
+ format_date(Time.now + duration*60*60)
9
+ end
10
+
11
+ def self.format_date(date)
12
+ date.strftime('%d%m%Y%H%M')
13
+ end
14
+ end
15
+ end
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.2
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
- - ".gitignore"
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/version.rb
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
@@ -1,14 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- *.bundle
11
- *.so
12
- *.o
13
- *.a
14
- mkmf.log
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in jetsms.gemspec
4
- gemspec
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
@@ -1,2 +0,0 @@
1
- require "bundler/gem_tasks"
2
-
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
@@ -1,3 +0,0 @@
1
- module JetSMS
2
- VERSION = "0.0.2"
3
- end