lib/board/client.rb in board-client-0.3.0 vs lib/board/client.rb in board-client-0.99.0
- old
+ new
@@ -1,46 +1,65 @@
require 'yajl'
+require 'hashie/mash'
-require 'board/request'
-require 'board/candidate_search'
+require 'board/client/version'
+require 'board/client/request'
module Board
class Client
+ class Error < StandardError
+ attr_reader :response
+
+ def initialize(response)
+ @response = response
+ end
+ end
+
+ BadRequest = Class.new(Error)
+ Unauthorized = Class.new(Error)
+ Forbidden = Class.new(Error)
+ NotFound = Class.new(Error)
+ NotAcceptable = Class.new(Error)
+ Conflict = Class.new(Error)
+ UnprocessableEntity = Class.new(Error)
+ InternalServerError = Class.new(Error)
+ NotImplemented = Class.new(Error)
+ BadGateway = Class.new(Error)
+ ServiceUnavailable = Class.new(Error)
+
include Request
class << self
- attr_accessor :default_url
+ attr_accessor :default_endpoint
end
- self.default_url = 'https://board.recruitmilitary.com/api/v1'
+ self.default_endpoint = 'https://board.recruitmilitary.com/api/v1'
- def initialize(api_key, url = Client.default_url)
- @api_key = api_key
- @url = url
+ def initialize(api_key, endpoint = Client.default_endpoint)
+ @api_key = api_key
+ @endpoint = endpoint
end
- def candidate_searches(params)
- get "/candidate_searches", params
- end
+ autoload :API, 'board/client/api'
+ autoload :Users, 'board/client/users'
+ autoload :Candidates, 'board/client/candidates'
+ autoload :Organizations, 'board/client/organizations'
+ autoload :UserOrganizations, 'board/client/user_organizations'
- def find_user(params)
- get "/users", params
+ def users
+ Users.new(self)
end
- def mark_user_invalid(params)
- get "/users/invalid", params
+ def candidates
+ Candidates.new(self)
end
- def unsubscribe(params)
- get "/users/unsubscribe", params
+ def organizations
+ Organizations.new(self)
end
- def create_candidate_invitation(params)
- post "/candidate_invitations", params
- end
-
- def find_candidate(candidate_id)
- get "/candidates/#{candidate_id}", {}
+ def user_organizations
+ UserOrganizations.new(self)
end
end
end