Method: FellowshipOneAPI::Client#initialize

Defined in:
lib/f1api/client.rb

#initialize(args = {}) ⇒ Client

Creates a new instance of a client used to connect with the Fellowship One API The client can be configured with the following symbols:

:auth_type
  • Can be :credentials or :oauth (:oauth is the default)

:auth_against
  • Can be :portal or :weblink (:portal is the default)

:oauth_token
  • The access token

:oauth_token_secret
  • The access token secret



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/f1api/client.rb', line 38

def initialize(args = {})
  args[:auth_type] ||= Configuration.authentication_type.to_sym
  if args[:auth_type] == :credentials
    extend OAuth::CredentialsAuthentication
  else
    extend OAuth::OAuthAuthentication
  end
  
  if(args[:auth_against])
    load_consumer_config args[:auth_against]
  else
    load_consumer_config
  end
  
  if(args[:oauth_token] and args[:oauth_token_secret])
    @oauth_access_token = ::OAuth::AccessToken.from_hash(@oauth_consumer, args[:oauth_token], args[:oauth_token_secret])
  end
end