Module: Force::Concerns::Base

Included in:
AbstractClient
Defined in:
lib/force/concerns/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/force/concerns/base.rb', line 4

def options
  @options
end

Instance Method Details

#initialize(options = {}) {|builder| ... } ⇒ Object

Public: Creates a new client instance

options - A hash of options to be passed in (default: {}).

:username               - The String username to use (required for password authentication).
:password               - The String password to use (required for password authentication).
:security_token         - The String security token to use (required for password authentication).

:oauth_token            - The String oauth access token to authenticate api
                          calls (required unless password
                          authentication is used).
:refresh_token          - The String refresh token to obtain fresh
                          oauth access tokens (required if oauth
                          authentication is used).
:instance_url           - The String base url for all api requests
                          (required if oauth authentication is used).

:client_id              - The oauth client id to use. Needed for both
                          password and oauth authentication
:client_secret          - The oauth client secret to use.

:host                   - The String hostname to use during
                          authentication requests (default: 'login.salesforce.com').

:api_version            - The String REST api version to use (default: '24.0')

:authentication_retries - The number of times that client
                          should attempt to reauthenticate
                          before raising an exception (default: 3).

:compress               - Set to true to have Salesforce compress the response (default: false).
:timeout                - Faraday connection request read/open timeout. (default: nil).

:proxy_uri              - Proxy URI: 'http://proxy.example.com:port' or 'http://user@pass:proxy.example.com:port'

:authentication_callback
                        - A Proc that is called with the response body after a successful authentication.

Yields:

  • (builder)


42
43
44
45
46
47
# File 'lib/force/concerns/base.rb', line 42

def initialize(options = {})        
  @options = Hash[Force.configuration.options.map { |option| [option, Force.configuration.send(option)] }]
  @options.merge!(options)

  yield builder if block_given?
end

#inspectObject



54
55
56
# File 'lib/force/concerns/base.rb', line 54

def inspect
  "#<#{self.class} @options=#{@options.inspect}>"
end

#instance_urlObject



49
50
51
52
# File 'lib/force/concerns/base.rb', line 49

def instance_url
  authenticate! unless options[:instance_url]
  options[:instance_url]
end