sms16client 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.
Files changed (6) hide show
  1. data/Manifest +4 -0
  2. data/README +0 -0
  3. data/Rakefile +12 -0
  4. data/lib/sms16client.rb +80 -0
  5. data/sms16client.gemspec +29 -0
  6. metadata +66 -0
data/Manifest ADDED
@@ -0,0 +1,4 @@
1
+ README
2
+ Rakefile
3
+ lib/sms16client.rb
4
+ Manifest
data/README ADDED
File without changes
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+
5
+ Echoe.new('sms16client', '0.0.1') do |p|
6
+ p.description = "Sms16 Service Consumer"
7
+ p.url = "http://github.com/kohgpat/sms16client"
8
+ p.author = "Nikolay Burlov"
9
+ p.email = "kohgpat@gmail.com"
10
+ p.ignore_pattern = ["tmp/*", "script/*"]
11
+ p.development_dependencies = []
12
+ end
@@ -0,0 +1,80 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'rubygems'
4
+ require 'builder'
5
+ require 'net/http'
6
+ require 'net/https'
7
+ require 'uri'
8
+
9
+ module Sms16Client
10
+ VERSION = '0.0.1'
11
+
12
+ class Client
13
+ attr_accessor :login, :password, :query
14
+
15
+ def initialize(login, password)
16
+ @login = login
17
+ @password = password
18
+ @query = String.new
19
+ end
20
+
21
+ def get_balance
22
+ xml = Builder::XmlMarkup.new(:target => @query)
23
+
24
+ xml.request {
25
+ xml.security {
26
+ xml.login(:value => @login)
27
+ xml.password(:value => @password)
28
+ }
29
+ }
30
+
31
+ return execute_query(@query, 'https://my.sms16.ru/xml/balance.php')
32
+ end
33
+
34
+ def send_message(message, destination, source)
35
+ xml = Builder::XmlMarkup.new(:target => @query)
36
+
37
+ xml.request {
38
+ xml.message(:type => "sms") {
39
+ xml.sender source.to_s
40
+ xml.text message.to_s
41
+ xml.abonent(:phone => destination.to_s, :number_sms => "1")
42
+ }
43
+ xml.security {
44
+ xml.login(:value => @login)
45
+ xml.password(:value => @password)
46
+ }
47
+ }
48
+
49
+ return execute_query(@query, 'https://my.sms16.ru/xml/')
50
+ end
51
+
52
+ def get_message_state(message_id)
53
+ xml = Builder::XmlMarkup.new(:target => @query)
54
+
55
+ xml.request {
56
+ xml.security {
57
+ xml.login(:value => @login)
58
+ xml.password(:value => @password)
59
+ }
60
+ xml.get_state {
61
+ xml.id_sms message_id.to_s
62
+ }
63
+ }
64
+
65
+ return execute_query(@query, 'https://my.sms16.ru/xml/state.php')
66
+ end
67
+
68
+ private
69
+
70
+ def execute_query(query, uri)
71
+ url = URI.parse(uri)
72
+ headers = {"Content-Type" => "text/xml"}
73
+
74
+ request = Net::HTTP.new(url.host, url.port)
75
+ request.use_ssl = true
76
+
77
+ return request.post(url.path, query, headers).body
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{sms16client}
5
+ s.version = "0.0.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Nikolay Burlov"]
9
+ s.date = %q{2011-03-22}
10
+ s.description = %q{Sms16 Service Consumer}
11
+ s.email = %q{kohgpat@gmail.com}
12
+ s.extra_rdoc_files = ["README", "lib/sms16client.rb"]
13
+ s.files = ["README", "Rakefile", "lib/sms16client.rb", "Manifest", "sms16client.gemspec"]
14
+ s.homepage = %q{http://github.com/kohgpat/sms16client}
15
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Sms16client", "--main", "README"]
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = %q{sms16client}
18
+ s.rubygems_version = %q{1.5.0}
19
+ s.summary = %q{Sms16 Service Consumer}
20
+
21
+ if s.respond_to? :specification_version then
22
+ s.specification_version = 3
23
+
24
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
25
+ else
26
+ end
27
+ else
28
+ end
29
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sms16client
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Nikolay Burlov
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-03-22 00:00:00 -04:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description: Sms16 Service Consumer
18
+ email: kohgpat@gmail.com
19
+ executables: []
20
+
21
+ extensions: []
22
+
23
+ extra_rdoc_files:
24
+ - README
25
+ - lib/sms16client.rb
26
+ files:
27
+ - README
28
+ - Rakefile
29
+ - lib/sms16client.rb
30
+ - Manifest
31
+ - sms16client.gemspec
32
+ has_rdoc: true
33
+ homepage: http://github.com/kohgpat/sms16client
34
+ licenses: []
35
+
36
+ post_install_message:
37
+ rdoc_options:
38
+ - --line-numbers
39
+ - --inline-source
40
+ - --title
41
+ - Sms16client
42
+ - --main
43
+ - README
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: "0"
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: "1.2"
58
+ requirements: []
59
+
60
+ rubyforge_project: sms16client
61
+ rubygems_version: 1.5.0
62
+ signing_key:
63
+ specification_version: 3
64
+ summary: Sms16 Service Consumer
65
+ test_files: []
66
+