Sha256: 1483dad867ad91eb79b3bb89f01adf83c4330b1445522507d84bf787fb908988

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

require 'yajl'
require 'hashie/mash'

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_endpoint
    end
    self.default_endpoint = 'https://board.recruitmilitary.com/api/v1'

    def initialize(api_key, endpoint = Client.default_endpoint)
      @api_key  = api_key
      @endpoint = endpoint
    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 users
      Users.new(self)
    end

    def candidates
      Candidates.new(self)
    end

    def organizations
      Organizations.new(self)
    end

    def user_organizations
      UserOrganizations.new(self)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
board-client-0.99.0 lib/board/client.rb