Class: Bullhorn::Rest::Client

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Entities::Base

#define_methods, #entity

Methods included from Authentication

#auth_conn, #authenticate, #authenticated?, #authorize, #login, #retrieve_tokens

Constructor Details

#initialize(options = {}) ⇒ Client

Initializes a new Bullhorn REST Client



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/bullhorn/rest/client.rb', line 48

def initialize(options = {})

  @username = options[:username]
  @password = options[:password]
  @client_id = options[:client_id]
  @client_secret = options[:client_secret]
  @auth_code = options[:auth_code]
  @rest_url = options[:rest_url]
  @rest_token = options[:rest_token]
  @access_token = options[:access_token]
  @refresh_token = options[:refresh_token]

end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



45
46
47
# File 'lib/bullhorn/rest/client.rb', line 45

def access_token
  @access_token
end

#auth_codeObject (readonly)

Returns the value of attribute auth_code.



45
46
47
# File 'lib/bullhorn/rest/client.rb', line 45

def auth_code
  @auth_code
end

#client_idObject (readonly)

Returns the value of attribute client_id.



45
46
47
# File 'lib/bullhorn/rest/client.rb', line 45

def client_id
  @client_id
end

#client_secretObject (readonly)

Returns the value of attribute client_secret.



45
46
47
# File 'lib/bullhorn/rest/client.rb', line 45

def client_secret
  @client_secret
end

#passwordObject (readonly)

Returns the value of attribute password.



45
46
47
# File 'lib/bullhorn/rest/client.rb', line 45

def password
  @password
end

#refresh_tokenObject (readonly)

Returns the value of attribute refresh_token.



45
46
47
# File 'lib/bullhorn/rest/client.rb', line 45

def refresh_token
  @refresh_token
end

#rest_tokenObject (readonly)

Returns the value of attribute rest_token.



45
46
47
# File 'lib/bullhorn/rest/client.rb', line 45

def rest_token
  @rest_token
end

#rest_urlObject (readonly)

Returns the value of attribute rest_url.



45
46
47
# File 'lib/bullhorn/rest/client.rb', line 45

def rest_url
  @rest_url
end

#usernameObject (readonly)

Returns the value of attribute username.



45
46
47
# File 'lib/bullhorn/rest/client.rb', line 45

def username
  @username
end

Instance Method Details

#connObject



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/bullhorn/rest/client.rb', line 62

def conn
  if !authenticated?
    authenticate
  end

  params = {
    BhRestToken: rest_token
  }

  @conn ||= Faraday.new(url: rest_url, params: params)
end