doyoubuzz-showcase 0.0.1
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 +17 -0
- data/.rspec +1 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +22 -0
- data/README.md +60 -0
- data/Rakefile +1 -0
- data/doyoubuzz-showcase.gemspec +26 -0
- data/lib/doyoubuzz/showcase.rb +72 -0
- data/lib/doyoubuzz/showcase/version.rb +3 -0
- data/spec/fixtures/vcr_cassettes/failed_call.yml +31 -0
- data/spec/fixtures/vcr_cassettes/good_call.yml +124 -0
- data/spec/showcase_spec.rb +80 -0
- data/spec/spec_helper.rb +15 -0
- metadata +117 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d14295790c6ff76c60fe43b6e484f91b8adfb8fd
|
4
|
+
data.tar.gz: 8845df115a005dccccea9c8d248194b33acbe7ee
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b38d9b40e0769446971a27324a61005f6e167174f6e50ed7873f68714a558a71f50cfac4b48027d0d5ee0dce7b00a89dba55486c55586fbcabd128592cf4a2ec
|
7
|
+
data.tar.gz: 48cc99484f86a48626a3938ec2f7464e7ac6d4d874c3f209e512cede7c8ace8170a2b2f1e32f9a0e86b749ac4061aa828cbe4abd16cc30ed5296daf38239d911
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 David RUYER
|
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,60 @@
|
|
1
|
+
# Doyoubuzz::Showcase
|
2
|
+
|
3
|
+
## Description
|
4
|
+
|
5
|
+
The `doyoubuzz-showcase` gem is a thin ruby wrapper for the DoYouBuzz Showcase API. Based around the HTTParty gem, it handles the authorization and HTTP calls, and wraps the results in a Hashie::Mash for a simpler usage.
|
6
|
+
|
7
|
+
## Requirements
|
8
|
+
|
9
|
+
- httparty
|
10
|
+
- hashie
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Add this line to your application's Gemfile:
|
15
|
+
|
16
|
+
gem 'doyoubuzz-showcase', :git => 'git://github.com/MrRuru/doyoubuzz-showcase.git'
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install doyoubuzz-showcase
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
|
29
|
+
### Authentication
|
30
|
+
|
31
|
+
# Authenticate with your API credentials
|
32
|
+
client = Doyoubuzz::Showcase.new('your_api_key', 'your_api_secret')
|
33
|
+
|
34
|
+
### Querying
|
35
|
+
|
36
|
+
# Getting a results collection
|
37
|
+
response = client.get '/users'
|
38
|
+
|
39
|
+
puts response.users.items.first.email
|
40
|
+
# $ john.doe@domain.com
|
41
|
+
|
42
|
+
### Queries with parameters
|
43
|
+
|
44
|
+
# Get another page
|
45
|
+
response = client.get '/users', :page => 2
|
46
|
+
|
47
|
+
|
48
|
+
### HTTP Verbs support
|
49
|
+
|
50
|
+
# Associate a tag to a user
|
51
|
+
response = client.put '/users/12345/associateTags', :tags => [12, 13, 14]
|
52
|
+
|
53
|
+
|
54
|
+
## Contributing
|
55
|
+
|
56
|
+
1. Fork it
|
57
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
58
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
59
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
60
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'doyoubuzz/showcase/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "doyoubuzz-showcase"
|
8
|
+
spec.version = Doyoubuzz::VERSION
|
9
|
+
spec.authors = ["David RUYER"]
|
10
|
+
spec.email = ["david.ruyer@gmail.com"]
|
11
|
+
spec.description = %q{Wrapper around the DoYouBuzz showcase API}
|
12
|
+
spec.summary = %q{Wrapper around the DoYouBuzz showcase API}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
|
24
|
+
spec.add_dependency "httparty", "~> 0.11"
|
25
|
+
spec.add_dependency "hashie", "~> 2.0"
|
26
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'hashie/mash'
|
3
|
+
|
4
|
+
module Doyoubuzz
|
5
|
+
class Showcase
|
6
|
+
|
7
|
+
include HTTParty
|
8
|
+
base_uri 'http://showcase.doyoubuzz.com/api/v1'
|
9
|
+
|
10
|
+
# Construction with mandatory api key and api secret
|
11
|
+
def initialize(api_key, api_secret)
|
12
|
+
@api_key = api_key
|
13
|
+
@api_secret = api_secret
|
14
|
+
end
|
15
|
+
|
16
|
+
# HTTP calls => forwarded to #call_api with the verb as the first argument
|
17
|
+
[:get, :post, :put, :delete].each do |verb|
|
18
|
+
define_method(verb) do |method, params = {}|
|
19
|
+
call_api(verb, method, params)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
# The actual api call
|
28
|
+
def call_api(verb, method, params)
|
29
|
+
res = self.class.send(verb, method, :query => process_params(params))
|
30
|
+
return process_response(res)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Process the HTTParty response, checking for errors
|
34
|
+
def process_response(res)
|
35
|
+
if !res.success?
|
36
|
+
raise HTTParty::ResponseError.new(res.response)
|
37
|
+
end
|
38
|
+
|
39
|
+
if res.is_a? Hash
|
40
|
+
return Hashie::Mash.new(res)
|
41
|
+
elsif res.is_a? Array
|
42
|
+
return res.map{|item| Hashie::Mash.new(item)}
|
43
|
+
else
|
44
|
+
return res
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
# The arguments processing and signing
|
50
|
+
def process_params(params)
|
51
|
+
params.merge!({:apikey => @api_key, :timestamp => Time.now.to_i})
|
52
|
+
params[:hash] = compute_signature(params)
|
53
|
+
params
|
54
|
+
end
|
55
|
+
|
56
|
+
# Computing the parameters signature hash
|
57
|
+
# Algorithm :
|
58
|
+
# - Order parameters by key
|
59
|
+
# - Concatenate their values
|
60
|
+
# - Append the current timestamp
|
61
|
+
# - Append the api secret
|
62
|
+
# - MD5 the resulting string
|
63
|
+
def compute_signature(params)
|
64
|
+
ordered_params_values = params.sort.map{|k,v|v}
|
65
|
+
concatenated_params_string = ordered_params_values.join
|
66
|
+
concatenated_params_string << @api_secret
|
67
|
+
|
68
|
+
return Digest::MD5.hexdigest(concatenated_params_string)
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://showcase.doyoubuzz.com/api/v1/users?apikey=an_api_key&hash=11a68a1bb9e23c681438efb714c9ad4d×tamp=1370534334
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 403
|
13
|
+
message: Forbidden
|
14
|
+
headers:
|
15
|
+
Date:
|
16
|
+
- Thu, 06 Jun 2013 15:58:54 GMT
|
17
|
+
Server:
|
18
|
+
- Apache/2.2
|
19
|
+
Cache-Control:
|
20
|
+
- no-cache
|
21
|
+
Transfer-Encoding:
|
22
|
+
- chunked
|
23
|
+
Content-Type:
|
24
|
+
- application/json
|
25
|
+
body:
|
26
|
+
encoding: UTF-8
|
27
|
+
string: |
|
28
|
+
{"error":{"code":403,"message":"Forbidden"}}
|
29
|
+
http_version:
|
30
|
+
recorded_at: Thu, 06 Jun 2013 15:58:55 GMT
|
31
|
+
recorded_with: VCR 2.5.0
|
@@ -0,0 +1,124 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://showcase.doyoubuzz.com/api/v1/users?apikey=an_api_key&hash=11a68a1bb9e23c681438efb714c9ad4d×tamp=1370534334
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
Date:
|
16
|
+
- Thu, 06 Jun 2013 15:57:15 GMT
|
17
|
+
Server:
|
18
|
+
- Apache/2.2
|
19
|
+
Cache-Control:
|
20
|
+
- no-cache
|
21
|
+
Transfer-Encoding:
|
22
|
+
- chunked
|
23
|
+
Content-Type:
|
24
|
+
- application/json
|
25
|
+
body:
|
26
|
+
encoding: UTF-8
|
27
|
+
string: '{"users":{"current_page_number":1,"num_items_per_page":20,"items":[{"username":"lvrmterjwea","email":"cuslijmmv@ocgfwjcuv.com","firstname":"nbrnoqn","lastname":"wfjtjnsxy","id":409632},{"username":"pnlsrwxqreh","email":"twbqztcml@qoyowwufj.com","firstname":"ydgnetr","lastname":"nthsuwmbw","id":683507},{"username":"xamfolxvmvw","email":"srcriwspx@kcbidtybg.com","firstname":"dikgtqf","lastname":"uqvipekkw","id":777742},{"username":"purrnerwsoi","email":"pbgqdrxgy@uwjvjdrae.com","firstname":"qunnwet","lastname":"kalpcmsct","id":489468},{"username":"jzagsqyhiay","email":"vtbbschfn@lckixfujf.com","firstname":"lqbsyvl","lastname":"qzwfcsash","id":159122},{"username":"evagcfcqdrt","email":"bmqquglfh@gnjikshdp.com","firstname":"qrrvqfl","lastname":"cufblqqtd","id":819427},{"username":"sniabboudmy","email":"sutmfwrhr@okebhflgh.com","firstname":"bgenhsh","lastname":"yderwvzwu","id":707699},{"username":"sifstaypiav","email":"hbmkrxczn@wcfojnoxg.com","firstname":"bwpsixt","lastname":"xhqiujjzv","id":900721},{"username":"qtshkhzngoc","email":"frqebwcco@vtlykuwqw.com","firstname":"cuqekqp","lastname":"mbvyoiegh","id":336722},{"username":"unpvaqfvlaz","email":"lagleoyly@xwvmtykzj.com","firstname":"ksgzglo","lastname":"ajprfeptt","id":202730},{"username":"efvvorfzicf","email":"nafeocmlo@lglevredx.com","firstname":"uuxtpui","lastname":"cikpoaqif","id":885925},{"username":"akvnsgmqhnr","email":"bvcpmqwgp@hthkwxdtd.com","firstname":"afxiaei","lastname":"itjirbghd","id":248555},{"username":"vkhzqjmzqxl","email":"loybsrnlh@ajjbovwki.com","firstname":"oyhmrgu","lastname":"yynuzskas","id":502227},{"username":"suvdmtykpfc","email":"jxhwgqryg@fvlryraqt.com","firstname":"zpatimc","lastname":"yalilktvi","id":466551},{"username":"wfdmacwblgb","email":"qqeiopomo@edxyvucgm.com","firstname":"ppppyeq","lastname":"bbigngmbb","id":492976},{"username":"sppornjgdea","email":"gxcpevtxd@xkjevvfju.com","firstname":"gadqcmi","lastname":"ipxjtgnlg","id":86855},{"username":"tlztdmqmbdl","email":"anapxqulq@dapqmrbce.com","firstname":"msubzkh","lastname":"shqhqulhc","id":203486},{"username":"kjumgryocef","email":"rjnqskibz@oiynnsepx.com","firstname":"rhhbflt","lastname":"pbkhcdere","id":378199},{"username":"auqmurvzpcj","email":"csukzqsxt@amdvhjgnx.com","firstname":"jhvhrcv","lastname":"trcxvfbnk","id":90629},{"username":"lbgppnnimyb","email":"otdyszrie@qgapnhekl.com","firstname":"ecutuep","lastname":"ueevhrfvk","id":651639}],"total_count":748,"paginator_options":{"pageParameterName":"page","sortFieldParameterName":"sort","sortDirectionParameterName":"direction","filterFieldParameterName":"filterField","filterValueParameterName":"filterValue","distinct":true,"sortFieldWhitelist":["u.firstname","u.lastname","u.email","g.name","u.id"]},"custom_parameters":[],"route":"api_users_all","params":{"apikey":"an_api_key","timestamp":"1370534334","hash":"11a68a1bb9e23c681438efb714c9ad4d"},"page_range":5,"template":"DYBShowcaseBundle:Common:pagination.html.twig","sortable_template":"DYBShowcaseBundle:Common:sortable.html.twig","filtration_template":"KnpPaginatorBundle:Pagination:filtration.html.twig","extra_view_params":[]},"total":748,"next":"/api/v1/users?page=2"}'
|
28
|
+
http_version:
|
29
|
+
recorded_at: Thu, 06 Jun 2013 15:58:54 GMT
|
30
|
+
- request:
|
31
|
+
method: get
|
32
|
+
uri: http://showcase.doyoubuzz.com/api/v1/tags?apikey=an_api_key&hash=11a68a1bb9e23c681438efb714c9ad4d×tamp=1370534334
|
33
|
+
body:
|
34
|
+
encoding: US-ASCII
|
35
|
+
string: ''
|
36
|
+
headers: {}
|
37
|
+
response:
|
38
|
+
status:
|
39
|
+
code: 200
|
40
|
+
message: OK
|
41
|
+
headers:
|
42
|
+
Date:
|
43
|
+
- Thu, 06 Jun 2013 17:19:59 GMT
|
44
|
+
Server:
|
45
|
+
- Apache/2.2
|
46
|
+
Cache-Control:
|
47
|
+
- no-cache
|
48
|
+
Transfer-Encoding:
|
49
|
+
- chunked
|
50
|
+
Content-Type:
|
51
|
+
- application/json
|
52
|
+
body:
|
53
|
+
encoding: UTF-8
|
54
|
+
string: '[{"id":356,"id_origin":0,"title":"Grande Ecole","translations":[{"id":1,"locale":"en","field":"title","content":"Master
|
55
|
+
of Science in Management - Grande Ecole"}]},{"id":357,"id_origin":0,"title":"Bachelor
|
56
|
+
in Business Administration","translations":[{"id":2,"locale":"en","field":"title","content":"Bachelor
|
57
|
+
in Business Administration"}]},{"id":358,"id_origin":0,"title":"Mast\u00e8res
|
58
|
+
Sp\u00e9cialis\u00e9s","translations":[{"id":4,"locale":"en","field":"title","content":"Advanced
|
59
|
+
Masters"}]},{"id":359,"id_origin":0,"title":"Marketing Management","translations":[{"id":7,"locale":"en","field":"title","content":"Marketing
|
60
|
+
Management"}]},{"id":360,"id_origin":0,"title":"Logistique et Management de
|
61
|
+
la Supply Chain","translations":[{"id":9,"locale":"en","field":"title","content":"Logistics
|
62
|
+
and Supply Chain Management"}]},{"id":361,"id_origin":0,"title":"Gestion Achats
|
63
|
+
Internationaux","translations":[{"id":10,"locale":"en","field":"title","content":"International
|
64
|
+
Supply Management"}]},{"id":362,"id_origin":0,"title":"Techniques Financi\u00e8res","translations":[{"id":11,"locale":"en","field":"title","content":"Financial
|
65
|
+
Techniques"}]},{"id":364,"id_origin":0,"title":"Droit des Affaires Internationales
|
66
|
+
et Management","translations":[{"id":12,"locale":"en","field":"title","content":"International
|
67
|
+
Business Law and Management"}]},{"id":365,"id_origin":0,"title":"Management
|
68
|
+
de Projets Technologiques","translations":[{"id":13,"locale":"en","field":"title","content":"Management
|
69
|
+
of Technological Projects"}]},{"id":366,"id_origin":0,"title":"Management
|
70
|
+
des Syst\u00e8mes d''Information en R\u00e9seau","translations":[{"id":14,"locale":"en","field":"title","content":"Information
|
71
|
+
Systems and Telecommunication Networks"}]},{"id":367,"id_origin":0,"title":"Centrale
|
72
|
+
- ESSEC Entrepreneurs","translations":[{"id":15,"locale":"en","field":"title","content":"Entrepreneurship
|
73
|
+
in partnership with Ecole Centrale Paris"}]},{"id":368,"id_origin":0,"title":"Management
|
74
|
+
International Agro-alimentaire","translations":[{"id":16,"locale":"en","field":"title","content":"International
|
75
|
+
Food Industry Management"}]},{"id":369,"id_origin":0,"title":"Management Urbain,
|
76
|
+
Environnement et Services","translations":[{"id":17,"locale":"en","field":"title","content":"Urban,
|
77
|
+
Environmental and Services Management"}]},{"id":370,"id_origin":0,"title":"Strategy
|
78
|
+
and Management of International Business","translations":[{"id":18,"locale":"en","field":"title","content":"Strategy
|
79
|
+
and Management of International Business"}]},{"id":371,"id_origin":0,"title":"MBA","translations":[]},{"id":372,"id_origin":0,"title":"Global
|
80
|
+
MBA","translations":[{"id":8,"locale":"en","field":"title"}]},{"id":373,"id_origin":0,"title":"MBA
|
81
|
+
in International Luxury Brand Management","translations":[]},{"id":374,"id_origin":0,"title":"MBA
|
82
|
+
in Hospitality Management (IMHI)","translations":[]},{"id":375,"id_origin":0,"title":"One-year
|
83
|
+
track","translations":[]},{"id":376,"id_origin":0,"title":"Two-year track","translations":[]},{"id":377,"id_origin":0,"title":"Ph.D.","translations":[]},{"id":508,"id_origin":0,"title":"Modular
|
84
|
+
Track","translations":[]},{"id":1318,"id_origin":0,"title":"Accounting & Auditing","translations":[]},{"id":1319,"id_origin":0,"title":"Economics","translations":[]},{"id":1320,"id_origin":0,"title":"Finance","translations":[]},{"id":1321,"id_origin":0,"title":"Management","translations":[]},{"id":1322,"id_origin":0,"title":"Marketing","translations":[]},{"id":1323,"id_origin":0,"title":"Operations
|
85
|
+
Management and Decision Sciences","translations":[]},{"id":1324,"id_origin":0,"title":"Executive
|
86
|
+
MBA","translations":[]},{"id":1325,"id_origin":0,"title":"Week-End Track","translations":[]},{"id":1420,"id_origin":0,"title":"MS
|
87
|
+
Financial Engineering Asia","translations":[]},{"id":1426,"id_origin":0,"title":"Dipl\u00f4m\u00e9s","translations":[{"id":5,"locale":"en","field":"title","content":"Alumni"}]},{"id":1427,"id_origin":0,"title":"Grande
|
88
|
+
Ecole","translations":[{"id":19,"locale":"en","field":"title","content":"Master
|
89
|
+
of Science in Management - Grande Ecole"}]},{"id":1428,"id_origin":0,"title":"Bachelor
|
90
|
+
in Business Administration","translations":[{"id":20,"locale":"en","field":"title","content":"Bachelor
|
91
|
+
in Business Administration"}]},{"id":1429,"id_origin":0,"title":"Mast\u00e8res
|
92
|
+
Sp\u00e9cialis\u00e9s","translations":[{"id":21,"locale":"en","field":"title","content":"Advanced
|
93
|
+
Masters"}]},{"id":1431,"id_origin":0,"title":"Logistique et Management de
|
94
|
+
la Supply Chain","translations":[{"id":22,"locale":"en","field":"title","content":"Logistics
|
95
|
+
and Supply Chain Management"}]},{"id":1432,"id_origin":0,"title":"Marketing
|
96
|
+
Management","translations":[{"id":23,"locale":"en","field":"title","content":"Marketing
|
97
|
+
Management"}]},{"id":1433,"id_origin":0,"title":"Gestion Achats Internationaux","translations":[{"id":24,"locale":"en","field":"title","content":"International
|
98
|
+
Supply Management"}]},{"id":1434,"id_origin":0,"title":"Techniques Financi\u00e8res","translations":[{"id":25,"locale":"en","field":"title","content":"Financial
|
99
|
+
Techniques"}]},{"id":1435,"id_origin":0,"title":"Droit des Affaires Internationales
|
100
|
+
et Management","translations":[{"id":26,"locale":"en","field":"title","content":"International
|
101
|
+
Business Law and Management"}]},{"id":1436,"id_origin":0,"title":"Management
|
102
|
+
de Projets Technologiques","translations":[{"id":27,"locale":"en","field":"title","content":"Management
|
103
|
+
of Technological Projects"}]},{"id":1437,"id_origin":0,"title":"Management
|
104
|
+
des Syst\u00e8mes d''Information en R\u00e9seaux","translations":[{"id":28,"locale":"en","field":"title","content":"Information
|
105
|
+
Systems and Telecommunication Networks"}]},{"id":1438,"id_origin":0,"title":"Centrale
|
106
|
+
- ESSEC Entrepreneurs","translations":[{"id":29,"locale":"en","field":"title","content":"Entrepreneurship
|
107
|
+
in partnership with Ecole Centrale Paris"}]},{"id":1439,"id_origin":0,"title":"Management
|
108
|
+
International Agro-alimentaire","translations":[{"id":30,"locale":"en","field":"title","content":"International
|
109
|
+
Food Industry Management"}]},{"id":1440,"id_origin":0,"title":"Management
|
110
|
+
Urbain, Environnement et Services","translations":[{"id":31,"locale":"en","field":"title","content":"Urban,
|
111
|
+
Environmental and Services Management"}]},{"id":1441,"id_origin":0,"title":"Strategy
|
112
|
+
and Management of International Business","translations":[{"id":32,"locale":"en","field":"title","content":"Strategy
|
113
|
+
and Management of International Business"}]},{"id":1442,"id_origin":0,"title":"Financial
|
114
|
+
Engineering Asia","translations":[{"id":33,"locale":"en","field":"title","content":"Financial
|
115
|
+
Engineering Asia"}]},{"id":1443,"id_origin":0,"title":"Strategy and Management
|
116
|
+
of International Business","translations":[{"id":34,"locale":"en","field":"title","content":"Strategy
|
117
|
+
and Management of International Business"}]},{"id":1444,"id_origin":0,"title":"MBA","translations":[]},{"id":1445,"id_origin":0,"title":"Global
|
118
|
+
MBA","translations":[]},{"id":1446,"id_origin":0,"title":"MBA in International
|
119
|
+
Luxury Brand Management","translations":[]},{"id":1447,"id_origin":0,"title":"MBA
|
120
|
+
in Hospitality Management (IMHI)","translations":[]},{"id":1448,"id_origin":0,"title":"Executive
|
121
|
+
MBA","translations":[]},{"id":1449,"id_origin":0,"title":"Ph.D","translations":[]},{"id":1451,"id_origin":0,"title":"ISFOGEP","translations":[]}]'
|
122
|
+
http_version:
|
123
|
+
recorded_at: Thu, 06 Jun 2013 15:58:54 GMT
|
124
|
+
recorded_with: VCR 2.5.0
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'doyoubuzz/showcase'
|
4
|
+
|
5
|
+
describe Doyoubuzz::Showcase do
|
6
|
+
|
7
|
+
let(:api_key){ 'an_api_key' }
|
8
|
+
let(:api_secret){ 'an_api_secret' }
|
9
|
+
|
10
|
+
describe '#new' do
|
11
|
+
it 'should require an api key and secret key' do
|
12
|
+
expect{ Doyoubuzz::Showcase.new }.to raise_error ArgumentError
|
13
|
+
|
14
|
+
expect{ Doyoubuzz::Showcase.new(api_key, api_secret) }.to_not raise_error
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#call' do
|
19
|
+
let(:showcase){ Doyoubuzz::Showcase.new(api_key, api_secret) }
|
20
|
+
let(:method){ '/a_method' }
|
21
|
+
let(:arguments){ {:foo => 'bar', :zab => 'baz'} }
|
22
|
+
let(:timestamp){ 1370534334 }
|
23
|
+
|
24
|
+
# The timestamp is important in the request generation and the VCR handling. Here it is set at a fixed date
|
25
|
+
before(:each) do
|
26
|
+
time = Time.at(timestamp)
|
27
|
+
Time.stub!(:now).and_return time
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should compute a valid signature" do
|
31
|
+
Doyoubuzz::Showcase.new('IuQSDLKQLSDK344590Li987', 'IuJyt42BnUiOlPM8FvB67tG').send(:compute_signature, {:apikey => 'IuQSDLKQLSDK344590Li987', :timestamp => timestamp}).should == '1dd33466d71275d06c9e17e18235c9f0'
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should generate a valid signed api call" do
|
35
|
+
showcase.stub!(:process_response) # We only want to check the sent parameters here
|
36
|
+
showcase.class.should_receive(:get).with("/path", {:query => {:foo => "bar", :zab => "baz", :apikey => "an_api_key", :timestamp => timestamp, :hash => "757b04a866f1d02f077471589341ff7a"}})
|
37
|
+
|
38
|
+
showcase.get('/path', arguments)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should handle HTTP verbs" do
|
42
|
+
expect(showcase).to respond_to :get
|
43
|
+
expect(showcase).to respond_to :post
|
44
|
+
expect(showcase).to respond_to :put
|
45
|
+
expect(showcase).to respond_to :delete
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should return an explorable hash" do
|
49
|
+
VCR.use_cassette("good_call") do
|
50
|
+
res = showcase.get('/users')
|
51
|
+
|
52
|
+
res.keys.should == ["users", "total", "next"]
|
53
|
+
res["users"]["items"].first.keys.should == ["username", "email", "firstname", "lastname", "id"]
|
54
|
+
res.users.items.first.username.should == "lvrmterjwea"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
it "should handle array responses" do
|
60
|
+
VCR.use_cassette("good_call") do
|
61
|
+
res = showcase.get('/tags')
|
62
|
+
|
63
|
+
res.should be_a Array
|
64
|
+
res.first.should be_a Hashie::Mash
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
it "should raise an exception on a failed call" do
|
70
|
+
VCR.use_cassette("failed_call") do
|
71
|
+
expect{ res = showcase.get('/users') }.to raise_error do |error|
|
72
|
+
error.should be_a(HTTParty::ResponseError)
|
73
|
+
error.response.should == Net::HTTPForbidden
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
require 'vcr'
|
5
|
+
|
6
|
+
VCR.configure do |conf|
|
7
|
+
conf.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
|
8
|
+
conf.hook_into :webmock
|
9
|
+
conf.default_cassette_options = { :record => :new_episodes }
|
10
|
+
end
|
11
|
+
|
12
|
+
# Rspec config goes here
|
13
|
+
RSpec.configure do |conf|
|
14
|
+
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: doyoubuzz-showcase
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- David RUYER
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-06-06 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.11'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.11'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: hashie
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.0'
|
69
|
+
description: Wrapper around the DoYouBuzz showcase API
|
70
|
+
email:
|
71
|
+
- david.ruyer@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- .rspec
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- doyoubuzz-showcase.gemspec
|
83
|
+
- lib/doyoubuzz/showcase.rb
|
84
|
+
- lib/doyoubuzz/showcase/version.rb
|
85
|
+
- spec/fixtures/vcr_cassettes/failed_call.yml
|
86
|
+
- spec/fixtures/vcr_cassettes/good_call.yml
|
87
|
+
- spec/showcase_spec.rb
|
88
|
+
- spec/spec_helper.rb
|
89
|
+
homepage: ''
|
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.0.3
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: Wrapper around the DoYouBuzz showcase API
|
113
|
+
test_files:
|
114
|
+
- spec/fixtures/vcr_cassettes/failed_call.yml
|
115
|
+
- spec/fixtures/vcr_cassettes/good_call.yml
|
116
|
+
- spec/showcase_spec.rb
|
117
|
+
- spec/spec_helper.rb
|