board-client 0.3.0 → 0.99.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/.gitignore +4 -0
- data/.rspec +1 -0
- data/.rvmrc +47 -0
- data/Gemfile +1 -7
- data/README.md +63 -17
- data/Rakefile +4 -44
- data/board-client.gemspec +22 -66
- data/lib/board/client.rb +41 -22
- data/lib/board/client/api.rb +29 -0
- data/lib/board/client/candidates.rb +13 -0
- data/lib/board/client/organizations.rb +17 -0
- data/lib/board/client/request.rb +98 -0
- data/lib/board/client/user_organizations.rb +20 -0
- data/lib/board/client/users.rb +21 -0
- data/lib/board/client/version.rb +5 -0
- data/spec/board/client_spec.rb +27 -83
- data/spec/cassettes/candidate_exists_with_id.yml +30 -0
- data/spec/cassettes/candidate_id_does_not_exist.yml +336 -0
- data/spec/cassettes/candidate_invite_email_exists.yml +30 -0
- data/spec/cassettes/candidate_invite_when_invalid.yml +30 -0
- data/spec/cassettes/candidate_invite_when_valid.yml +32 -0
- data/spec/cassettes/list_user_organizations_with_invalid_id.yml +346 -0
- data/spec/cassettes/list_user_organizations_with_valid_id.yml +30 -0
- data/spec/cassettes/organization_add_user.yml +26 -0
- data/spec/cassettes/organization_add_user_-_organization_does_not_exist.yml +356 -0
- data/spec/cassettes/organization_add_user_-_user_does_not_exist.yml +348 -0
- data/spec/cassettes/organization_create_is_invalid.yml +30 -0
- data/spec/cassettes/organization_create_is_valid.yml +32 -0
- data/spec/cassettes/organization_exists_with_email.yml +30 -0
- data/spec/cassettes/organization_exists_with_id.yml +30 -0
- data/spec/cassettes/organization_id_does_not_exist.yml +354 -0
- data/spec/cassettes/organization_name_does_not_exist.yml +334 -0
- data/spec/cassettes/unsubscribe_email_does_not_exist.yml +340 -0
- data/spec/cassettes/unsubscribe_email_exists.yml +30 -0
- data/spec/cassettes/user_does_exist.yml +30 -0
- data/spec/cassettes/user_does_not_exist.yml +32 -0
- data/spec/cassettes/user_email_does_not_exist.yml +334 -0
- data/spec/cassettes/user_email_md5_does_not_exist.yml +334 -0
- data/spec/cassettes/user_exists_with_email.yml +30 -0
- data/spec/cassettes/user_exists_with_email_md5.yml +30 -0
- data/spec/cassettes/user_exists_with_id.yml +30 -0
- data/spec/cassettes/user_id_does_not_exist.yml +346 -0
- data/spec/cassettes/user_missing_attributes.yml +30 -0
- data/spec/integration/candidates/find_spec.rb +28 -0
- data/spec/integration/candidates/invite_spec.rb +48 -0
- data/spec/integration/organizations/add_user_spec.rb +34 -0
- data/spec/integration/organizations/create_spec.rb +38 -0
- data/spec/integration/organizations/find_spec.rb +50 -0
- data/spec/integration/users/create_spec.rb +54 -0
- data/spec/integration/users/find_spec.rb +73 -0
- data/spec/integration/users/list_organizations_spec.rb +36 -0
- data/spec/integration/users/unsubscribe_spec.rb +27 -0
- data/spec/spec_helper.rb +6 -5
- data/spec/support/integration_helpers.rb +17 -0
- data/spec/support/vcr.rb +11 -0
- metadata +144 -52
- data/Gemfile.lock +0 -22
- data/lib/board/candidate_search.rb +0 -45
- data/lib/board/request.rb +0 -78
- data/spec/board/candidate_search_spec.rb +0 -45
- data/spec/spec.opts +0 -1
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/.rvmrc
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
+
# development environment upon cd'ing into the directory
|
5
|
+
|
6
|
+
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
|
7
|
+
environment_id="ree-1.8.7-2011.03@board-client"
|
8
|
+
|
9
|
+
#
|
10
|
+
# Uncomment following line if you want options to be set only for given project.
|
11
|
+
#
|
12
|
+
# PROJECT_JRUBY_OPTS=( --1.9 )
|
13
|
+
|
14
|
+
#
|
15
|
+
# First we attempt to load the desired environment directly from the environment
|
16
|
+
# file. This is very fast and efficient compared to running through the entire
|
17
|
+
# CLI and selector. If you want feedback on which environment was used then
|
18
|
+
# insert the word 'use' after --create as this triggers verbose mode.
|
19
|
+
#
|
20
|
+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
|
21
|
+
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
22
|
+
then
|
23
|
+
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
24
|
+
|
25
|
+
if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
|
26
|
+
then
|
27
|
+
. "${rvm_path:-$HOME/.rvm}/hooks/after_use"
|
28
|
+
fi
|
29
|
+
else
|
30
|
+
# If the environment file has not yet been created, use the RVM CLI to select.
|
31
|
+
if ! rvm --create "$environment_id"
|
32
|
+
then
|
33
|
+
echo "Failed to create RVM environment '${environment_id}'."
|
34
|
+
exit 1
|
35
|
+
fi
|
36
|
+
fi
|
37
|
+
|
38
|
+
#
|
39
|
+
# If you use an RVM gemset file to install a list of gems (*.gems), you can have
|
40
|
+
# it be automatically loaded. Uncomment the following and adjust the filename if
|
41
|
+
# necessary.
|
42
|
+
#
|
43
|
+
# filename=".gems"
|
44
|
+
# if [[ -s "$filename" ]] ; then
|
45
|
+
# rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
|
46
|
+
# fi
|
47
|
+
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,30 +1,76 @@
|
|
1
|
-
#
|
1
|
+
# Board::Client
|
2
2
|
|
3
|
-
|
3
|
+
## TODO
|
4
4
|
|
5
|
-
|
5
|
+
* Organization / User update add organization to user or add user to organization
|
6
6
|
|
7
|
-
|
8
|
-
:distance => 50,
|
9
|
-
:location => "Cincinnati, OH")
|
7
|
+
## Usage
|
10
8
|
|
11
|
-
|
9
|
+
board = Board::Client.new('YOUR_API_KEY_HERE')
|
12
10
|
|
13
|
-
|
11
|
+
### Search
|
14
12
|
|
15
|
-
|
13
|
+
All methods named search return search object that support a few elements of convenience. Each search API returns a similar format and supports similar options.
|
16
14
|
|
17
|
-
|
15
|
+
search.results # current page of results
|
16
|
+
search.each_result { |result| p result } # iterate through all pages of results
|
17
|
+
search.total # total number of results
|
18
|
+
search.page # current page number
|
18
19
|
|
19
|
-
|
20
|
+
### User Search
|
20
21
|
|
21
|
-
|
22
|
+
# should this mimic candidate search with keywords?
|
23
|
+
board.users.search(:email => "foo@bar.com")
|
22
24
|
|
23
|
-
|
25
|
+
# should this just be a special method?
|
26
|
+
board.users.find(42) # by id
|
27
|
+
board.users.find(:email => "foo@bar.com")
|
28
|
+
board.users.find(:email_md5 => "asdfasdf")
|
24
29
|
|
25
|
-
|
26
|
-
|
27
|
-
|
30
|
+
### User Create
|
31
|
+
|
32
|
+
user = board.users.create(:email => "foo@bar.com",
|
33
|
+
:first_name => "Bob",
|
34
|
+
:last_name => "Smith")
|
35
|
+
|
36
|
+
user.email # => "foo@bar.com"
|
37
|
+
user.first_name # => "Bob"
|
38
|
+
user.last_name # => "Smith"
|
39
|
+
user.id # => 42
|
40
|
+
|
41
|
+
### Organization Search
|
42
|
+
|
43
|
+
board.organizations.search(:name => "Nike")
|
44
|
+
|
45
|
+
### Organization Create
|
46
|
+
|
47
|
+
organization = board.organizations.create(:name => "Nike"
|
48
|
+
:url => "http://nike.com")
|
49
|
+
|
50
|
+
organization.name # => "Nike"
|
51
|
+
organization.url # => "http://nike.com"
|
52
|
+
organization.id # => 9
|
53
|
+
|
54
|
+
### Organization Add User
|
55
|
+
|
56
|
+
board.organizations.add_user(:organization_id => organization.id, :user_id => 42)
|
57
|
+
|
58
|
+
### Candidate Search
|
59
|
+
|
60
|
+
board.candidates.search(:keywords => "ruby",
|
61
|
+
:distance => 50,
|
62
|
+
:location => "Cincinnati, OH")
|
63
|
+
|
64
|
+
### Candidate Invitations
|
65
|
+
|
66
|
+
invitation = client.candidates.invitation(:first_name => "Michael",
|
67
|
+
:last_name => "Jordan",
|
68
|
+
:email => "michael.jordan@nike.com")
|
69
|
+
|
70
|
+
invitation.url # => "https://board.recruitmilitary.com/invitations/abcdefghijklmnopqrstuvwxyz0123456789"
|
71
|
+
invitation.first_name # => "Michael"
|
72
|
+
invitation.last_name # => "Jordan"
|
73
|
+
invitation.email # => "michael.jordan@nike.com"
|
28
74
|
|
29
75
|
## Note on Patches/Pull Requests
|
30
76
|
|
@@ -38,4 +84,4 @@ iterate through all pages and yield result
|
|
38
84
|
|
39
85
|
## Copyright
|
40
86
|
|
41
|
-
Copyright (c)
|
87
|
+
Copyright (c) 2011 Michael Guterl. See LICENSE for details
|
data/Rakefile
CHANGED
@@ -1,46 +1,6 @@
|
|
1
|
-
require '
|
2
|
-
|
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.6.2"
|
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
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
35
3
|
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
RSpec::Core::RakeTask.new
|
36
6
|
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/board-client.gemspec
CHANGED
@@ -1,74 +1,30 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "board/client/version"
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
7
|
-
s.name
|
8
|
-
s.version
|
6
|
+
s.name = "board-client"
|
7
|
+
s.version = Board::Client::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Michael Guterl"]
|
10
|
+
s.email = ["mguterl@gmail.com"]
|
11
|
+
s.homepage = "http://github.com/recruitmilitary/board-client"
|
12
|
+
s.summary = %q{A ruby wrapper for the RecruitMilitary Board HTTP API}
|
13
|
+
s.description = %q{A ruby wrapper for the RecruitMilitary Board HTTP API}
|
9
14
|
|
10
|
-
s.
|
11
|
-
|
12
|
-
s.
|
13
|
-
s.
|
14
|
-
s.
|
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/candidate_search.rb",
|
30
|
-
"lib/board/client.rb",
|
31
|
-
"lib/board/request.rb",
|
32
|
-
"spec/board/candidate_search_spec.rb",
|
33
|
-
"spec/board/client_spec.rb",
|
34
|
-
"spec/spec.opts",
|
35
|
-
"spec/spec_helper.rb"
|
36
|
-
]
|
37
|
-
s.homepage = %q{http://github.com/mguterl/board-client}
|
15
|
+
s.rubyforge_project = "board-client"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
38
20
|
s.require_paths = ["lib"]
|
39
|
-
s.rubygems_version = %q{1.5.2}
|
40
|
-
s.summary = %q{A ruby wrapper for the board platform}
|
41
|
-
s.test_files = [
|
42
|
-
"spec/board/candidate_search_spec.rb",
|
43
|
-
"spec/board/client_spec.rb",
|
44
|
-
"spec/spec_helper.rb"
|
45
|
-
]
|
46
21
|
|
47
|
-
|
48
|
-
|
22
|
+
s.add_dependency 'rest-client', '~> 1.6.1'
|
23
|
+
s.add_dependency 'yajl-ruby', '~> 0.7.7'
|
24
|
+
s.add_dependency 'hashie', '~> 1.1.0'
|
49
25
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
s.add_runtime_dependency(%q<yajl-ruby>, ["~> 0.7.7"])
|
55
|
-
s.add_development_dependency(%q<rspec>, ["~> 1.3.0"])
|
56
|
-
s.add_development_dependency(%q<webmock>, ["~> 1.6.2"])
|
57
|
-
else
|
58
|
-
s.add_dependency(%q<rest-client>, ["~> 1.6.1"])
|
59
|
-
s.add_dependency(%q<yajl-ruby>, ["~> 0.7.7"])
|
60
|
-
s.add_dependency(%q<rest-client>, ["~> 1.6.1"])
|
61
|
-
s.add_dependency(%q<yajl-ruby>, ["~> 0.7.7"])
|
62
|
-
s.add_dependency(%q<rspec>, ["~> 1.3.0"])
|
63
|
-
s.add_dependency(%q<webmock>, ["~> 1.6.2"])
|
64
|
-
end
|
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.6.2"])
|
72
|
-
end
|
26
|
+
s.add_development_dependency 'rspec', '~> 2.6.0'
|
27
|
+
s.add_development_dependency 'vcr', '~> 1.11.1'
|
28
|
+
s.add_development_dependency 'webmock', '~> 1.7.4'
|
29
|
+
s.add_development_dependency 'ruby-debug'
|
73
30
|
end
|
74
|
-
|
data/lib/board/client.rb
CHANGED
@@ -1,45 +1,64 @@
|
|
1
1
|
require 'yajl'
|
2
|
+
require 'hashie/mash'
|
2
3
|
|
3
|
-
require 'board/
|
4
|
-
require 'board/
|
4
|
+
require 'board/client/version'
|
5
|
+
require 'board/client/request'
|
5
6
|
|
6
7
|
module Board
|
7
8
|
class Client
|
8
9
|
|
9
|
-
|
10
|
+
class Error < StandardError
|
11
|
+
attr_reader :response
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
+
def initialize(response)
|
14
|
+
@response = response
|
15
|
+
end
|
13
16
|
end
|
14
|
-
self.default_url = 'https://board.recruitmilitary.com/api/v1'
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
BadRequest = Class.new(Error)
|
19
|
+
Unauthorized = Class.new(Error)
|
20
|
+
Forbidden = Class.new(Error)
|
21
|
+
NotFound = Class.new(Error)
|
22
|
+
NotAcceptable = Class.new(Error)
|
23
|
+
Conflict = Class.new(Error)
|
24
|
+
UnprocessableEntity = Class.new(Error)
|
25
|
+
InternalServerError = Class.new(Error)
|
26
|
+
NotImplemented = Class.new(Error)
|
27
|
+
BadGateway = Class.new(Error)
|
28
|
+
ServiceUnavailable = Class.new(Error)
|
20
29
|
|
21
|
-
|
22
|
-
|
30
|
+
include Request
|
31
|
+
|
32
|
+
class << self
|
33
|
+
attr_accessor :default_endpoint
|
23
34
|
end
|
35
|
+
self.default_endpoint = 'https://board.recruitmilitary.com/api/v1'
|
24
36
|
|
25
|
-
def
|
26
|
-
|
37
|
+
def initialize(api_key, endpoint = Client.default_endpoint)
|
38
|
+
@api_key = api_key
|
39
|
+
@endpoint = endpoint
|
27
40
|
end
|
28
41
|
|
29
|
-
|
30
|
-
|
42
|
+
autoload :API, 'board/client/api'
|
43
|
+
autoload :Users, 'board/client/users'
|
44
|
+
autoload :Candidates, 'board/client/candidates'
|
45
|
+
autoload :Organizations, 'board/client/organizations'
|
46
|
+
autoload :UserOrganizations, 'board/client/user_organizations'
|
47
|
+
|
48
|
+
def users
|
49
|
+
Users.new(self)
|
31
50
|
end
|
32
51
|
|
33
|
-
def
|
34
|
-
|
52
|
+
def candidates
|
53
|
+
Candidates.new(self)
|
35
54
|
end
|
36
55
|
|
37
|
-
def
|
38
|
-
|
56
|
+
def organizations
|
57
|
+
Organizations.new(self)
|
39
58
|
end
|
40
59
|
|
41
|
-
def
|
42
|
-
|
60
|
+
def user_organizations
|
61
|
+
UserOrganizations.new(self)
|
43
62
|
end
|
44
63
|
|
45
64
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Board
|
2
|
+
class Client::API
|
3
|
+
|
4
|
+
def initialize(client)
|
5
|
+
@client = client
|
6
|
+
end
|
7
|
+
|
8
|
+
def post(path, attributes = {})
|
9
|
+
json = @client.post(path, attributes)
|
10
|
+
|
11
|
+
if json.is_a?(Hash)
|
12
|
+
Hashie::Mash.new(json)
|
13
|
+
else
|
14
|
+
json
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def get(path, attributes = {})
|
19
|
+
json = @client.get(path, attributes)
|
20
|
+
|
21
|
+
if json.is_a?(Array)
|
22
|
+
json.map { |item| Hashie::Mash.new(item) }
|
23
|
+
else
|
24
|
+
Hashie::Mash.new(json)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Board
|
2
|
+
class Client::Organizations < Client::API
|
3
|
+
|
4
|
+
def create(attributes)
|
5
|
+
post("/organizations", attributes)
|
6
|
+
end
|
7
|
+
|
8
|
+
def find(id)
|
9
|
+
if id.is_a?(Hash)
|
10
|
+
get("/organizations", id)
|
11
|
+
else
|
12
|
+
get("/organizations/#{id}")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|