ozonetel 0.1.0
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.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +68 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/ozonetel.rb +9 -0
- data/lib/ozonetel/config.rb +15 -0
- data/lib/ozonetel/outbound/call.rb +56 -0
- data/lib/ozonetel/response.rb +20 -0
- data/lib/ozonetel/version.rb +3 -0
- data/ozonetel.gemspec +28 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ae5849da7d4c3324af27d91089b4cb0a350eb1c7
|
4
|
+
data.tar.gz: 60be30c3c7130d00eaf303477bad860a8bb2d211
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5b23307d39646f277e8d0ee051a54642f19f47894042822705be6be916edd71a8e67c3dd444b58e6bfd6932dd6d98bc909f843a9ef62a85262db6b892c1c2095
|
7
|
+
data.tar.gz: 94d3acdb6d4c0d31098dd8e2d578bc1d2656124346632c226069137473b7e4942e2f3304310c72e53eaaeca86c9602cfd45922116e729d8ba0aead86178b3a65
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Aashutosh Chaudhary
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# Ozonetel - REST API to interact with Ozonetel KooKoo
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'ozonetel'
|
9
|
+
```
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install ozonetel
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
**Configure authentication key and version**
|
22
|
+
|
23
|
+
Add following lines into your rails application.rb file
|
24
|
+
|
25
|
+
Ozonetel.configure do |c|
|
26
|
+
c.outbound_version = 2
|
27
|
+
c.api_key = 'xxxxxxxxxxxxxxx'
|
28
|
+
end
|
29
|
+
|
30
|
+
**To send outbound call**
|
31
|
+
|
32
|
+
response = Ozonetel::Outbound::Call.connect({:phone_no => 'The phone number to place the call to', :extra_data => 'Your KooKoo Tunes', :caller_id => 'Your ozonetel caller id', :url => 'Your application url', :callback_url => 'URL which will be called after the call is finished.'})
|
33
|
+
|
34
|
+
Example - 1
|
35
|
+
response = Ozonetel::Outbound::Call.connect({:phone_no => "xxxxxxxxxx", :extra_data =>"<response><playtext>ILove KooKoo</playtext><hangup/></response>"})
|
36
|
+
|
37
|
+
puts response.status
|
38
|
+
|
39
|
+
"queued"
|
40
|
+
|
41
|
+
puts response.message
|
42
|
+
|
43
|
+
"136989181721681"
|
44
|
+
|
45
|
+
Example 2 -
|
46
|
+
response = Ozonetel::Outbound::Call.connect({:phone_no => "9643919931", :extra_data =>"<response><playtext>ILove KooKoo</playtext><hangup/></response>"})
|
47
|
+
|
48
|
+
puts response.status
|
49
|
+
|
50
|
+
"error"
|
51
|
+
|
52
|
+
puts response.message
|
53
|
+
|
54
|
+
"Authentication error"
|
55
|
+
|
56
|
+
## Dependencies
|
57
|
+
|
58
|
+
gem httparty 0.14.0
|
59
|
+
|
60
|
+
## Contributing
|
61
|
+
|
62
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ashugodia/ozonetel.
|
63
|
+
|
64
|
+
|
65
|
+
## License
|
66
|
+
|
67
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
68
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ozonetel"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/ozonetel.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module Ozonetel
|
2
|
+
class << self
|
3
|
+
attr_accessor :outbound_version, :api_key
|
4
|
+
|
5
|
+
def configure
|
6
|
+
yield self
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class AuthenticationError < StandardError; end
|
11
|
+
|
12
|
+
class UnexpectedError < StandardError; end
|
13
|
+
|
14
|
+
class ParamsError < StandardError; end
|
15
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
module Ozonetel
|
3
|
+
module Outbound
|
4
|
+
class Call
|
5
|
+
include HTTParty
|
6
|
+
|
7
|
+
base_uri 'http://www.kookoo.in/outbound/outbound.php'
|
8
|
+
|
9
|
+
def initialize; end
|
10
|
+
|
11
|
+
def self.connect(params={})
|
12
|
+
self.new.connect(params)
|
13
|
+
end
|
14
|
+
|
15
|
+
def connect(params={})
|
16
|
+
params = params.merge(configuration)
|
17
|
+
if valid?(params)
|
18
|
+
response = self.class.get(URI.escape("?#{transform_params(params)}"))
|
19
|
+
handle_response(response)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
protected
|
24
|
+
|
25
|
+
def valid?(params)
|
26
|
+
mandatory_keys = [:phone_no, :api_key]
|
27
|
+
unless mandatory_keys.all?{|key| params.keys.include?(key)}
|
28
|
+
raise Ozonetel::ParamsError, "#{key} parameter missing."
|
29
|
+
else
|
30
|
+
return true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def transform_params(params)
|
35
|
+
transformed_params = []
|
36
|
+
params.each do |k,v| transformed_params << "#{k}=#{v}" end
|
37
|
+
transformed_params.join('&')
|
38
|
+
end
|
39
|
+
|
40
|
+
def configuration
|
41
|
+
{:outbound_version => Ozonetel.outbound_version, :api_key => Ozonetel.api_key}
|
42
|
+
end
|
43
|
+
|
44
|
+
def handle_response(response)
|
45
|
+
case response.code.to_i
|
46
|
+
when 200...300 then Ozonetel::Response.new(response)
|
47
|
+
when 401 then raise Ozonetel::AuthenticationError, response.body
|
48
|
+
when 403 then Ozonetel::Response.new(response)
|
49
|
+
else
|
50
|
+
raise Ozonetel::UnexpectedError, response.body
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Ozonetel
|
2
|
+
class Response
|
3
|
+
|
4
|
+
def initialize(response)
|
5
|
+
set_response_data(response.parsed_response)
|
6
|
+
end
|
7
|
+
|
8
|
+
def set_response_data(response)
|
9
|
+
(response['response']).each do |key, value|
|
10
|
+
set_variable(key, value)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def set_variable(key, value)
|
15
|
+
self.class.send(:attr_accessor, key) #Set accessors dynamically
|
16
|
+
instance_variable_set("@#{key}", value)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
data/ozonetel.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ozonetel/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ozonetel"
|
8
|
+
spec.version = Ozonetel::VERSION
|
9
|
+
spec.authors = ["Aashutosh Chaudhary"]
|
10
|
+
spec.email = ["ashugodia@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{REST API to interact with Ozonetel KooKoo.}
|
13
|
+
spec.description = %q{This gem helps to make outbound calls using KooKoo.}
|
14
|
+
spec.homepage = "https://github.com/ashugodia/ozonetel"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
|
27
|
+
spec.add_dependency 'httparty', "~> 0.14.0"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ozonetel
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Aashutosh Chaudhary
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-04-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.14'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.14'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: httparty
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.14.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.14.0
|
55
|
+
description: This gem helps to make outbound calls using KooKoo.
|
56
|
+
email:
|
57
|
+
- ashugodia@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- bin/console
|
68
|
+
- bin/setup
|
69
|
+
- lib/ozonetel.rb
|
70
|
+
- lib/ozonetel/config.rb
|
71
|
+
- lib/ozonetel/outbound/call.rb
|
72
|
+
- lib/ozonetel/response.rb
|
73
|
+
- lib/ozonetel/version.rb
|
74
|
+
- ozonetel.gemspec
|
75
|
+
homepage: https://github.com/ashugodia/ozonetel
|
76
|
+
licenses:
|
77
|
+
- MIT
|
78
|
+
metadata: {}
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
requirements: []
|
94
|
+
rubyforge_project:
|
95
|
+
rubygems_version: 2.4.8
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: REST API to interact with Ozonetel KooKoo.
|
99
|
+
test_files: []
|