nileshtrivedi-gupshup 0.0.2

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.
@@ -0,0 +1,4 @@
1
+ === 0.0.1 2009-08-17
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
@@ -0,0 +1,11 @@
1
+ History.txt
2
+ Manifest.txt
3
+ PostInstall.txt
4
+ README.rdoc
5
+ Rakefile
6
+ lib/gupshup.rb
7
+ script/console
8
+ script/destroy
9
+ script/generate
10
+ test/test_gupshup.rb
11
+ test/test_helper.rb
@@ -0,0 +1,6 @@
1
+ For more information on SMS GupShup product, see http://enterprise.smsgupshup.com
2
+ For more information on gupshup gem, see http://github.com/nileshtrivedi
3
+
4
+
5
+
6
+
@@ -0,0 +1,53 @@
1
+ = gupshup
2
+
3
+ * http://github.com/nileshtrivedi/smsgupshup
4
+
5
+ == DESCRIPTION:
6
+
7
+ gupshup is a ruby wrapper for the HTTP APIs provided by SMS GupShup which
8
+ is a Group SMS Platform for the enterprises with advanced features such as
9
+ masks, keywords, text/flash/vcard/bulk messages, advertising and keyword
10
+ campaigns and so on.
11
+
12
+ == FEATURES:
13
+
14
+ * V 0.0.1 send_message is implemented.
15
+
16
+ == SYNOPSIS:
17
+
18
+ gup = Gupshup::Client.new('your_gupshup_login','password')
19
+ gup.send_message('sms message text',target_phone_number)
20
+
21
+ == REQUIREMENTS:
22
+
23
+ * uri, cgi, http
24
+
25
+ == INSTALL:
26
+
27
+ * sudo gem sources -a http://gems.github.com
28
+ * sudo gem install gupshup
29
+
30
+ == LICENSE:
31
+
32
+ (The MIT License)
33
+
34
+ Copyright (c) 2009 Nilesh Trivedi
35
+
36
+ Permission is hereby granted, free of charge, to any person obtaining
37
+ a copy of this software and associated documentation files (the
38
+ 'Software'), to deal in the Software without restriction, including
39
+ without limitation the rights to use, copy, modify, merge, publish,
40
+ distribute, sublicense, and/or sell copies of the Software, and to
41
+ permit persons to whom the Software is furnished to do so, subject to
42
+ the following conditions:
43
+
44
+ The above copyright notice and this permission notice shall be
45
+ included in all copies or substantial portions of the Software.
46
+
47
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
48
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
49
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
50
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
51
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
52
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
53
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,26 @@
1
+ require 'rubygems'
2
+ gem 'hoe', '>= 2.1.0'
3
+ require 'hoe'
4
+ require 'fileutils'
5
+ require './lib/gupshup'
6
+
7
+ Hoe.plugin :newgem
8
+ # Hoe.plugin :website
9
+ # Hoe.plugin :cucumberfeatures
10
+
11
+ # Generate all the Rake tasks
12
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
13
+ $hoe = Hoe.spec 'gupshup' do
14
+ self.developer 'Nilesh Trivedi', 'nilesh.tr@gmail.com'
15
+ self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
16
+ self.rubyforge_name = self.name # TODO this is default value
17
+ # self.extra_deps = [['activesupport','>= 2.0.2']]
18
+
19
+ end
20
+
21
+ require 'newgem/tasks'
22
+ Dir['tasks/**/*.rake'].each { |t| load t }
23
+
24
+ # TODO - want other tests/tasks run by default? Add them to the list
25
+ # remove_task :default
26
+ # task :default => [:spec, :features]
@@ -0,0 +1,46 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ require 'net/http'
5
+ require 'uri'
6
+ require 'cgi'
7
+
8
+ module Gupshup
9
+ VERSION = '0.0.1'
10
+ class Client
11
+ def initialize(login,password)
12
+ @api_url = 'http://enterprise.smsgupshup.com/GatewayAPI/rest'
13
+ @api_params = {}
14
+ @api_params[:userid] = login
15
+ @api_params[:password] = password
16
+ @api_params[:v] = '1.1'
17
+ @api_params[:auth_scheme] = 'PLAIN'
18
+ end
19
+
20
+ def send_message(msg,number)
21
+ msg_params = {}
22
+ msg_params[:method] = 'sendMessage'
23
+ msg_params[:msg_type] = 'TEXT'
24
+ msg_params[:msg] = msg.to_s
25
+ msg_params[:send_to] = CGI.escape(number.to_i.to_s)
26
+ url = URI.parse(@api_url)
27
+ req = Net::HTTP::Post.new(url.path)
28
+ puts "--- #{msg_params.merge(@api_params).inspect}"
29
+ req.set_form_data(msg_params.merge(@api_params))
30
+ res = Net::HTTP.new(url.host, url.port).start {|http|http.request(req) }
31
+ success = false
32
+ case res
33
+ when Net::HTTPSuccess, Net::HTTPRedirection
34
+ resp = res.body
35
+ success = true
36
+ else
37
+ puts "---#{res.body}"
38
+ end
39
+ if resp.nil? || resp.include?("success") == false
40
+ puts "############## SMS Sending failed - #{resp}"
41
+ success = false
42
+ end
43
+ return success
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/gupshup.rb'}"
9
+ puts "Loading gupshup gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestGupshup < Test::Unit::TestCase
4
+
5
+ def setup
6
+ end
7
+
8
+ def test_truth
9
+ assert true
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ require 'stringio'
2
+ require 'test/unit'
3
+ require File.dirname(__FILE__) + '/../lib/gupshup'
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nileshtrivedi-gupshup
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Nilesh Trivedi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-08-17 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: hoe
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.3.3
24
+ version:
25
+ description: FIX (describe your package)
26
+ email:
27
+ - nilesh.tr@gmail.com
28
+ executables: []
29
+
30
+ extensions: []
31
+
32
+ extra_rdoc_files:
33
+ - History.txt
34
+ - Manifest.txt
35
+ - PostInstall.txt
36
+ files:
37
+ - History.txt
38
+ - Manifest.txt
39
+ - PostInstall.txt
40
+ - README.rdoc
41
+ - Rakefile
42
+ - lib/gupshup.rb
43
+ - script/console
44
+ - script/destroy
45
+ - script/generate
46
+ - test/test_gupshup.rb
47
+ - test/test_helper.rb
48
+ has_rdoc: false
49
+ homepage: http://github.com/#{github_username}/#{project_name}
50
+ licenses:
51
+ post_install_message: PostInstall.txt
52
+ rdoc_options:
53
+ - --main
54
+ - README.rdoc
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: "0"
62
+ version:
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: "0"
68
+ version:
69
+ requirements: []
70
+
71
+ rubyforge_project: gupshup
72
+ rubygems_version: 1.3.5
73
+ signing_key:
74
+ specification_version: 3
75
+ summary: FIX (describe your package)
76
+ test_files:
77
+ - test/test_gupshup.rb
78
+ - test/test_helper.rb