revieto 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +9 -0
- data/.rspec +3 -0
- data/.travis.yml +15 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE.txt +21 -0
- data/README.md +44 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/changes.txt +8 -0
- data/lib/revieto.rb +10 -0
- data/lib/revieto/account.rb +22 -0
- data/lib/revieto/base_service.rb +45 -0
- data/lib/revieto/client.rb +33 -0
- data/lib/revieto/reviews.rb +28 -0
- data/lib/revieto/version.rb +3 -0
- data/revieto.gemspec +30 -0
- metadata +174 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ce3d3c965e9b40419ac08fa74a0addcdd0830a08
|
4
|
+
data.tar.gz: 2755e9e1052e191692abd304c6eacd07a64bcda3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 03f684efc141163df27f6bfa58b47275cc5066f5294787f6951437269ecb4ba6d28683cd548422149a05b9f9235a71c4e2429e4bdab0ac7ab2d38e84a94ac1c6
|
7
|
+
data.tar.gz: 75ca36d4be8f1209f2f340160f4716f17889e318ec4962bf4cc13c4bc2a7be0934c724c855c2075d8fb1aa4e991c585ce229d59a3f9983187722079f9a40ff72
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/MIT-LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Revieto (https://www.revieto.com)
|
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,44 @@
|
|
1
|
+
# revieto-ruby
|
2
|
+
|
3
|
+
Ruby bindings for the Revieto API.
|
4
|
+
|
5
|
+
[![Build Status](https://travis-ci.org/revieto/revieto-ruby.svg?branch=master)](https://travis-ci.org/revieto/revieto-ruby)
|
6
|
+
|
7
|
+
[![Gem Version](https://badge.fury.io/rb/revieto.svg)](https://badge.fury.io/rb/revieto)
|
8
|
+
|
9
|
+
[![Coverage Status](https://coveralls.io/repos/github/revieto/revieto-ruby/badge.svg?branch=master)](https://coveralls.io/github/revieto/revieto-ruby?branch=master)
|
10
|
+
|
11
|
+
## Instalation
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem install revieto
|
15
|
+
```
|
16
|
+
|
17
|
+
Using bundler:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
gem 'revieto'
|
21
|
+
```
|
22
|
+
|
23
|
+
## Configure your client
|
24
|
+
|
25
|
+
```
|
26
|
+
revieto = Revieto::Client.new('my_api_key')
|
27
|
+
```
|
28
|
+
|
29
|
+
You can get your `api_key` from your account in Revieto in the integration settings page.
|
30
|
+
|
31
|
+
## Usage
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
# Find your account's aggregate rating
|
35
|
+
aggregate_rating = revieto.account.aggregate_rating
|
36
|
+
|
37
|
+
# Find your account's reviews
|
38
|
+
reviews = revieto.reviews.all
|
39
|
+
```
|
40
|
+
|
41
|
+
## License
|
42
|
+
|
43
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
44
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "revieto"
|
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
data/changes.txt
ADDED
data/lib/revieto.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
module Revieto
|
2
|
+
class Account < BaseService
|
3
|
+
|
4
|
+
def name
|
5
|
+
response = JSON.parse(get_api_rating.body)
|
6
|
+
|
7
|
+
response['account_name']
|
8
|
+
end
|
9
|
+
|
10
|
+
def aggregate_rating
|
11
|
+
response = JSON.parse(get_api_rating.body)
|
12
|
+
|
13
|
+
response['aggregate_rating']
|
14
|
+
end
|
15
|
+
|
16
|
+
def rating_count
|
17
|
+
response = JSON.parse(get_api_rating.body)
|
18
|
+
|
19
|
+
response['rating_count']
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'http'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Revieto
|
5
|
+
class InvalidApiRequestError < StandardError; end
|
6
|
+
class BaseService
|
7
|
+
attr_reader :client
|
8
|
+
|
9
|
+
def initialize(client)
|
10
|
+
@client = client
|
11
|
+
end
|
12
|
+
|
13
|
+
def auth
|
14
|
+
'api_key=' + @client.api_key
|
15
|
+
end
|
16
|
+
|
17
|
+
def url(action)
|
18
|
+
@client.base_url + action
|
19
|
+
end
|
20
|
+
|
21
|
+
def get(action)
|
22
|
+
HTTP.auth(auth).get(url(action))
|
23
|
+
end
|
24
|
+
|
25
|
+
def get_api_rating
|
26
|
+
response = get('/api/v1/rating')
|
27
|
+
|
28
|
+
if response.code == 200
|
29
|
+
response
|
30
|
+
else
|
31
|
+
fail InvalidApiRequestError.new("invalid response from API (CODE: #{response.code})")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_api_reviews
|
36
|
+
response = get('/api/v1/reviews')
|
37
|
+
|
38
|
+
if response.code == 200
|
39
|
+
response
|
40
|
+
else
|
41
|
+
fail InvalidApiRequestError.new("invalid response from API (CODE: #{response.code})")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Revieto
|
2
|
+
class MisconfiguredClientError < StandardError; end
|
3
|
+
class Client
|
4
|
+
attr_reader :base_url, :api_key
|
5
|
+
|
6
|
+
def initialize(api_key)
|
7
|
+
@api_key = api_key
|
8
|
+
|
9
|
+
validate_credentials!
|
10
|
+
|
11
|
+
@base_url = build_base_url
|
12
|
+
end
|
13
|
+
|
14
|
+
def account
|
15
|
+
@account ||= Revieto::Account.new(self)
|
16
|
+
end
|
17
|
+
|
18
|
+
def reviews
|
19
|
+
@reviews ||= Revieto::Reviews.new(self)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def validate_credentials!
|
25
|
+
error = MisconfiguredClientError.new('api_key must not be nil')
|
26
|
+
fail error if @api_key.nil?
|
27
|
+
end
|
28
|
+
|
29
|
+
def build_base_url
|
30
|
+
'https://www.revieto.com'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Revieto
|
2
|
+
class Reviews < BaseService
|
3
|
+
|
4
|
+
def name
|
5
|
+
response = JSON.parse(get_api_reviews.body)
|
6
|
+
|
7
|
+
response['account_name']
|
8
|
+
end
|
9
|
+
|
10
|
+
def aggregate_rating
|
11
|
+
response = JSON.parse(get_api_reviews.body)
|
12
|
+
|
13
|
+
response['aggregate_rating']
|
14
|
+
end
|
15
|
+
|
16
|
+
def rating_count
|
17
|
+
response = JSON.parse(get_api_reviews.body)
|
18
|
+
|
19
|
+
response['rating_count']
|
20
|
+
end
|
21
|
+
|
22
|
+
def all
|
23
|
+
response = JSON.parse(get_api_reviews.body)
|
24
|
+
|
25
|
+
response['reviews']
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/revieto.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'revieto/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'revieto'
|
8
|
+
spec.version = Revieto::VERSION
|
9
|
+
spec.authors = ['Bruno Valentino']
|
10
|
+
spec.email = ['brunovalentino@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = %q{Ruby bindings for the Revieto API (https://wwww.revieto.com)}
|
13
|
+
spec.description = %q{Ruby bindings for the Revieto API (https://wwww.revieto.com)}
|
14
|
+
spec.homepage = 'https://github.com/revieto/revieto-ruby'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.11'
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
25
|
+
spec.add_development_dependency 'pry'
|
26
|
+
spec.add_development_dependency 'webmock'
|
27
|
+
spec.add_development_dependency 'forgery'
|
28
|
+
spec.add_development_dependency 'coveralls'
|
29
|
+
spec.add_dependency 'http'
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,174 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: revieto
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bruno Valentino
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-27 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.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
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: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: forgery
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: coveralls
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: http
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: Ruby bindings for the Revieto API (https://wwww.revieto.com)
|
126
|
+
email:
|
127
|
+
- brunovalentino@gmail.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- ".coveralls.yml"
|
133
|
+
- ".gitignore"
|
134
|
+
- ".rspec"
|
135
|
+
- ".travis.yml"
|
136
|
+
- Gemfile
|
137
|
+
- MIT-LICENSE.txt
|
138
|
+
- README.md
|
139
|
+
- Rakefile
|
140
|
+
- bin/console
|
141
|
+
- bin/setup
|
142
|
+
- changes.txt
|
143
|
+
- lib/revieto.rb
|
144
|
+
- lib/revieto/account.rb
|
145
|
+
- lib/revieto/base_service.rb
|
146
|
+
- lib/revieto/client.rb
|
147
|
+
- lib/revieto/reviews.rb
|
148
|
+
- lib/revieto/version.rb
|
149
|
+
- revieto.gemspec
|
150
|
+
homepage: https://github.com/revieto/revieto-ruby
|
151
|
+
licenses:
|
152
|
+
- MIT
|
153
|
+
metadata: {}
|
154
|
+
post_install_message:
|
155
|
+
rdoc_options: []
|
156
|
+
require_paths:
|
157
|
+
- lib
|
158
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
159
|
+
requirements:
|
160
|
+
- - ">="
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: '0'
|
163
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
requirements: []
|
169
|
+
rubyforge_project:
|
170
|
+
rubygems_version: 2.5.1
|
171
|
+
signing_key:
|
172
|
+
specification_version: 4
|
173
|
+
summary: Ruby bindings for the Revieto API (https://wwww.revieto.com)
|
174
|
+
test_files: []
|