board-client 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.
- data/.document +5 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +22 -0
- data/LICENSE +20 -0
- data/README.md +41 -0
- data/Rakefile +46 -0
- data/VERSION +1 -0
- data/board-client.gemspec +82 -0
- data/lib/board/api/base.rb +49 -0
- data/lib/board/api/candidate_invitations.rb +11 -0
- data/lib/board/api/candidate_searches.rb +11 -0
- data/lib/board/api/users.rb +21 -0
- data/lib/board/api.rb +10 -0
- data/lib/board/candidate_search.rb +70 -0
- data/lib/board/client.rb +39 -0
- data/lib/board-client.rb +1 -0
- data/spec/board/api/candidate_invitations_spec.rb +40 -0
- data/spec/board/api/candidate_searches_spec.rb +80 -0
- data/spec/board/api/users_spec.rb +49 -0
- data/spec/board/client_spec.rb +23 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +12 -0
- metadata +188 -0
data/.document
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
addressable (2.2.1)
|
5
|
+
crack (0.1.8)
|
6
|
+
mime-types (1.16)
|
7
|
+
rest-client (1.6.1)
|
8
|
+
mime-types (>= 1.16)
|
9
|
+
rspec (1.3.0)
|
10
|
+
webmock (1.3.5)
|
11
|
+
addressable (>= 2.1.1)
|
12
|
+
crack (>= 0.1.7)
|
13
|
+
yajl-ruby (0.7.7)
|
14
|
+
|
15
|
+
PLATFORMS
|
16
|
+
ruby
|
17
|
+
|
18
|
+
DEPENDENCIES
|
19
|
+
rest-client (~> 1.6.1)
|
20
|
+
rspec (~> 1.3.0)
|
21
|
+
webmock (~> 1.3.5)
|
22
|
+
yajl-ruby (~> 0.7.7)
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Michael Guterl
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# board-client
|
2
|
+
|
3
|
+
client = Board::Client.new('YOUR_API_KEY_HERE')
|
4
|
+
|
5
|
+
## candidate searches
|
6
|
+
|
7
|
+
search = client.candidate_search(:keywords => "ruby",
|
8
|
+
:distance => 50,
|
9
|
+
:location => "Cincinnati, OH")
|
10
|
+
|
11
|
+
iterate through current page of results
|
12
|
+
|
13
|
+
search.results.each do |result|
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
iterate through all pages and yield result
|
18
|
+
|
19
|
+
search.each_result do |result|
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
## invitations
|
24
|
+
|
25
|
+
invitation = client.create_invitation(:first_name => "Michael",
|
26
|
+
:last_name => "Jordan",
|
27
|
+
:email => "michael.jordan@nike.com")
|
28
|
+
|
29
|
+
## Note on Patches/Pull Requests
|
30
|
+
|
31
|
+
* Fork the project.
|
32
|
+
* Make your feature addition or bug fix.
|
33
|
+
* Add tests for it. This is important so I don't break it in a
|
34
|
+
future version unintentionally.
|
35
|
+
* Commit, do not mess with rakefile, version, or history.
|
36
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
37
|
+
* Send me a pull request. Bonus points for topic branches.
|
38
|
+
|
39
|
+
## Copyright
|
40
|
+
|
41
|
+
Copyright (c) 2010 Michael Guterl. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "board-client"
|
8
|
+
gem.summary = %Q{A ruby wrapper for the board platform}
|
9
|
+
gem.description = %Q{A ruby wrapper for the board platform.}
|
10
|
+
gem.email = "mguterl@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/mguterl/board-client"
|
12
|
+
gem.authors = ["Michael Guterl"]
|
13
|
+
gem.add_dependency "rest-client", "~> 1.6.1"
|
14
|
+
gem.add_dependency "yajl-ruby", "~> 0.7.7"
|
15
|
+
gem.add_development_dependency "rspec", "~> 1.3.0"
|
16
|
+
gem.add_development_dependency "webmock", "~> 1.3.5"
|
17
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
18
|
+
end
|
19
|
+
Jeweler::GemcutterTasks.new
|
20
|
+
rescue LoadError
|
21
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
22
|
+
end
|
23
|
+
|
24
|
+
require 'spec/rake/spectask'
|
25
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
26
|
+
spec.libs << 'lib' << 'spec'
|
27
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
28
|
+
end
|
29
|
+
|
30
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
31
|
+
spec.libs << 'lib' << 'spec'
|
32
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
33
|
+
spec.rcov = true
|
34
|
+
end
|
35
|
+
|
36
|
+
task :default => :spec
|
37
|
+
|
38
|
+
require 'rake/rdoctask'
|
39
|
+
Rake::RDocTask.new do |rdoc|
|
40
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
41
|
+
|
42
|
+
rdoc.rdoc_dir = 'rdoc'
|
43
|
+
rdoc.title = "board-client #{version}"
|
44
|
+
rdoc.rdoc_files.include('README*')
|
45
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
46
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{board-client}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Michael Guterl"]
|
12
|
+
s.date = %q{2011-04-05}
|
13
|
+
s.description = %q{A ruby wrapper for the board platform.}
|
14
|
+
s.email = %q{mguterl@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
"Gemfile",
|
22
|
+
"Gemfile.lock",
|
23
|
+
"LICENSE",
|
24
|
+
"README.md",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"board-client.gemspec",
|
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
|
+
"lib/board/candidate_search.rb",
|
35
|
+
"lib/board/client.rb",
|
36
|
+
"spec/board/api/candidate_invitations_spec.rb",
|
37
|
+
"spec/board/api/candidate_searches_spec.rb",
|
38
|
+
"spec/board/api/users_spec.rb",
|
39
|
+
"spec/board/client_spec.rb",
|
40
|
+
"spec/spec.opts",
|
41
|
+
"spec/spec_helper.rb"
|
42
|
+
]
|
43
|
+
s.homepage = %q{http://github.com/mguterl/board-client}
|
44
|
+
s.require_paths = ["lib"]
|
45
|
+
s.rubygems_version = %q{1.5.2}
|
46
|
+
s.summary = %q{A ruby wrapper for the board platform}
|
47
|
+
s.test_files = [
|
48
|
+
"spec/board/api/candidate_invitations_spec.rb",
|
49
|
+
"spec/board/api/candidate_searches_spec.rb",
|
50
|
+
"spec/board/api/users_spec.rb",
|
51
|
+
"spec/board/client_spec.rb",
|
52
|
+
"spec/spec_helper.rb"
|
53
|
+
]
|
54
|
+
|
55
|
+
if s.respond_to? :specification_version then
|
56
|
+
s.specification_version = 3
|
57
|
+
|
58
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
59
|
+
s.add_runtime_dependency(%q<rest-client>, ["~> 1.6.1"])
|
60
|
+
s.add_runtime_dependency(%q<yajl-ruby>, ["~> 0.7.7"])
|
61
|
+
s.add_runtime_dependency(%q<rest-client>, ["~> 1.6.1"])
|
62
|
+
s.add_runtime_dependency(%q<yajl-ruby>, ["~> 0.7.7"])
|
63
|
+
s.add_development_dependency(%q<rspec>, ["~> 1.3.0"])
|
64
|
+
s.add_development_dependency(%q<webmock>, ["~> 1.3.5"])
|
65
|
+
else
|
66
|
+
s.add_dependency(%q<rest-client>, ["~> 1.6.1"])
|
67
|
+
s.add_dependency(%q<yajl-ruby>, ["~> 0.7.7"])
|
68
|
+
s.add_dependency(%q<rest-client>, ["~> 1.6.1"])
|
69
|
+
s.add_dependency(%q<yajl-ruby>, ["~> 0.7.7"])
|
70
|
+
s.add_dependency(%q<rspec>, ["~> 1.3.0"])
|
71
|
+
s.add_dependency(%q<webmock>, ["~> 1.3.5"])
|
72
|
+
end
|
73
|
+
else
|
74
|
+
s.add_dependency(%q<rest-client>, ["~> 1.6.1"])
|
75
|
+
s.add_dependency(%q<yajl-ruby>, ["~> 0.7.7"])
|
76
|
+
s.add_dependency(%q<rest-client>, ["~> 1.6.1"])
|
77
|
+
s.add_dependency(%q<yajl-ruby>, ["~> 0.7.7"])
|
78
|
+
s.add_dependency(%q<rspec>, ["~> 1.3.0"])
|
79
|
+
s.add_dependency(%q<webmock>, ["~> 1.3.5"])
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
@@ -0,0 +1,49 @@
|
|
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
|
@@ -0,0 +1,21 @@
|
|
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
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
module Board
|
2
|
+
|
3
|
+
class CandidateSearch < API::Base
|
4
|
+
|
5
|
+
DEFAULT_PER_PAGE = 10
|
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
|
24
|
+
|
25
|
+
def total_pages
|
26
|
+
(total / per_page.to_f).ceil
|
27
|
+
end
|
28
|
+
|
29
|
+
def results
|
30
|
+
response['results']
|
31
|
+
end
|
32
|
+
|
33
|
+
def total
|
34
|
+
response['total']
|
35
|
+
end
|
36
|
+
|
37
|
+
def per_page
|
38
|
+
params[:per_page] || DEFAULT_PER_PAGE
|
39
|
+
end
|
40
|
+
|
41
|
+
def page
|
42
|
+
params[:page]
|
43
|
+
end
|
44
|
+
|
45
|
+
def page=(value)
|
46
|
+
params[:page] = value
|
47
|
+
end
|
48
|
+
|
49
|
+
def valid?
|
50
|
+
response && (errors.nil? || errors.size == 0)
|
51
|
+
end
|
52
|
+
|
53
|
+
attr_reader :errors
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def clear
|
58
|
+
@response = nil
|
59
|
+
@errors = nil
|
60
|
+
end
|
61
|
+
|
62
|
+
def response
|
63
|
+
@response ||= get "/candidate_searches", params
|
64
|
+
rescue RestClient::Exception => e
|
65
|
+
@errors = decode_json(e.response)
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
data/lib/board/client.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
require 'rest_client'
|
5
|
+
require 'yajl'
|
6
|
+
|
7
|
+
require 'board/api'
|
8
|
+
|
9
|
+
module Board
|
10
|
+
|
11
|
+
autoload :CandidateSearch, 'board/candidate_search'
|
12
|
+
|
13
|
+
class Client
|
14
|
+
|
15
|
+
class << self
|
16
|
+
attr_accessor :default_url
|
17
|
+
end
|
18
|
+
self.default_url = 'https://board.recruitmilitary.com/api/v1'
|
19
|
+
|
20
|
+
def initialize(api_key, url = Client.default_url)
|
21
|
+
@api_key = api_key
|
22
|
+
@url = url
|
23
|
+
end
|
24
|
+
|
25
|
+
def candidate_invitations
|
26
|
+
@candidate_invitations ||= API::CandidateInvitations.new(@api_key, @url)
|
27
|
+
end
|
28
|
+
|
29
|
+
def users
|
30
|
+
@users ||= API::Users.new(@api_key, @url)
|
31
|
+
end
|
32
|
+
|
33
|
+
def candidate_search(params)
|
34
|
+
API::CandidateSearches.new(@api_key, @url).create(params)
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
data/lib/board-client.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'board/client'
|
@@ -0,0 +1,40 @@
|
|
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
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Board::API::CandidateSearches do
|
4
|
+
|
5
|
+
let(:client) { Board::Client.new('VALID_KEY') }
|
6
|
+
|
7
|
+
before do
|
8
|
+
stub_request(:get, "https://board.recruitmilitary.com/api/v1/candidate_searches").
|
9
|
+
with(:query => {
|
10
|
+
'user_credentials' => 'VALID_KEY',
|
11
|
+
'keywords' => 'ruby',
|
12
|
+
'page' => '1',
|
13
|
+
}).
|
14
|
+
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, "https://board.recruitmilitary.com/api/v1/candidate_searches").
|
16
|
+
with(:query => {
|
17
|
+
'user_credentials' => 'VALID_KEY',
|
18
|
+
'keywords' => 'ruby',
|
19
|
+
'page' => '2',
|
20
|
+
}).
|
21
|
+
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, "https://board.recruitmilitary.com/api/v1/candidate_searches").
|
23
|
+
with(:query => {
|
24
|
+
'user_credentials' => 'VALID_KEY',
|
25
|
+
'per_page' => '501',
|
26
|
+
'page' => '1',
|
27
|
+
}).
|
28
|
+
to_return(:body => %q{[["per_page", "must be less than or equal to 500"]]},
|
29
|
+
:status => 422)
|
30
|
+
end
|
31
|
+
|
32
|
+
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
|
+
it 'returns the correct number of results' do
|
49
|
+
search.results.size.should == 10
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'returns the correct number of total pages' do
|
53
|
+
search.total_pages.should == 2
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'iterates through all results' do
|
57
|
+
results = []
|
58
|
+
search.each_result do |result|
|
59
|
+
results << result
|
60
|
+
end
|
61
|
+
results.size.should == search.total
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
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
|
73
|
+
|
74
|
+
it 'returns a collection of errors' do
|
75
|
+
search.errors.should == [["per_page", "must be less than or equal to 500"]]
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
@@ -0,0 +1,49 @@
|
|
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
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Board::Client do
|
4
|
+
|
5
|
+
let(:client) { Board::Client.new('VALID_KEY') }
|
6
|
+
|
7
|
+
describe "when creating" do
|
8
|
+
|
9
|
+
context 'and missing an API key' do
|
10
|
+
it 'should raise an error' do
|
11
|
+
expect { Board::Client.new }.to raise_error
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context "with an API key" do
|
16
|
+
it 'should not raise an error' do
|
17
|
+
Board::Client.new('API_KEY')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
require 'board-client'
|
4
|
+
require 'spec'
|
5
|
+
require 'spec/autorun'
|
6
|
+
require 'webmock/rspec'
|
7
|
+
|
8
|
+
require 'yajl/json_gem' # required for webmock
|
9
|
+
|
10
|
+
Spec::Runner.configure do |config|
|
11
|
+
config.include WebMock
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,188 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: board-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Michael Guterl
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-04-05 00:00:00 -04:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
hash: 13
|
28
|
+
segments:
|
29
|
+
- 1
|
30
|
+
- 6
|
31
|
+
- 1
|
32
|
+
version: 1.6.1
|
33
|
+
version_requirements: *id001
|
34
|
+
name: rest-client
|
35
|
+
prerelease: false
|
36
|
+
type: :runtime
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 13
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
- 7
|
47
|
+
- 7
|
48
|
+
version: 0.7.7
|
49
|
+
version_requirements: *id002
|
50
|
+
name: yajl-ruby
|
51
|
+
prerelease: false
|
52
|
+
type: :runtime
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ~>
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 13
|
60
|
+
segments:
|
61
|
+
- 1
|
62
|
+
- 6
|
63
|
+
- 1
|
64
|
+
version: 1.6.1
|
65
|
+
version_requirements: *id003
|
66
|
+
name: rest-client
|
67
|
+
prerelease: false
|
68
|
+
type: :runtime
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
hash: 13
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
- 7
|
79
|
+
- 7
|
80
|
+
version: 0.7.7
|
81
|
+
version_requirements: *id004
|
82
|
+
name: yajl-ruby
|
83
|
+
prerelease: false
|
84
|
+
type: :runtime
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ~>
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
hash: 27
|
92
|
+
segments:
|
93
|
+
- 1
|
94
|
+
- 3
|
95
|
+
- 0
|
96
|
+
version: 1.3.0
|
97
|
+
version_requirements: *id005
|
98
|
+
name: rspec
|
99
|
+
prerelease: false
|
100
|
+
type: :development
|
101
|
+
- !ruby/object:Gem::Dependency
|
102
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
103
|
+
none: false
|
104
|
+
requirements:
|
105
|
+
- - ~>
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
hash: 17
|
108
|
+
segments:
|
109
|
+
- 1
|
110
|
+
- 3
|
111
|
+
- 5
|
112
|
+
version: 1.3.5
|
113
|
+
version_requirements: *id006
|
114
|
+
name: webmock
|
115
|
+
prerelease: false
|
116
|
+
type: :development
|
117
|
+
description: A ruby wrapper for the board platform.
|
118
|
+
email: mguterl@gmail.com
|
119
|
+
executables: []
|
120
|
+
|
121
|
+
extensions: []
|
122
|
+
|
123
|
+
extra_rdoc_files:
|
124
|
+
- LICENSE
|
125
|
+
- README.md
|
126
|
+
files:
|
127
|
+
- .document
|
128
|
+
- Gemfile
|
129
|
+
- Gemfile.lock
|
130
|
+
- LICENSE
|
131
|
+
- README.md
|
132
|
+
- Rakefile
|
133
|
+
- VERSION
|
134
|
+
- board-client.gemspec
|
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
|
+
- lib/board/candidate_search.rb
|
142
|
+
- lib/board/client.rb
|
143
|
+
- spec/board/api/candidate_invitations_spec.rb
|
144
|
+
- spec/board/api/candidate_searches_spec.rb
|
145
|
+
- spec/board/api/users_spec.rb
|
146
|
+
- spec/board/client_spec.rb
|
147
|
+
- spec/spec.opts
|
148
|
+
- spec/spec_helper.rb
|
149
|
+
has_rdoc: true
|
150
|
+
homepage: http://github.com/mguterl/board-client
|
151
|
+
licenses: []
|
152
|
+
|
153
|
+
post_install_message:
|
154
|
+
rdoc_options: []
|
155
|
+
|
156
|
+
require_paths:
|
157
|
+
- lib
|
158
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
159
|
+
none: false
|
160
|
+
requirements:
|
161
|
+
- - ">="
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
hash: 3
|
164
|
+
segments:
|
165
|
+
- 0
|
166
|
+
version: "0"
|
167
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
168
|
+
none: false
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
hash: 3
|
173
|
+
segments:
|
174
|
+
- 0
|
175
|
+
version: "0"
|
176
|
+
requirements: []
|
177
|
+
|
178
|
+
rubyforge_project:
|
179
|
+
rubygems_version: 1.5.2
|
180
|
+
signing_key:
|
181
|
+
specification_version: 3
|
182
|
+
summary: A ruby wrapper for the board platform
|
183
|
+
test_files:
|
184
|
+
- spec/board/api/candidate_invitations_spec.rb
|
185
|
+
- spec/board/api/candidate_searches_spec.rb
|
186
|
+
- spec/board/api/users_spec.rb
|
187
|
+
- spec/board/client_spec.rb
|
188
|
+
- spec/spec_helper.rb
|