Class: FellowshipOneAPI::Client
- Inherits:
-
Object
- Object
- FellowshipOneAPI::Client
- Defined in:
- lib/f1api/client.rb
Overview
The Fellowship One API client class
Takes an HTTP request and passes it through the OAuth library which added the approperiate headers and querystring parameters.
Examples
- Simple client using OAuth and default YAML config values
-
client = FellowshipOneAPI::Client.new
client.authorize!
client.request(:get, ‘/v1/People/123.xml’)
- Using credentials based authentication (2nd party)
-
client = FellowshipOneAPI::Client.new(=> :credentials)
client.authorize!(“username”, “password”)
client.request(:get, ‘/v1/People/123.xml’)
- Authenticating against weblink passing credentials
-
client = FellowshipOneAPI::Client.new(=> :credentials, :auth_against => :weblink)
client.authorize(“weblinkuser”, “weblinkpassword”)
client.request(:get, ‘/v1/People/123.xml’)
- Loading a client with an existing access token
-
client = FellowshipOneAPI::Client.new(=> “123456”, :oauth_token_secret => “987654”)
client.request(:get, ‘/v1/People/123.xml’)
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Client
constructor
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. -
#request(*args) ⇒ Object
Passes through the request to the OAuth library to be signed and set out HTTP.
Constructor Details
#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 |
Instance Method Details
#request(*args) ⇒ Object
Passes through the request to the OAuth library to be signed and set out HTTP
58 59 60 |
# File 'lib/f1api/client.rb', line 58 def request(*args) @oauth_access_token.request(*args) end |