Permalink
Browse files

First commit. Implemented send_message.

  • Loading branch information...
Nilesh Trivedi
Nilesh Trivedi committed Aug 17, 2009
0 parents commit f2e3d00936c95d635b2b76f1d267e1d7884f60bc
@@ -0,0 +1,4 @@
+=== 0.0.1 2009-08-17
+
+* 1 major enhancement:
+ * Initial release
@@ -0,0 +1,11 @@
+History.txt
+Manifest.txt
+PostInstall.txt
+README.rdoc
+Rakefile
+lib/gupshup.rb
+script/console
+script/destroy
+script/generate
+test/test_gupshup.rb
+test/test_helper.rb
@@ -0,0 +1,6 @@
+For more information on SMS GupShup product, see http://enterprise.smsgupshup.com
+For more information on gupshup gem, see http://github.com/nileshtrivedi
+
+
+
+
@@ -0,0 +1,48 @@
+= gupshup
+
+* http://github.com/#{github_username}/#{project_name}
+
+== DESCRIPTION:
+
+FIX (describe your package)
+
+== FEATURES/PROBLEMS:
+
+* FIX (list of features or problems)
+
+== SYNOPSIS:
+
+ FIX (code sample of usage)
+
+== REQUIREMENTS:
+
+* FIX (list of requirements)
+
+== INSTALL:
+
+* FIX (sudo gem install, anything else)
+
+== LICENSE:
+
+(The MIT License)
+
+Copyright (c) 2009 FIXME full name
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,26 @@
+require 'rubygems'
+gem 'hoe', '>= 2.1.0'
+require 'hoe'
+require 'fileutils'
+require './lib/gupshup'
+
+Hoe.plugin :newgem
+# Hoe.plugin :website
+# Hoe.plugin :cucumberfeatures
+
+# Generate all the Rake tasks
+# Run 'rake -T' to see list of generated tasks (from gem root directory)
+$hoe = Hoe.spec 'gupshup' do
+ self.developer 'Nilesh Trivedi', 'nilesh.tr@gmail.com'
+ self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
+ self.rubyforge_name = self.name # TODO this is default value
+ # self.extra_deps = [['activesupport','>= 2.0.2']]
+
+end
+
+require 'newgem/tasks'
+Dir['tasks/**/*.rake'].each { |t| load t }
+
+# TODO - want other tests/tasks run by default? Add them to the list
+# remove_task :default
+# task :default => [:spec, :features]
@@ -0,0 +1,35 @@
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = %q{gupshup}
+ s.version = "0.0.1"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Nilesh Trivedi"]
+ s.date = %q{2009-08-17}
+ s.description = %q{FIX (describe your package)}
+ s.email = ["nilesh.tr@gmail.com"]
+ s.extra_rdoc_files = ["History.txt", "Manifest.txt", "PostInstall.txt"]
+ s.files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "lib/gupshup.rb", "script/console", "script/destroy", "script/generate", "test/test_gupshup.rb", "test/test_helper.rb"]
+ s.homepage = %q{http://github.com/#{github_username}/#{project_name}}
+ s.post_install_message = %q{PostInstall.txt}
+ s.rdoc_options = ["--main", "README.rdoc"]
+ s.require_paths = ["lib"]
+ s.rubyforge_project = %q{gupshup}
+ s.rubygems_version = %q{1.3.5}
+ s.summary = %q{FIX (describe your package)}
+ s.test_files = ["test/test_gupshup.rb", "test/test_helper.rb"]
+
+ if s.respond_to? :specification_version then
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
+ s.specification_version = 3
+
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
+ s.add_development_dependency(%q<hoe>, [">= 2.3.3"])
+ else
+ s.add_dependency(%q<hoe>, [">= 2.3.3"])
+ end
+ else
+ s.add_dependency(%q<hoe>, [">= 2.3.3"])
+ end
+end
@@ -0,0 +1,46 @@
+$:.unshift(File.dirname(__FILE__)) unless
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
+
+require 'net/http'
+require 'uri'
+require 'cgi'
+
+module Gupshup
+ VERSION = '0.0.1'
+ class Client
+ def initialize(login,password)
+ @api_url = 'http://enterprise.smsgupshup.com/GatewayAPI/rest'
+ @api_params = {}
+ @api_params[:userid] = login
+ @api_params[:password] = password
+ @api_params[:v] = '1.1'
+ @api_params[:auth_scheme] = 'PLAIN'
+ end
+
+ def send_message(msg,number)
+ msg_params = {}
+ msg_params[:method] = 'sendMessage'
+ msg_params[:msg_type] = 'TEXT'
+ msg_params[:msg] = msg.to_s
+ msg_params[:send_to] = CGI.escape(number.to_i.to_s)
+ url = URI.parse(@api_url)
+ req = Net::HTTP::Post.new(url.path)
+ puts "--- #{msg_params.merge(@api_params).inspect}"
+ req.set_form_data(msg_params.merge(@api_params))
+ res = Net::HTTP.new(url.host, url.port).start {|http|http.request(req) }
+ success = false
+ case res
+ when Net::HTTPSuccess, Net::HTTPRedirection
+ resp = res.body
+ success = true
+ else
+ puts "---#{res.body}"
+ end
+ if resp.nil? || resp.include?("success") == false
+ puts "############## SMS Sending failed - #{resp}"
+ success = false
+ end
+ return success
+ end
+ end
+end
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,4 @@
+=== 0.0.1 2009-08-17
+
+* 1 major enhancement:
+ * Initial release
@@ -0,0 +1,11 @@
+History.txt
+Manifest.txt
+PostInstall.txt
+README.rdoc
+Rakefile
+lib/gupshup.rb
+script/console
+script/destroy
+script/generate
+test/test_gupshup.rb
+test/test_helper.rb
@@ -0,0 +1,6 @@
+For more information on SMS GupShup product, see http://enterprise.smsgupshup.com
+For more information on gupshup gem, see http://github.com/nileshtrivedi
+
+
+
+
@@ -0,0 +1,48 @@
+= gupshup
+
+* http://github.com/#{github_username}/#{project_name}
+
+== DESCRIPTION:
+
+FIX (describe your package)
+
+== FEATURES/PROBLEMS:
+
+* FIX (list of features or problems)
+
+== SYNOPSIS:
+
+ FIX (code sample of usage)
+
+== REQUIREMENTS:
+
+* FIX (list of requirements)
+
+== INSTALL:
+
+* FIX (sudo gem install, anything else)
+
+== LICENSE:
+
+(The MIT License)
+
+Copyright (c) 2009 FIXME full name
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,26 @@
+require 'rubygems'
+gem 'hoe', '>= 2.1.0'
+require 'hoe'
+require 'fileutils'
+require './lib/gupshup'
+
+Hoe.plugin :newgem
+# Hoe.plugin :website
+# Hoe.plugin :cucumberfeatures
+
+# Generate all the Rake tasks
+# Run 'rake -T' to see list of generated tasks (from gem root directory)
+$hoe = Hoe.spec 'gupshup' do
+ self.developer 'Nilesh Trivedi', 'nilesh.tr@gmail.com'
+ self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
+ self.rubyforge_name = self.name # TODO this is default value
+ # self.extra_deps = [['activesupport','>= 2.0.2']]
+
+end
+
+require 'newgem/tasks'
+Dir['tasks/**/*.rake'].each { |t| load t }
+
+# TODO - want other tests/tasks run by default? Add them to the list
+# remove_task :default
+# task :default => [:spec, :features]
@@ -0,0 +1,46 @@
+$:.unshift(File.dirname(__FILE__)) unless
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
+
+require 'net/http'
+require 'uri'
+require 'cgi'
+
+module Gupshup
+ VERSION = '0.0.1'
+ class Client
+ def initialize(login,password)
+ @api_url = 'http://enterprise.smsgupshup.com/GatewayAPI/rest'
+ @api_params = {}
+ @api_params[:userid] = login
+ @api_params[:password] = password
+ @api_params[:v] = '1.1'
+ @api_params[:auth_scheme] = 'PLAIN'
+ end
+
+ def send_message(msg,number)
+ msg_params = {}
+ msg_params[:method] = 'sendMessage'
+ msg_params[:msg_type] = 'TEXT'
+ msg_params[:msg] = msg.to_s
+ msg_params[:send_to] = CGI.escape(number.to_i.to_s)
+ url = URI.parse(@api_url)
+ req = Net::HTTP::Post.new(url.path)
+ puts "--- #{msg_params.merge(@api_params).inspect}"
+ req.set_form_data(msg_params.merge(@api_params))
+ res = Net::HTTP.new(url.host, url.port).start {|http|http.request(req) }
+ success = false
+ case res
+ when Net::HTTPSuccess, Net::HTTPRedirection
+ resp = res.body
+ success = true
+ else
+ puts "---#{res.body}"
+ end
+ if resp.nil? || resp.include?("success") == false
+ puts "############## SMS Sending failed - #{resp}"
+ success = false
+ end
+ return success
+ end
+ end
+end
@@ -0,0 +1,10 @@
+#!/usr/bin/env ruby
+# File: script/console
+irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
+
+libs = " -r irb/completion"
+# Perhaps use a console_lib to store any extra methods I may want available in the cosole
+# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
+libs << " -r #{File.dirname(__FILE__) + '/../lib/gupshup.rb'}"
+puts "Loading gupshup gem"
+exec "#{irb} #{libs} --simple-prompt"
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
+
+begin
+ require 'rubigen'
+rescue LoadError
+ require 'rubygems'
+ require 'rubigen'
+end
+require 'rubigen/scripts/destroy'
+
+ARGV.shift if ['--help', '-h'].include?(ARGV[0])
+RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
+RubiGen::Scripts::Destroy.new.run(ARGV)
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
+
+begin
+ require 'rubigen'
+rescue LoadError
+ require 'rubygems'
+ require 'rubigen'
+end
+require 'rubigen/scripts/generate'
+
+ARGV.shift if ['--help', '-h'].include?(ARGV[0])
+RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
+RubiGen::Scripts::Generate.new.run(ARGV)
@@ -0,0 +1,11 @@
+require File.dirname(__FILE__) + '/test_helper.rb'
+
+class TestGupshup < Test::Unit::TestCase
+
+ def setup
+ end
+
+ def test_truth
+ assert true
+ end
+end
@@ -0,0 +1,3 @@
+require 'stringio'
+require 'test/unit'
+require File.dirname(__FILE__) + '/../lib/gupshup'
Oops, something went wrong.

0 comments on commit f2e3d00

Please sign in to comment.