chutki 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/CHANGELOG.md ADDED
File without changes
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in chutki.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Aditya Sanghi
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 ADDED
@@ -0,0 +1,36 @@
1
+ # Chutki
2
+
3
+ Chutki sends SMS thru ProSMS Easy2Approach
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'chutki'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install chutki
18
+
19
+ ## Usage
20
+
21
+ chutki = Chutki.new(username,password,senderid)
22
+ result = chutki.send_sms(phone_number,message)
23
+ if result.success?
24
+ ...
25
+ else
26
+ ...
27
+ end
28
+ # See documentation for all result codes
29
+
30
+ ## Contributing
31
+
32
+ 1. Fork it
33
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
34
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
35
+ 4. Push to the branch (`git push origin my-new-feature`)
36
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+
4
+ require "rubygems"
5
+ require "rake"
6
+ require "rake/testtask"
7
+ require "rdoc/task"
8
+
9
+ Rake::TestTask.new(:test) do |test|
10
+ test.libs << "lib" << "test"
11
+ test.pattern = "test/**/test_*.rb"
12
+ test.verbose = true
13
+ end
14
+ task :default => :test
data/chutki.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/chutki/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Aditya Sanghi"]
6
+ gem.email = ["aditya.sanghi@risingsuntech.net"]
7
+ gem.description = %q{Sends SMS thru a web api}
8
+ gem.summary = %q{Your SMS provider has given you an endpoint which you must call to Send SMS. Chutki makes it easy.}
9
+ gem.homepage = "https://github.com/asanghi/chutki"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "chutki"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Chutki::VERSION
17
+
18
+ gem.add_runtime_dependency "httparty", ">= 0.5.2"
19
+
20
+ [["shoulda",">= 2.10.3"],["mocha",">= 0.9.8"],["mcmire-matchy",">= 0.5.2"],["fakeweb",">= 1.2.8"]].each do |d|
21
+ gem.add_development_dependency d[0], d[1]
22
+ end
23
+
24
+ end
data/lib/chutki.rb ADDED
@@ -0,0 +1,60 @@
1
+ require 'chutki/version'
2
+ require 'httparty'
3
+
4
+ class Chutki
5
+ include HTTParty
6
+ base_uri "http://prosms.easy2approach.com"
7
+
8
+ def initialize(username,password,sender_id)
9
+ @username = username
10
+ @password = password
11
+ @sender_id = sender_id
12
+ end
13
+
14
+ def send_sms(message,to,opts = {})
15
+ opts ||= {}
16
+ opts[:mobiles] = to
17
+ opts[:message] = message
18
+ opts[:senderid] = @sender_id
19
+ makesend("/sendhttp.php",opts)
20
+ end
21
+
22
+ def check_dnd_balance
23
+ balance("dnd")
24
+ end
25
+
26
+ def voice_balance
27
+ balance("voice")
28
+ end
29
+
30
+ def balance(type = nil)
31
+ opts = {}
32
+ if type && (["dnd","voice"].include?(type))
33
+ opts[:type] = type
34
+ end
35
+ makesend("/api/balance.php",opts)
36
+ end
37
+
38
+ def change_password(new_password)
39
+ makesend("/api/change_password.php",{:newpass => new_password})
40
+ end
41
+
42
+ def validation
43
+ makesend("/api/validate.php")
44
+ end
45
+
46
+ def check_delivery_report(msgid)
47
+ makesend("/api/check_delivery.php",:msgid => msgid)
48
+ end
49
+
50
+ private
51
+
52
+ def makesend(endpoint,opts = {})
53
+ self.class.post(endpoint,opts.merge(options))
54
+ end
55
+
56
+ def options
57
+ {:user => @username, :password => @password}
58
+ end
59
+
60
+ end
@@ -0,0 +1,3 @@
1
+ class Chutki
2
+ VERSION="0.0.1"
3
+ end
@@ -0,0 +1,14 @@
1
+ require "rubygems"
2
+ require "test/unit"
3
+ require "shoulda"
4
+ require "mocha"
5
+ require "matchy"
6
+ require "fakeweb"
7
+
8
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
9
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
10
+
11
+ require "chutki"
12
+
13
+ class Test::Unit::TestCase
14
+ end
data/test/test_init.rb ADDED
@@ -0,0 +1,27 @@
1
+ require 'test_helper'
2
+
3
+ class InitTest < Test::Unit::TestCase
4
+
5
+ context "Initialization" do
6
+
7
+ should "require username and password and senderid" do
8
+ lambda { Chutki.new }.should raise_error(ArgumentError)
9
+ Chutki.new("username","password","senderid")
10
+ end
11
+ end
12
+
13
+ context "making remote calls" do
14
+ setup do
15
+ @response = "ok"
16
+ Chutki.stubs(:post).returns(@response)
17
+ end
18
+
19
+ context "Sending SMS" do
20
+ @chutki = Chutki.new("username","password","senderid")
21
+ Chutki.expects(:post).with("/sendhttp.php",:message => "message", :mobiles => "phonenumber", :senderid => "senderid", :user => "username", :password => "password")
22
+ @chutki.send_sms("message","phonenumber")
23
+ end
24
+
25
+ end
26
+
27
+ end
metadata ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chutki
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Aditya Sanghi
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: httparty
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.5.2
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.5.2
30
+ - !ruby/object:Gem::Dependency
31
+ name: shoulda
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 2.10.3
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 2.10.3
46
+ - !ruby/object:Gem::Dependency
47
+ name: mocha
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 0.9.8
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.9.8
62
+ - !ruby/object:Gem::Dependency
63
+ name: mcmire-matchy
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: 0.5.2
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 0.5.2
78
+ - !ruby/object:Gem::Dependency
79
+ name: fakeweb
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: 1.2.8
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: 1.2.8
94
+ description: Sends SMS thru a web api
95
+ email:
96
+ - aditya.sanghi@risingsuntech.net
97
+ executables: []
98
+ extensions: []
99
+ extra_rdoc_files: []
100
+ files:
101
+ - .gitignore
102
+ - CHANGELOG.md
103
+ - Gemfile
104
+ - LICENSE
105
+ - README.md
106
+ - Rakefile
107
+ - chutki.gemspec
108
+ - lib/chutki.rb
109
+ - lib/chutki/version.rb
110
+ - test/test_helper.rb
111
+ - test/test_init.rb
112
+ homepage: https://github.com/asanghi/chutki
113
+ licenses: []
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ! '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ none: false
126
+ requirements:
127
+ - - ! '>='
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ requirements: []
131
+ rubyforge_project:
132
+ rubygems_version: 1.8.21
133
+ signing_key:
134
+ specification_version: 3
135
+ summary: Your SMS provider has given you an endpoint which you must call to Send SMS.
136
+ Chutki makes it easy.
137
+ test_files:
138
+ - test/test_helper.rb
139
+ - test/test_init.rb