classy_plivo 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/.travis.yml +10 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +63 -0
- data/Rakefile +8 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/classy_plivo.gemspec +25 -0
- data/lib/classy_plivo/response.rb +34 -0
- data/lib/classy_plivo/rest_api.rb +13 -0
- data/lib/classy_plivo/version.rb +3 -0
- data/lib/classy_plivo.rb +8 -0
- metadata +113 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 319d9a4ada1a05f394bd3d77fb4f4d55862a8038
|
4
|
+
data.tar.gz: 236e725fd6da9f8b19673c247ccbf98a3eb4153f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 79738e1a4a175f6656045006caed17b0982342f9ff8a4ed2a1f8f3e02de3157569369ef18a5aae54ae6c5ff1990ed886617e55da696678490e7fe8a39027c1a2
|
7
|
+
data.tar.gz: 0ba13573698a1ca99d002263e9c276f7d43029b03f912254954f2692fc52bb54df2d03833a0afb7a41440edbd501178563c68ec653b419e280cfd7ce5f64859f
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Faraz Yashar
|
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,63 @@
|
|
1
|
+
# ClassyPlivo :phone:
|
2
|
+
|
3
|
+
[](http://badge.fury.io/rb/classy_plivo)
|
4
|
+
[](https://travis-ci.org/fny/classy_plivo)
|
5
|
+
[](https://codeclimate.com/github/fny/classy_plivo)
|
6
|
+
[](https://codeclimate.com/github/fny/classy_plivo)
|
7
|
+
[](https://gemnasium.com/fny/classy_plivo)
|
8
|
+
|
9
|
+
A classy and minimalistic wrapper for the [Plivo Ruby library](https://github.com/plivo/plivo-ruby).
|
10
|
+
|
11
|
+
## Overview
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
# This matches Plivo::RestAPI signature
|
15
|
+
classy_api = ClassyPlivo::RestAPI.new('auth_id', 'auth_token')
|
16
|
+
classy_response = classy_api.get_account
|
17
|
+
|
18
|
+
# => ClassyPlivo::Response
|
19
|
+
classy_response.nonsense
|
20
|
+
# => NoMethodError
|
21
|
+
classy_response.error?
|
22
|
+
# => true for 4XX and 5XX errors
|
23
|
+
classy_response.http_status
|
24
|
+
# => Integer response code
|
25
|
+
classy_response.payload
|
26
|
+
# => Twilio payload hash: { api_id: '1', 'message' => 'success' }
|
27
|
+
classy_response.payload_key
|
28
|
+
# => Value of payload['payload_key'] or ClassyPlivo::Response:::NoPayloadKeyError
|
29
|
+
classy_response.has_payload_key?('whatever')
|
30
|
+
# => true if the payload provides the requested key
|
31
|
+
```
|
32
|
+
|
33
|
+
A lot of this behavior relies on overriding `#method_missing`. For more details, check out the tests in the `test` directory and the source code.
|
34
|
+
|
35
|
+
## Installation
|
36
|
+
|
37
|
+
Add this line to your application's Gemfile:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
gem 'classy_plivo'
|
41
|
+
```
|
42
|
+
|
43
|
+
And then execute:
|
44
|
+
|
45
|
+
$ bundle
|
46
|
+
|
47
|
+
Or install it yourself as:
|
48
|
+
|
49
|
+
$ gem install classy_plivo
|
50
|
+
|
51
|
+
## Development
|
52
|
+
|
53
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment. Run `bundle exec rake test` to run the test suite.
|
54
|
+
|
55
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
56
|
+
|
57
|
+
## Contributing
|
58
|
+
|
59
|
+
1. Fork it ( https://github.com/fny/classy_plivo/fork )
|
60
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
61
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
62
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
63
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'classy_plivo'
|
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
|
data/bin/setup
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'classy_plivo/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'classy_plivo'
|
8
|
+
spec.version = ClassyPlivo::VERSION
|
9
|
+
spec.authors = ['Faraz Yashar']
|
10
|
+
spec.email = ['faraz.yashar@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = 'A classy wrapper for the Plivo Ruby library'
|
13
|
+
spec.description = 'A minimalistic and classy wrapper for the Plivo Ruby library.'
|
14
|
+
spec.homepage = 'https://github.com/fny/classy_plivo'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
|
20
|
+
spec.add_dependency 'plivo', '~> 0.3.16'
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
23
|
+
spec.add_development_dependency 'minitest', '~> 5.6'
|
24
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
25
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module ClassyPlivo
|
2
|
+
class Response
|
3
|
+
attr_reader :http_status, :payload
|
4
|
+
|
5
|
+
# Raised when attempting to access a key that does not exist in Plivo's
|
6
|
+
# response payload
|
7
|
+
NoPayloadKeyError = Class.new(NoMethodError)
|
8
|
+
|
9
|
+
def initialize(response)
|
10
|
+
@http_status = response[0]
|
11
|
+
@payload = response[1]
|
12
|
+
end
|
13
|
+
|
14
|
+
# True if 4XX or 5XX status code is received
|
15
|
+
def error?
|
16
|
+
http_status >= 400 && http_status <= 599
|
17
|
+
end
|
18
|
+
|
19
|
+
def has_payload_key?(key)
|
20
|
+
payload.has_key?(key)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Delegate all other method calls to the payload hash
|
24
|
+
def method_missing(method, *args, &block)
|
25
|
+
payload_key = method.to_s
|
26
|
+
if has_payload_key?(payload_key)
|
27
|
+
payload[payload_key]
|
28
|
+
else
|
29
|
+
fail NoPayloadKeyError,
|
30
|
+
"Key '#{payload_key}' not found in response payload: #{payload}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/classy_plivo.rb
ADDED
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: classy_plivo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Faraz Yashar
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: plivo
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.3.16
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.3.16
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
description: A minimalistic and classy wrapper for the Plivo Ruby library.
|
70
|
+
email:
|
71
|
+
- faraz.yashar@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bin/console
|
83
|
+
- bin/setup
|
84
|
+
- classy_plivo.gemspec
|
85
|
+
- lib/classy_plivo.rb
|
86
|
+
- lib/classy_plivo/response.rb
|
87
|
+
- lib/classy_plivo/rest_api.rb
|
88
|
+
- lib/classy_plivo/version.rb
|
89
|
+
homepage: https://github.com/fny/classy_plivo
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 2.4.6
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: A classy wrapper for the Plivo Ruby library
|
113
|
+
test_files: []
|