sms-client 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in sms-client.gemspec
4
+ gemspec
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,52 @@
1
+ require "sms-client/version"
2
+ require 'rest_client'
3
+ require "crack/xml"
4
+
5
+ module SMS
6
+ module Client
7
+ class Moonshado
8
+ attr_accessor :api_key, :message, :reporting_key, :originating_address, :device_address, :keyword, :body, :response
9
+
10
+ def self.send_message(&block)
11
+ request = SMS::Client::Moonshado.new
12
+ request.instance_eval(&block)
13
+ request.send_sms
14
+
15
+ end
16
+
17
+ def send_sms
18
+ begin
19
+ d = {
20
+ :api_key => self.api_key,
21
+ :message => {
22
+ :reporting_key => self.reporting_key,
23
+ :originating_address => self.originating_address,
24
+ :device_address => self.device_address,
25
+ :keyword => self.keyword,
26
+ :body => self.body
27
+ }
28
+ }
29
+ r = RestClient.post 'http://api.moonshado.com/gateway/sms', d
30
+
31
+ #TODO We should do something about these statuses!
32
+ code = Crack::XML.parse(r)["status"]["code"] rescue nil
33
+ info = Crack::XML.parse(r)["status"]["info"] rescue nil
34
+ puts "code:#{code} info:#{info}"
35
+ rescue Exception => e
36
+ raise e.response
37
+ end
38
+
39
+ end
40
+ end
41
+
42
+ end
43
+ end
44
+
45
+ m = SMS::Client::Moonshado.send_message do |request|
46
+ request.api_key = "ZZS268NGGQZWRSG2"
47
+ request.body = "[ARREST SOS] New Assignment for zip code 75126 https://arrestsos.com/34f2X"
48
+ request.keyword = "arrestsos"
49
+ request.reporting_key = "12300127"
50
+ request.originating_address = '75572'
51
+ request.device_address = '12145328951'
52
+ end
@@ -0,0 +1,5 @@
1
+ module SMS
2
+ module Client
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "sms-client/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "sms-client"
7
+ s.version = SMS::Client::VERSION
8
+ s.authors = ["Nathan Clark"]
9
+ s.email = ["nathanclark80@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{sms client}
12
+ s.description = %q{sms client}
13
+
14
+ s.rubyforge_project = "sms-client"
15
+
16
+ #s.files = `git ls-files`.split("\n")
17
+ s.files = ['Gemfile', 'Rakefile', 'lib/sms-client.rb', 'lib/sms-client/version.rb', 'sms-client.gemspec'];
18
+ #s.test_files = `git ls-files -- {spec}/*`. split("\n")
19
+ #s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ # specify any dependencies here; for example:
23
+ s.add_development_dependency "rspec"
24
+ s.add_runtime_dependency "rest-client"
25
+ s.add_runtime_dependency "crack"
26
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sms-client
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Nathan Clark
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-03-09 00:00:00 -06:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rspec
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :development
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: rest-client
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :runtime
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: crack
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ type: :runtime
62
+ version_requirements: *id003
63
+ description: sms client
64
+ email:
65
+ - nathanclark80@gmail.com
66
+ executables: []
67
+
68
+ extensions: []
69
+
70
+ extra_rdoc_files: []
71
+
72
+ files:
73
+ - Gemfile
74
+ - Rakefile
75
+ - lib/sms-client.rb
76
+ - lib/sms-client/version.rb
77
+ - sms-client.gemspec
78
+ has_rdoc: true
79
+ homepage: ""
80
+ licenses: []
81
+
82
+ post_install_message:
83
+ rdoc_options: []
84
+
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ hash: 3
93
+ segments:
94
+ - 0
95
+ version: "0"
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ hash: 3
102
+ segments:
103
+ - 0
104
+ version: "0"
105
+ requirements: []
106
+
107
+ rubyforge_project: sms-client
108
+ rubygems_version: 1.6.2
109
+ signing_key:
110
+ specification_version: 3
111
+ summary: sms client
112
+ test_files: []
113
+