Class: SparkApi::Client

Inherits:
Object
  • Object
show all
Includes:
Authentication, SparkApi::Configuration::OAuth2Configurable, Connection, Request
Defined in:
lib/spark_api/client.rb

Overview

API Client

Main class to setup and run requests on the API. A default client is accessible globally as SparkApi::client if the global configuration has been set as well. Otherwise, this class may be instanciated separately with the configuration information.

Constant Summary

Constants included from Connection

SparkApi::Connection::ACCEPT_ENCODING, SparkApi::Connection::COMPRESS_ACCEPT_ENCODING, SparkApi::Connection::HTTPS_SCHEME, SparkApi::Connection::HTTP_SCHEME, SparkApi::Connection::MIME_JSON, SparkApi::Connection::MIME_RESO, SparkApi::Connection::REG_HTTP, SparkApi::Connection::REG_HTTPS, SparkApi::Connection::X_REQUEST_ID_CHAIN

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SparkApi::Configuration::OAuth2Configurable

#convert_to_oauth2?, #grant_uri, #oauth2_enabled?, #oauthify!

Methods included from Request

#delete, #get, #post, #put

Methods included from Authentication

#authenticate, #authenticated?, #logout, #session, #session=

Methods included from Connection

#connection, #headers, #reso_headers, #spark_headers

Constructor Details

#initialize(options = {}) ⇒ Client

Constructor bootstraps the client with configuration and authorization class. options - see Configuration::VALID_OPTION_KEYS



19
20
21
22
23
24
25
26
# File 'lib/spark_api/client.rb', line 19

def initialize(options={})
  options = SparkApi.options.merge(options)
  Configuration::VALID_OPTION_KEYS.each do |key|
    send("#{key}=", options[key])
  end
  # Instanciate the authenication class passed in.
  @authenticator = authentication_mode.send("new", self)
end

Instance Attribute Details

#authenticatorObject

Returns the value of attribute authenticator.



14
15
16
# File 'lib/spark_api/client.rb', line 14

def authenticator
  @authenticator
end