clinch-talent 0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +61 -0
- data/README.md +38 -0
- data/Rakefile +6 -0
- data/clinch-talent.gemspec +18 -0
- data/lib/clinch-talent.rb +1 -0
- data/lib/clinch_talent.rb +7 -0
- data/lib/clinch_talent/base.rb +10 -0
- data/lib/clinch_talent/candidate.rb +5 -0
- data/lib/clinch_talent/hmac_signing_middleware.rb +93 -0
- data/lib/clinch_talent/social_profile.rb +5 -0
- data/test/clinch_talent/candidate_test.rb +22 -0
- data/test/test_helper.rb +10 -0
- metadata +105 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9b5486316763cbab65df5a15009613e813ba2952
|
4
|
+
data.tar.gz: d6943caad4eaa320c306eb644d9cfbb29ba17400
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 003c861644586a07cad13ea769185eb0c7bd8d43178ce1378282e4de1ffc81434935d12075b2ad074d6bdfcff6e227aad363e98b8179fa12f72ba9fc21e10d92
|
7
|
+
data.tar.gz: 65aa448502cd2fd3d2caace83b4c9033e9a5ae58a9205216549a56055080d9371e753a7bd1c43b0915a02102771222dbe98bb1c176e13d5c9e320301fe28afbf
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
clinch-talent (0.1)
|
5
|
+
json_api_client (~> 1.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activemodel (4.2.5)
|
11
|
+
activesupport (= 4.2.5)
|
12
|
+
builder (~> 3.1)
|
13
|
+
activesupport (4.2.5)
|
14
|
+
i18n (~> 0.7)
|
15
|
+
json (~> 1.7, >= 1.7.7)
|
16
|
+
minitest (~> 5.1)
|
17
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
18
|
+
tzinfo (~> 1.1)
|
19
|
+
addressable (2.4.0)
|
20
|
+
builder (3.2.2)
|
21
|
+
crack (0.4.3)
|
22
|
+
safe_yaml (~> 1.0.0)
|
23
|
+
faraday (0.9.2)
|
24
|
+
multipart-post (>= 1.2, < 3)
|
25
|
+
faraday_middleware (0.10.0)
|
26
|
+
faraday (>= 0.7.4, < 0.10)
|
27
|
+
hashdiff (0.2.3)
|
28
|
+
i18n (0.7.0)
|
29
|
+
json (1.8.3)
|
30
|
+
json_api_client (1.0.1)
|
31
|
+
activemodel (>= 3.2.0)
|
32
|
+
activesupport (>= 3.2.0)
|
33
|
+
addressable (~> 2.2)
|
34
|
+
faraday (>= 0.8.0)
|
35
|
+
faraday_middleware (~> 0.9)
|
36
|
+
metaclass (0.0.4)
|
37
|
+
minitest (5.8.3)
|
38
|
+
mocha (1.1.0)
|
39
|
+
metaclass (~> 0.0.1)
|
40
|
+
multipart-post (2.0.0)
|
41
|
+
rake (10.4.2)
|
42
|
+
safe_yaml (1.0.4)
|
43
|
+
thread_safe (0.3.5)
|
44
|
+
tzinfo (1.2.2)
|
45
|
+
thread_safe (~> 0.1)
|
46
|
+
webmock (1.22.3)
|
47
|
+
addressable (>= 2.3.6)
|
48
|
+
crack (>= 0.3.2)
|
49
|
+
hashdiff
|
50
|
+
|
51
|
+
PLATFORMS
|
52
|
+
ruby
|
53
|
+
|
54
|
+
DEPENDENCIES
|
55
|
+
clinch-talent!
|
56
|
+
mocha (~> 1.1)
|
57
|
+
rake
|
58
|
+
webmock
|
59
|
+
|
60
|
+
BUNDLED WITH
|
61
|
+
1.10.6
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# clinch-talent-ruby
|
2
|
+
A ruby client for the Clinch Talent API. Glues the json-api-client gem with HMAC signing and predefined models.
|
3
|
+
|
4
|
+
[![Build Status](https://travis-ci.org/ClinchIO/clinch-ruby-client.svg)](https://travis-ci.org/ClinchIO/clinch-ruby-client)
|
5
|
+
|
6
|
+
##Getting Started
|
7
|
+
|
8
|
+
This Ruby client allows developers to connect to the Clinch Talent API to access their data. In order to use the client you must have a valid Clinch Talent account and valid API keys. The steps to obtain keys can be found in the [developer documentation](http://dev.clinch.io/docs/api_getting_started).
|
9
|
+
|
10
|
+
##Using the Gem
|
11
|
+
|
12
|
+
Install the gem:
|
13
|
+
|
14
|
+
```
|
15
|
+
|
16
|
+
gem install clinch-talent
|
17
|
+
|
18
|
+
```
|
19
|
+
|
20
|
+
Require the gem:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
|
24
|
+
require 'clinch-talent'
|
25
|
+
|
26
|
+
```
|
27
|
+
|
28
|
+
Use the gem to get candidate data:
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
|
32
|
+
ClinchTalent::Base.config("YOUR-KEY", "YOUR-SECRET")
|
33
|
+
ClinchTalent::Candidate.all # Get data for the collection of candidates
|
34
|
+
ClinchTalent::Candidate.find('candidate-id') # Get data for an individual candidate using the candidate's ID
|
35
|
+
|
36
|
+
```
|
37
|
+
|
38
|
+
Run these tests with rake test
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'clinch-talent'
|
3
|
+
s.version = '0.1'
|
4
|
+
s.date = '2015-12-11'
|
5
|
+
s.summary = 'A ruby client for the Clinch Talent API'
|
6
|
+
s.description = 'A ruby client for the Clinch Talent API. Requests are HMAC signed. Responses are in JSON API format (https://jsonapi.org). See https://dev.clinch.io/v1.0/docs/api_getting_started'
|
7
|
+
s.authors = ['Damien Glancy', 'Peter Keogh', 'Steve Quinlan']
|
8
|
+
s.email = 'damien@clinch.io'
|
9
|
+
s.homepage = 'http://rubygems.org/gems/clinch-talent'
|
10
|
+
s.license = 'MIT'
|
11
|
+
s.add_dependency 'json_api_client', '~> 1.0'
|
12
|
+
s.add_development_dependency 'mocha', '~> 1.1'
|
13
|
+
s.add_development_dependency 'webmock'
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- test/*`.split("\n")
|
17
|
+
s.require_paths = ['lib']
|
18
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'clinch_talent'
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module ClinchTalent
|
2
|
+
class Base < ::JsonApiClient::Resource
|
3
|
+
def self.config(access_id, secret, options = {})
|
4
|
+
self.site = options[:site] || 'https://api.clinchtalent.com/v1/'
|
5
|
+
self.connection do |connection|
|
6
|
+
connection.use HmacSigningMiddleware, {access_id: access_id, secret: secret}
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module ClinchTalent
|
2
|
+
class HmacSigningMiddleware < Faraday::Middleware
|
3
|
+
def initialize(app, options, &block)
|
4
|
+
super(app)
|
5
|
+
@options = options
|
6
|
+
@block = block
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
env.request_headers['Content-MD5'] = calculated_md5(env)
|
11
|
+
env.request_headers['DATE'] = Time.now.utc.httpdate
|
12
|
+
env.request_headers['Authorization'] = "APIAuth #{@options[:access_id]}:#{hmac_signature(env, @options[:secret])}"
|
13
|
+
@app.call(env)
|
14
|
+
end
|
15
|
+
private
|
16
|
+
def calculated_md5(env)
|
17
|
+
# if env.request.body
|
18
|
+
# body = env.request.body
|
19
|
+
# else
|
20
|
+
# body = ''
|
21
|
+
# end
|
22
|
+
#excluding the body as part of the md5'ing
|
23
|
+
md5_base64digest('')
|
24
|
+
end
|
25
|
+
|
26
|
+
def md5_base64digest(string)
|
27
|
+
if Digest::MD5.respond_to?(:base64digest)
|
28
|
+
Digest::MD5.base64digest(string)
|
29
|
+
else
|
30
|
+
b64_encode(Digest::MD5.digest(string))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def b64_encode(string)
|
35
|
+
if Base64.respond_to?(:strict_encode64)
|
36
|
+
Base64.strict_encode64(string)
|
37
|
+
else
|
38
|
+
# Fall back to stripping out newlines on Ruby 1.8.
|
39
|
+
Base64.encode64(string).gsub(/\n/, '')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def fetch_headers(env)
|
44
|
+
capitalize_keys env.request_headers
|
45
|
+
end
|
46
|
+
|
47
|
+
def capitalize_keys(hsh)
|
48
|
+
capitalized_hash = {}
|
49
|
+
hsh.each_pair {|k,v| capitalized_hash[k.to_s.upcase] = v }
|
50
|
+
capitalized_hash
|
51
|
+
end
|
52
|
+
|
53
|
+
def hmac_signature(env, secret_key)
|
54
|
+
canonical_string = canonical_string(env)
|
55
|
+
digest = OpenSSL::Digest.new('sha1')
|
56
|
+
b64_encode(OpenSSL::HMAC.digest(digest, secret_key, canonical_string))
|
57
|
+
end
|
58
|
+
|
59
|
+
def canonical_string(env)
|
60
|
+
[ content_type(env),
|
61
|
+
content_md5(env),
|
62
|
+
parse_uri(env.url.to_s),
|
63
|
+
timestamp(env)
|
64
|
+
].join(',')
|
65
|
+
end
|
66
|
+
|
67
|
+
def timestamp(env)
|
68
|
+
value = find_header(env, %w(DATE HTTP_DATE))
|
69
|
+
value.nil? ? '' : value
|
70
|
+
end
|
71
|
+
|
72
|
+
def content_type(env)
|
73
|
+
value = find_header(env, %w(CONTENT-TYPE CONTENT_TYPE HTTP_CONTENT_TYPE))
|
74
|
+
value.nil? ? '' : value
|
75
|
+
end
|
76
|
+
|
77
|
+
def content_md5(env)
|
78
|
+
value = find_header(env, %w(CONTENT-MD5 CONTENT_MD5 HTTP-CONTENT-MD5 HTTP_CONTENT_MD5))
|
79
|
+
value.nil? ? '' : value
|
80
|
+
end
|
81
|
+
|
82
|
+
def find_header(env, keys)
|
83
|
+
keys.map {|key| env.request_headers[key] }.compact.first
|
84
|
+
end
|
85
|
+
|
86
|
+
def parse_uri(uri)
|
87
|
+
uri_without_host = uri.gsub(/https?:\/\/[^(,|\?|\/)]*/, '')
|
88
|
+
return '/' if uri_without_host.empty?
|
89
|
+
uri_without_host
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
|
3
|
+
module ClinchTalent
|
4
|
+
class CandidateTest < Minitest::Test
|
5
|
+
def test_signing
|
6
|
+
Time.stubs(:now).returns(Time.new(2014, 01, 01, 01, 01, 01))
|
7
|
+
|
8
|
+
# Having problem stubbing the body response, so not doing this now
|
9
|
+
|
10
|
+
stub_request(:get, 'https://api.clinchtalent.com/v1/candidates?include=social_profile').
|
11
|
+
with(:headers => {'Accept' => 'application/vnd.api+json',
|
12
|
+
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
13
|
+
'Authorization' => 'APIAuth access_id:mCPWePkgbJo3G9JSDrtdtQrKGek=',
|
14
|
+
'Content-Md5' => '1B2M2Y8AsgTpgAmY7PhCfg==',
|
15
|
+
'Content-Type' => 'application/vnd.api+json',
|
16
|
+
'Date' => 'Wed, 01 Jan 2014 01:01:01 GMT',
|
17
|
+
'User-Agent' => 'Faraday v0.9.2'})
|
18
|
+
ClinchTalent::Base.config('access_id', 'secret')
|
19
|
+
ClinchTalent::Candidate.includes(:social_profile).all
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require_relative '../lib/clinch_talent'
|
4
|
+
require 'faraday'
|
5
|
+
require 'json_api_client'
|
6
|
+
require 'mocha'
|
7
|
+
require 'minitest/autorun'
|
8
|
+
require 'mocha/mini_test'
|
9
|
+
require 'json'
|
10
|
+
require 'webmock/minitest'
|
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: clinch-talent
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Damien Glancy
|
8
|
+
- Peter Keogh
|
9
|
+
- Steve Quinlan
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2015-12-11 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: json_api_client
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '1.0'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: mocha
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - "~>"
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '1.1'
|
36
|
+
type: :development
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '1.1'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: webmock
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
description: A ruby client for the Clinch Talent API. Requests are HMAC signed. Responses
|
58
|
+
are in JSON API format (https://jsonapi.org). See https://dev.clinch.io/v1.0/docs/api_getting_started
|
59
|
+
email: damien@clinch.io
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- ".gitignore"
|
65
|
+
- ".travis.yml"
|
66
|
+
- Gemfile
|
67
|
+
- Gemfile.lock
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- clinch-talent.gemspec
|
71
|
+
- lib/clinch-talent.rb
|
72
|
+
- lib/clinch_talent.rb
|
73
|
+
- lib/clinch_talent/base.rb
|
74
|
+
- lib/clinch_talent/candidate.rb
|
75
|
+
- lib/clinch_talent/hmac_signing_middleware.rb
|
76
|
+
- lib/clinch_talent/social_profile.rb
|
77
|
+
- test/clinch_talent/candidate_test.rb
|
78
|
+
- test/test_helper.rb
|
79
|
+
homepage: http://rubygems.org/gems/clinch-talent
|
80
|
+
licenses:
|
81
|
+
- MIT
|
82
|
+
metadata: {}
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
requirements: []
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 2.4.5.1
|
100
|
+
signing_key:
|
101
|
+
specification_version: 4
|
102
|
+
summary: A ruby client for the Clinch Talent API
|
103
|
+
test_files:
|
104
|
+
- test/clinch_talent/candidate_test.rb
|
105
|
+
- test/test_helper.rb
|