board-client 0.1.0 → 0.2.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.
- data/VERSION +1 -1
- data/board-client.gemspec +5 -13
- data/lib/board/candidate_search.rb +22 -47
- data/lib/board/client.rb +22 -15
- data/lib/board/request.rb +68 -0
- data/spec/board/{api/candidate_searches_spec.rb → candidate_search_spec.rb} +9 -47
- data/spec/board/client_spec.rb +85 -2
- metadata +7 -15
- data/lib/board/api/base.rb +0 -49
- data/lib/board/api/candidate_invitations.rb +0 -11
- data/lib/board/api/candidate_searches.rb +0 -11
- data/lib/board/api/users.rb +0 -21
- data/lib/board/api.rb +0 -10
- data/spec/board/api/candidate_invitations_spec.rb +0 -40
- data/spec/board/api/users_spec.rb +0 -49
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/board-client.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{board-client}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Michael Guterl"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-05-03}
|
13
13
|
s.description = %q{A ruby wrapper for the board platform.}
|
14
14
|
s.email = %q{mguterl@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -26,16 +26,10 @@ Gem::Specification.new do |s|
|
|
26
26
|
"VERSION",
|
27
27
|
"board-client.gemspec",
|
28
28
|
"lib/board-client.rb",
|
29
|
-
"lib/board/api.rb",
|
30
|
-
"lib/board/api/base.rb",
|
31
|
-
"lib/board/api/candidate_invitations.rb",
|
32
|
-
"lib/board/api/candidate_searches.rb",
|
33
|
-
"lib/board/api/users.rb",
|
34
29
|
"lib/board/candidate_search.rb",
|
35
30
|
"lib/board/client.rb",
|
36
|
-
"
|
37
|
-
"spec/board/
|
38
|
-
"spec/board/api/users_spec.rb",
|
31
|
+
"lib/board/request.rb",
|
32
|
+
"spec/board/candidate_search_spec.rb",
|
39
33
|
"spec/board/client_spec.rb",
|
40
34
|
"spec/spec.opts",
|
41
35
|
"spec/spec_helper.rb"
|
@@ -45,9 +39,7 @@ Gem::Specification.new do |s|
|
|
45
39
|
s.rubygems_version = %q{1.5.2}
|
46
40
|
s.summary = %q{A ruby wrapper for the board platform}
|
47
41
|
s.test_files = [
|
48
|
-
"spec/board/
|
49
|
-
"spec/board/api/candidate_searches_spec.rb",
|
50
|
-
"spec/board/api/users_spec.rb",
|
42
|
+
"spec/board/candidate_search_spec.rb",
|
51
43
|
"spec/board/client_spec.rb",
|
52
44
|
"spec/spec_helper.rb"
|
53
45
|
]
|
@@ -1,69 +1,44 @@
|
|
1
1
|
module Board
|
2
2
|
|
3
|
-
class CandidateSearch
|
3
|
+
class CandidateSearch
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
attr_reader :params
|
8
|
-
|
9
|
-
def initialize(*args)
|
10
|
-
@params = args.pop
|
11
|
-
self.page = params[:page] || 1
|
12
|
-
super
|
13
|
-
end
|
14
|
-
|
15
|
-
def each_result
|
16
|
-
(1..total_pages).each do |page|
|
17
|
-
self.page = page
|
18
|
-
results.each do |result|
|
19
|
-
yield result
|
20
|
-
end
|
21
|
-
clear
|
22
|
-
end
|
23
|
-
end
|
5
|
+
attr_reader :errors
|
24
6
|
|
25
|
-
def
|
26
|
-
|
7
|
+
def initialize(client, params = {})
|
8
|
+
@client = client
|
9
|
+
@params = params
|
10
|
+
@errors = []
|
27
11
|
end
|
28
12
|
|
29
13
|
def results
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
def total
|
34
|
-
response['total']
|
14
|
+
initial_search['results']
|
35
15
|
end
|
36
16
|
|
37
|
-
def
|
38
|
-
|
39
|
-
|
17
|
+
def each_result
|
18
|
+
total = initial_search['total']
|
19
|
+
pages = (total / 10.0).ceil
|
40
20
|
|
41
|
-
|
42
|
-
params[:page]
|
43
|
-
end
|
21
|
+
initial_search['results'].each { |r| yield r }
|
44
22
|
|
45
|
-
|
46
|
-
|
23
|
+
(2..pages).each do |page|
|
24
|
+
search = @client.candidate_searches(@params.merge(:page => page))
|
25
|
+
results = search['results']
|
26
|
+
results.each { |r| yield r }
|
27
|
+
end
|
47
28
|
end
|
48
29
|
|
49
30
|
def valid?
|
50
|
-
|
31
|
+
perform_search and @errors.empty?
|
51
32
|
end
|
52
33
|
|
53
|
-
attr_reader :errors
|
54
|
-
|
55
34
|
private
|
56
35
|
|
57
|
-
def
|
58
|
-
@
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
def response
|
63
|
-
@response ||= get "/candidate_searches", params
|
64
|
-
rescue RestClient::Exception => e
|
65
|
-
@errors = decode_json(e.response)
|
36
|
+
def initial_search
|
37
|
+
@initial_search ||= @client.candidate_searches(@params)
|
38
|
+
rescue Board::Request::Error => e
|
39
|
+
@errors = Yajl::Parser.parse(e.response.body)
|
66
40
|
end
|
41
|
+
alias perform_search initial_search
|
67
42
|
|
68
43
|
end
|
69
44
|
|
data/lib/board/client.rb
CHANGED
@@ -1,17 +1,13 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler/setup'
|
3
|
-
|
4
|
-
require 'rest_client'
|
5
1
|
require 'yajl'
|
6
2
|
|
7
|
-
require 'board/
|
3
|
+
require 'board/request'
|
4
|
+
require 'board/candidate_search'
|
8
5
|
|
9
6
|
module Board
|
10
|
-
|
11
|
-
autoload :CandidateSearch, 'board/candidate_search'
|
12
|
-
|
13
7
|
class Client
|
14
8
|
|
9
|
+
include Request
|
10
|
+
|
15
11
|
class << self
|
16
12
|
attr_accessor :default_url
|
17
13
|
end
|
@@ -22,18 +18,29 @@ module Board
|
|
22
18
|
@url = url
|
23
19
|
end
|
24
20
|
|
25
|
-
def
|
26
|
-
|
21
|
+
def candidate_searches(params)
|
22
|
+
get "/candidate_searches", params
|
27
23
|
end
|
28
24
|
|
29
|
-
def
|
30
|
-
|
25
|
+
def find_user(params)
|
26
|
+
get "/users", params
|
31
27
|
end
|
32
28
|
|
33
|
-
def
|
34
|
-
|
29
|
+
def mark_user_invalid(params)
|
30
|
+
get "/users/invalid", params
|
35
31
|
end
|
36
32
|
|
37
|
-
|
33
|
+
def unsubscribe(params)
|
34
|
+
get "/users/unsubscribe", params
|
35
|
+
end
|
38
36
|
|
37
|
+
def create_candidate_invitation(params)
|
38
|
+
post "/candidate_invitations", params
|
39
|
+
end
|
40
|
+
|
41
|
+
def find_candidate(candidate_id)
|
42
|
+
get "/candidates/#{candidate_id}", {}
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
39
46
|
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module Board
|
2
|
+
module Request
|
3
|
+
|
4
|
+
class Error < StandardError
|
5
|
+
attr_reader :response
|
6
|
+
|
7
|
+
def initialize(response)
|
8
|
+
@response = response
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def post(path, params)
|
15
|
+
request path, params, :post
|
16
|
+
end
|
17
|
+
|
18
|
+
def get(path, params)
|
19
|
+
request path, params, :get
|
20
|
+
end
|
21
|
+
|
22
|
+
def request(path, params, method)
|
23
|
+
params.merge!(:user_credentials => @api_key)
|
24
|
+
|
25
|
+
response = case method
|
26
|
+
when :get
|
27
|
+
uri = URI.parse(@url + path + "?" + hash_to_query_string(params))
|
28
|
+
Net::HTTP.get_response(uri)
|
29
|
+
when :post
|
30
|
+
uri = URI.parse(@url + path)
|
31
|
+
Net::HTTP.post_form(uri, params)
|
32
|
+
end
|
33
|
+
|
34
|
+
if response.code =~ /2../
|
35
|
+
Yajl::Parser.parse(response.body)
|
36
|
+
else
|
37
|
+
raise Error.new(response)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def hash_to_query_string(hash)
|
42
|
+
params = ''
|
43
|
+
stack = []
|
44
|
+
|
45
|
+
hash.each do |k, v|
|
46
|
+
if v.is_a?(Hash)
|
47
|
+
stack << [k,v]
|
48
|
+
else
|
49
|
+
params << "#{k}=#{v}&"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
stack.each do |parent, hash|
|
54
|
+
hash.each do |k, v|
|
55
|
+
if v.is_a?(Hash)
|
56
|
+
stack << ["#{parent}[#{k}]", v]
|
57
|
+
else
|
58
|
+
params << "#{parent}[#{k}]=#{v}&"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
params.chop! # trailing &
|
64
|
+
params
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
@@ -1,80 +1,42 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Board::
|
3
|
+
describe Board::CandidateSearch do
|
4
4
|
|
5
|
+
let(:search) { Board::CandidateSearch.new(client, :keywords => 'ruby') }
|
5
6
|
let(:client) { Board::Client.new('VALID_KEY') }
|
6
7
|
|
7
8
|
before do
|
8
|
-
stub_request(:get, "
|
9
|
-
with(:query => {
|
10
|
-
'user_credentials' => 'VALID_KEY',
|
11
|
-
'keywords' => 'ruby',
|
12
|
-
'page' => '1',
|
13
|
-
}).
|
9
|
+
stub_request(:get, "http://board.recruitmilitary.com:443/api/v1/candidate_searches?keywords=ruby&user_credentials=VALID_KEY").
|
14
10
|
to_return(:body => %q{{"results":[{"email":"candidate@recruitmilitary.com","zip_code":null,"last_activity_at":"2010-11-24T14:13:26Z","phone":null,"state":"OH","last_name":"Smith","first_name":"Rodolfo","resume_url":null,"location":"Hagenesside, OH","city":"Hagenesside"},{"email":"benton@effertz.info","zip_code":null,"last_activity_at":"2010-11-16T14:13:26Z","phone":null,"state":"OH","last_name":"Bins","first_name":"Alfred","resume_url":null,"location":"East Elizabeth, OH","city":"East Elizabeth"},{"email":"melba@armstrong.us","zip_code":null,"last_activity_at":"2010-11-22T14:13:27Z","phone":null,"state":"OH","last_name":"Pouros","first_name":"Warren","resume_url":null,"location":"Margemouth, OH","city":"Margemouth"},{"email":"yvette@lynch.name","zip_code":null,"last_activity_at":"2010-11-25T14:13:27Z","phone":null,"state":"OH","last_name":"Denesik","first_name":"Isai","resume_url":null,"location":"Lake Othaton, OH","city":"Lake Othaton"},{"email":"hipolito.mosciski@schoenbrown.uk","zip_code":null,"last_activity_at":"2010-11-25T14:13:28Z","phone":null,"state":"OH","last_name":"Paucek","first_name":"Cristina","resume_url":"https://localhost/resumes/1/resume.pdf","location":"East Aiden, OH","city":"East Aiden"},{"email":"lydia@cassin.name","zip_code":null,"last_activity_at":"2010-11-13T14:13:29Z","phone":null,"state":"OH","last_name":"Johnson","first_name":"Marianna","resume_url":null,"location":"Bartonhaven, OH","city":"Bartonhaven"},{"email":"gabe@price.ca","zip_code":null,"last_activity_at":"2010-11-16T14:13:29Z","phone":null,"state":"OH","last_name":"Wolf","first_name":"Idell","resume_url":"https://localhost/resumes/2/resume.pdf","location":"South Angelinestad, OH","city":"South Angelinestad"},{"email":"monserrat_douglas@zemlakbrekke.biz","zip_code":null,"last_activity_at":"2010-11-16T14:13:30Z","phone":null,"state":"OH","last_name":"Shanahan","first_name":"Zelda","resume_url":null,"location":"Mosesstad, OH","city":"Mosesstad"},{"email":"vada.hauck@gaylordbosco.co.uk","zip_code":null,"last_activity_at":"2010-11-12T14:13:30Z","phone":null,"state":"OH","last_name":"Bergstrom","first_name":"Anabelle","resume_url":null,"location":"Cliffordhaven, OH","city":"Cliffordhaven"},{"email":"maeve@abernathywaelchi.info","zip_code":null,"last_activity_at":"2010-12-01T14:13:31Z","phone":null,"state":"OH","last_name":"Gibson","first_name":"Rubie","resume_url":null,"location":"New Tre, OH","city":"New Tre"}],"page":1,"total":15}})
|
15
|
-
stub_request(:get, "
|
16
|
-
with(:query => {
|
17
|
-
'user_credentials' => 'VALID_KEY',
|
18
|
-
'keywords' => 'ruby',
|
19
|
-
'page' => '2',
|
20
|
-
}).
|
11
|
+
stub_request(:get, "http://board.recruitmilitary.com:443/api/v1/candidate_searches?keywords=ruby&page=2&user_credentials=VALID_KEY").
|
21
12
|
to_return(:body => %q{{"results":[{"email":"candidate@recruitmilitary.com","zip_code":null,"last_activity_at":"2010-11-24T14:13:26Z","phone":null,"state":"OH","last_name":"Smith","first_name":"Rodolfo","resume_url":null,"location":"Hagenesside, OH","city":"Hagenesside"},{"email":"benton@effertz.info","zip_code":null,"last_activity_at":"2010-11-16T14:13:26Z","phone":null,"state":"OH","last_name":"Bins","first_name":"Alfred","resume_url":null,"location":"East Elizabeth, OH","city":"East Elizabeth"},{"email":"melba@armstrong.us","zip_code":null,"last_activity_at":"2010-11-22T14:13:27Z","phone":null,"state":"OH","last_name":"Pouros","first_name":"Warren","resume_url":null,"location":"Margemouth, OH","city":"Margemouth"},{"email":"yvette@lynch.name","zip_code":null,"last_activity_at":"2010-11-25T14:13:27Z","phone":null,"state":"OH","last_name":"Denesik","first_name":"Isai","resume_url":null,"location":"Lake Othaton, OH","city":"Lake Othaton"},{"email":"hipolito.mosciski@schoenbrown.uk","zip_code":null,"last_activity_at":"2010-11-25T14:13:28Z","phone":null,"state":"OH","last_name":"Paucek","first_name":"Cristina","resume_url":"https://localhost/resumes/1/resume.pdf","location":"East Aiden, OH","city":"East Aiden"}],"page":2,"total":15}})
|
22
|
-
stub_request(:get, "
|
23
|
-
with(:query => {
|
24
|
-
'user_credentials' => 'VALID_KEY',
|
25
|
-
'per_page' => '501',
|
26
|
-
'page' => '1',
|
27
|
-
}).
|
13
|
+
stub_request(:get, "http://board.recruitmilitary.com:443/api/v1/candidate_searches?per_page=501&user_credentials=VALID_KEY").
|
28
14
|
to_return(:body => %q{[["per_page", "must be less than or equal to 500"]]},
|
29
15
|
:status => 422)
|
30
16
|
end
|
31
17
|
|
32
18
|
describe "searching", "when valid" do
|
33
|
-
|
34
|
-
let(:search) { client.candidate_search(:keywords => "ruby") }
|
35
|
-
|
36
|
-
it 'is valid' do
|
37
|
-
search.should be_valid
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'returns the number of search results' do
|
41
|
-
search.total.should == 15
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'returns the page' do
|
45
|
-
search.page.should == 1
|
46
|
-
end
|
47
|
-
|
48
19
|
it 'returns the correct number of results' do
|
49
20
|
search.results.size.should == 10
|
50
21
|
end
|
51
22
|
|
52
|
-
it 'returns the correct number of total pages' do
|
53
|
-
search.total_pages.should == 2
|
54
|
-
end
|
55
|
-
|
56
23
|
it 'iterates through all results' do
|
57
24
|
results = []
|
58
25
|
search.each_result do |result|
|
59
26
|
results << result
|
60
27
|
end
|
61
|
-
results.size.should ==
|
28
|
+
results.size.should == 15
|
62
29
|
end
|
63
|
-
|
64
30
|
end
|
65
31
|
|
66
32
|
describe "searching", "when invalid" do
|
67
|
-
|
68
|
-
let(:search) { client.candidate_search(:per_page => 501) }
|
69
|
-
|
70
|
-
before do
|
71
|
-
search.should_not be_valid
|
72
|
-
end
|
33
|
+
let(:search) { Board::CandidateSearch.new(client, :per_page => '501') }
|
73
34
|
|
74
35
|
it 'returns a collection of errors' do
|
36
|
+
search.valid?
|
37
|
+
|
75
38
|
search.errors.should == [["per_page", "must be less than or equal to 500"]]
|
76
39
|
end
|
77
|
-
|
78
40
|
end
|
79
41
|
|
80
42
|
end
|
data/spec/board/client_spec.rb
CHANGED
@@ -1,11 +1,32 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
+
module RequestTracking
|
4
|
+
|
5
|
+
class Request < Struct.new(:path, :params, :method); end
|
6
|
+
|
7
|
+
def request(path, params, method)
|
8
|
+
requests << Request.new(path, params, method)
|
9
|
+
end
|
10
|
+
|
11
|
+
def requests
|
12
|
+
@requests ||= []
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
3
17
|
describe Board::Client do
|
4
18
|
|
5
|
-
let(:client) {
|
19
|
+
let(:client) {
|
20
|
+
client = Board::Client.new('VALID_KEY')
|
21
|
+
client.extend(RequestTracking)
|
22
|
+
client
|
23
|
+
}
|
6
24
|
|
7
|
-
|
25
|
+
def last_request
|
26
|
+
@last_request ||= client.requests.last
|
27
|
+
end
|
8
28
|
|
29
|
+
describe "when creating" do
|
9
30
|
context 'and missing an API key' do
|
10
31
|
it 'should raise an error' do
|
11
32
|
expect { Board::Client.new }.to raise_error
|
@@ -17,7 +38,69 @@ describe Board::Client do
|
|
17
38
|
Board::Client.new('API_KEY')
|
18
39
|
end
|
19
40
|
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#candidate_searches' do
|
44
|
+
it 'performs the correct request' do
|
45
|
+
client.candidate_searches(:keywords => 'ruby', :location => 'Cincinnati')
|
46
|
+
|
47
|
+
last_request.path.should == '/candidate_searches'
|
48
|
+
last_request.method.should == :get
|
49
|
+
last_request.params.should == {
|
50
|
+
:keywords => "ruby",
|
51
|
+
:location => "Cincinnati",
|
52
|
+
}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#find_user' do
|
57
|
+
it 'performs the correct request' do
|
58
|
+
client.find_user(:email => 'bob@rm.com')
|
59
|
+
|
60
|
+
last_request.path.should == '/users'
|
61
|
+
last_request.method.should == :get
|
62
|
+
last_request.params.should == { :email => 'bob@rm.com' }
|
63
|
+
end
|
64
|
+
end
|
20
65
|
|
66
|
+
describe '#mark_user_invalid' do
|
67
|
+
it 'performs the correct request' do
|
68
|
+
client.mark_user_invalid(:email => 'bob@rm.com')
|
69
|
+
|
70
|
+
last_request.path.should == '/users/invalid'
|
71
|
+
last_request.method.should == :get
|
72
|
+
last_request.params.should == { :email => 'bob@rm.com' }
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '#unsubscribe' do
|
77
|
+
it 'performs the correct request' do
|
78
|
+
client.unsubscribe(:email => 'bob@rm.com')
|
79
|
+
|
80
|
+
last_request.path.should == '/users/unsubscribe'
|
81
|
+
last_request.method.should == :get
|
82
|
+
last_request.params.should == { :email => 'bob@rm.com' }
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe '#create_candidate_invitation' do
|
87
|
+
it 'performs the correct request' do
|
88
|
+
client.create_candidate_invitation(:email => 'bob@rm.com')
|
89
|
+
|
90
|
+
last_request.path.should == '/candidate_invitations'
|
91
|
+
last_request.method.should == :post
|
92
|
+
last_request.params.should == { :email => 'bob@rm.com' }
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe '#candidates' do
|
97
|
+
it 'performs the correct request' do
|
98
|
+
client.find_candidate(42)
|
99
|
+
|
100
|
+
last_request.path.should == '/candidates/42'
|
101
|
+
last_request.method.should == :get
|
102
|
+
last_request.params.should == {}
|
103
|
+
end
|
21
104
|
end
|
22
105
|
|
23
106
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: board-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 2
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael Guterl
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-05-03 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -133,16 +133,10 @@ files:
|
|
133
133
|
- VERSION
|
134
134
|
- board-client.gemspec
|
135
135
|
- lib/board-client.rb
|
136
|
-
- lib/board/api.rb
|
137
|
-
- lib/board/api/base.rb
|
138
|
-
- lib/board/api/candidate_invitations.rb
|
139
|
-
- lib/board/api/candidate_searches.rb
|
140
|
-
- lib/board/api/users.rb
|
141
136
|
- lib/board/candidate_search.rb
|
142
137
|
- lib/board/client.rb
|
143
|
-
-
|
144
|
-
- spec/board/
|
145
|
-
- spec/board/api/users_spec.rb
|
138
|
+
- lib/board/request.rb
|
139
|
+
- spec/board/candidate_search_spec.rb
|
146
140
|
- spec/board/client_spec.rb
|
147
141
|
- spec/spec.opts
|
148
142
|
- spec/spec_helper.rb
|
@@ -181,8 +175,6 @@ signing_key:
|
|
181
175
|
specification_version: 3
|
182
176
|
summary: A ruby wrapper for the board platform
|
183
177
|
test_files:
|
184
|
-
- spec/board/
|
185
|
-
- spec/board/api/candidate_searches_spec.rb
|
186
|
-
- spec/board/api/users_spec.rb
|
178
|
+
- spec/board/candidate_search_spec.rb
|
187
179
|
- spec/board/client_spec.rb
|
188
180
|
- spec/spec_helper.rb
|
data/lib/board/api/base.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
module Board
|
2
|
-
module API
|
3
|
-
|
4
|
-
class Base
|
5
|
-
|
6
|
-
def initialize(api_key, base_url)
|
7
|
-
@api_key = api_key
|
8
|
-
@base_url = base_url
|
9
|
-
end
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
def get(*args)
|
14
|
-
request(:get, *args)
|
15
|
-
end
|
16
|
-
|
17
|
-
def post(*args)
|
18
|
-
request(:post, *args)
|
19
|
-
end
|
20
|
-
|
21
|
-
def request(http_method, *args)
|
22
|
-
path = args.shift
|
23
|
-
params = args.shift.merge(:user_credentials => @api_key)
|
24
|
-
url = @base_url + path
|
25
|
-
|
26
|
-
response = case http_method
|
27
|
-
when :get
|
28
|
-
RestClient.get(url, { :params => params, :accept => :json })
|
29
|
-
when :post
|
30
|
-
RestClient.post(url, encode_json(params), :content_type => :json, :accept => :json)
|
31
|
-
else
|
32
|
-
raise ArgumentError, "unknown http method: #{http_method}"
|
33
|
-
end
|
34
|
-
|
35
|
-
decode_json(response.body)
|
36
|
-
end
|
37
|
-
|
38
|
-
def encode_json(obj)
|
39
|
-
Yajl::Encoder.encode(obj)
|
40
|
-
end
|
41
|
-
|
42
|
-
def decode_json(json)
|
43
|
-
Yajl::Parser.parse(json)
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
49
|
-
end
|
data/lib/board/api/users.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
module Board
|
2
|
-
module API
|
3
|
-
|
4
|
-
class Users < Base
|
5
|
-
|
6
|
-
def find(params)
|
7
|
-
get "/users", params
|
8
|
-
end
|
9
|
-
|
10
|
-
def unsubscribe(params)
|
11
|
-
get "/users/unsubscribe", params
|
12
|
-
end
|
13
|
-
|
14
|
-
def invalid(params)
|
15
|
-
get "/users/invalid", params
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
data/lib/board/api.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Board::API::CandidateInvitations do
|
4
|
-
|
5
|
-
let(:client) { Board::Client.new('VALID_KEY') }
|
6
|
-
|
7
|
-
before do
|
8
|
-
stub_request(:post, "https://board.recruitmilitary.com/api/v1/candidate_invitations").
|
9
|
-
with(:body => {
|
10
|
-
"first_name" => "Michael",
|
11
|
-
"email" => "michael.jordan@nike.com",
|
12
|
-
"last_name" => "Jordan",
|
13
|
-
"user_credentials" => "VALID_KEY"}).
|
14
|
-
to_return(:body => %q{{"created_at":"2010-09-21T17:51:23Z","accepted_at":null,"updated_at":"2010-09-21T17:51:23Z","secret_id":"5991a3d7c0fdfe0b6fa659ff8b5de18d","id":3,"last_name":"bar","organization_id":null,"first_name":"foo","email":"foo@bar.com"}})
|
15
|
-
end
|
16
|
-
|
17
|
-
describe "#create" do
|
18
|
-
|
19
|
-
context 'when successful' do
|
20
|
-
it 'should return a hash representing the saved invitation' do
|
21
|
-
response = client.candidate_invitations.create(:first_name => "Michael",
|
22
|
-
:last_name => "Jordan",
|
23
|
-
:email => "michael.jordan@nike.com")
|
24
|
-
response.should == {
|
25
|
-
"id" => 3,
|
26
|
-
"first_name" => "foo",
|
27
|
-
"last_name" => "bar",
|
28
|
-
"email" => "foo@bar.com",
|
29
|
-
"secret_id" => "5991a3d7c0fdfe0b6fa659ff8b5de18d",
|
30
|
-
"organization_id" => nil,
|
31
|
-
"accepted_at" => nil,
|
32
|
-
"created_at" => "2010-09-21T17:51:23Z",
|
33
|
-
"updated_at" => "2010-09-21T17:51:23Z",
|
34
|
-
}
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Board::API::Users do
|
4
|
-
|
5
|
-
let(:client) { Board::Client.new('VALID_KEY') }
|
6
|
-
|
7
|
-
before do
|
8
|
-
stub_request(:get, "https://board.recruitmilitary.com/api/v1/users?email=jerry@seinfeld.com&user_credentials=VALID_KEY").
|
9
|
-
to_return(:body => %q{[{"id":1,"last_name":"Seinfeld","first_name":"Jerry","email":"jerry@seinfeld.com"}]})
|
10
|
-
|
11
|
-
stub_request(:get, "https://board.recruitmilitary.com/api/v1/users/unsubscribe?email=jerry@seinfeld.com&user_credentials=VALID_KEY").
|
12
|
-
to_return(:body => %q{{"unsubscribed_at":"2010-11-17T15:09:57-05:00"}})
|
13
|
-
|
14
|
-
stub_request(:get, "https://board.recruitmilitary.com/api/v1/users/invalid?email=jerry@seinfeld.com&user_credentials=VALID_KEY").
|
15
|
-
to_return(:body => %q{{"email_invalid_at":"2010-11-17T15:09:57-05:00"}})
|
16
|
-
end
|
17
|
-
|
18
|
-
describe "#find" do
|
19
|
-
|
20
|
-
it 'should return an array of hashes' do
|
21
|
-
response = client.users.find(:email => 'jerry@seinfeld.com')
|
22
|
-
|
23
|
-
response.should == [{ "id" => 1,
|
24
|
-
"last_name" => "Seinfeld",
|
25
|
-
"first_name" => "Jerry",
|
26
|
-
"email" => "jerry@seinfeld.com"}]
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "#unsubscribe" do
|
32
|
-
|
33
|
-
it 'should return a date' do
|
34
|
-
response = client.users.unsubscribe(:email => 'jerry@seinfeld.com')
|
35
|
-
|
36
|
-
response.should == { 'unsubscribed_at' => "2010-11-17T15:09:57-05:00" }
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
describe "#invalid" do
|
42
|
-
it 'returns the date the user was marked invalid' do
|
43
|
-
response = client.users.invalid(:email => 'jerry@seinfeld.com')
|
44
|
-
|
45
|
-
response.should == { 'email_invalid_at' => '2010-11-17T15:09:57-05:00' }
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|