exotel-api-client 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/MIT-LICENSE +20 -0
- data/README.md +56 -0
- data/Rakefile +12 -0
- data/exotel-api-client.gemspec +22 -0
- data/lib/exotel-api-client.rb +4 -0
- data/lib/exotel-api-client/client.rb +31 -0
- data/lib/exotel-api-client/resource.rb +17 -0
- data/lib/exotel-api-client/response.rb +18 -0
- data/lib/exotel-api-client/version.rb +3 -0
- data/test/lib/exotel-api-client/version_test.rb +7 -0
- data/test/test_helper.rb +3 -0
- metadata +101 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 60b94daaf209d1fa6108373271dff0077adb5ea5
|
4
|
+
data.tar.gz: ae4d91714857410365d1067f0bf641b93310fe70
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 75423c1485798be8f229f30f04d01f51b72cfea1147883e06b913d0551d2e17ee24fca029d1606c1470741a370427a70802684641daf3d9d20ce6c59fa60e0d1
|
7
|
+
data.tar.gz: 1ae15368c6ffbebb19a63f999f32ac6db0473e28268f5f05386f0e29af4becde9ded2618f0bcca48c4e17a0051581bc8e7d6f331c289d423167017a63671bb8d
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Urban Ladder
|
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/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Urban Ladder (http://www.urbanladder.com)
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
exotel
|
2
|
+
======
|
3
|
+
|
4
|
+
Ruby interface to the Exotel API
|
5
|
+
|
6
|
+
Install
|
7
|
+
=======
|
8
|
+
|
9
|
+
```
|
10
|
+
gem install exotel-api-client
|
11
|
+
```
|
12
|
+
|
13
|
+
Requirements
|
14
|
+
============
|
15
|
+
|
16
|
+
* httparty
|
17
|
+
|
18
|
+
Examples
|
19
|
+
========
|
20
|
+
|
21
|
+
### Setup
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require 'exotel-api-client'
|
25
|
+
|
26
|
+
# put your credentials here
|
27
|
+
account_sid = '<My Exotel SID>'
|
28
|
+
account_token = '<My Exotel Token>'
|
29
|
+
|
30
|
+
# set up a client that will talk to the Exotel REST API
|
31
|
+
@client = Exotel::Client.new(account_sid, account_token)
|
32
|
+
```
|
33
|
+
|
34
|
+
### Send An SMS
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
sms_data = {
|
38
|
+
"From" => "<6-character Sender ID>"
|
39
|
+
"To" => "<Phone Number>"
|
40
|
+
"Body" => "<SMS content>"
|
41
|
+
}
|
42
|
+
|
43
|
+
client.Sms.post(sms_data)
|
44
|
+
```
|
45
|
+
|
46
|
+
### Get Status of An SMS
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
client.SMS.Messages({:sid => '<SmsSid>'})
|
50
|
+
```
|
51
|
+
|
52
|
+
### Get Call Details
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
client.Calls({:sid => '<CallSid>'})
|
56
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
|
4
|
+
require 'rake/testtask'
|
5
|
+
|
6
|
+
Rake::TestTask.new do |t|
|
7
|
+
t.libs << 'lib/exotel-api-client'
|
8
|
+
t.test_files = FileList['test/lib/exotel-api-client/*_test.rb']
|
9
|
+
t.verbose = true
|
10
|
+
end
|
11
|
+
|
12
|
+
task :default => :test
|
@@ -0,0 +1,22 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'exotel-api-client/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "exotel-api-client"
|
7
|
+
s.version = Exotel::VERSION
|
8
|
+
s.authors = "Kumar Akarsh"
|
9
|
+
s.email = ["akarsh@urbanladder.com","akarsh1357@gmail.com"]
|
10
|
+
s.description = "A simple library for using the Exotel REST API"
|
11
|
+
s.summary = "A simple library for using the Exotel REST API"
|
12
|
+
s.homepage = "https://github.com/urbanladder/exotel"
|
13
|
+
s.license = "MIT"
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split($/)
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
|
18
|
+
s.add_development_dependency "bundler", "~> 1.3"
|
19
|
+
s.add_development_dependency "rake"
|
20
|
+
|
21
|
+
s.add_dependency 'httparty'
|
22
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module Exotel
|
4
|
+
class Client
|
5
|
+
include HTTParty
|
6
|
+
|
7
|
+
def initialize(sid,token)
|
8
|
+
@auth = {:username => sid, :password => token}
|
9
|
+
@resource = Resource.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def method_missing(method, *args, &block)
|
13
|
+
@resource.append(method, args[0])
|
14
|
+
@opts = {:query => @resource.options, :basic_auth => @auth}
|
15
|
+
if args.size > 0 && !method.to_s.eql?("post")
|
16
|
+
execute("get")
|
17
|
+
elsif method.to_s.match /\bget\b|\bpost\b/
|
18
|
+
execute(method)
|
19
|
+
else
|
20
|
+
return self
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def execute(method)
|
25
|
+
response = Response.construct self.class.send(method,@resource.url(@auth[:username]),@opts)
|
26
|
+
@resource = Resource.new
|
27
|
+
response
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Exotel
|
2
|
+
class Resource
|
3
|
+
attr_reader :options
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@keys = []; @options = {}
|
7
|
+
end
|
8
|
+
|
9
|
+
def append(key,options)
|
10
|
+
@keys << key; @options.merge!(options) if options
|
11
|
+
end
|
12
|
+
|
13
|
+
def url sid
|
14
|
+
@url = "https://twilix.exotel.in/" + "v1/Accounts/" + "#{sid}/" + @keys.join("/")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Exotel
|
2
|
+
class Response
|
3
|
+
attr_reader :errors
|
4
|
+
|
5
|
+
def initialize(hash)
|
6
|
+
hash.each do |key,value|
|
7
|
+
Response.new value if value.class == Hash
|
8
|
+
self.instance_variable_set("@#{key}", value)
|
9
|
+
self.class.send(:define_method, key, proc{self.instance_variable_get("@#{key}")})
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.construct(response)
|
14
|
+
return response.class == Array ? response.collect { |item| Response.new(item) } : Response.new(response)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: exotel-api-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kumar Akarsh
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-24 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.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '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'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: A simple library for using the Exotel REST API
|
56
|
+
email:
|
57
|
+
- akarsh@urbanladder.com
|
58
|
+
- akarsh1357@gmail.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- MIT-LICENSE
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- exotel-api-client.gemspec
|
70
|
+
- lib/exotel-api-client.rb
|
71
|
+
- lib/exotel-api-client/client.rb
|
72
|
+
- lib/exotel-api-client/resource.rb
|
73
|
+
- lib/exotel-api-client/response.rb
|
74
|
+
- lib/exotel-api-client/version.rb
|
75
|
+
- test/lib/exotel-api-client/version_test.rb
|
76
|
+
- test/test_helper.rb
|
77
|
+
homepage: https://github.com/urbanladder/exotel
|
78
|
+
licenses:
|
79
|
+
- MIT
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 2.0.3
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: A simple library for using the Exotel REST API
|
101
|
+
test_files: []
|