Module: BooticClient

Defined in:
lib/bootic_client.rb,
lib/bootic_client/client.rb,
lib/bootic_client/entity.rb,
lib/bootic_client/errors.rb,
lib/bootic_client/version.rb,
lib/bootic_client/relation.rb,
lib/bootic_client/stubbing.rb,
lib/bootic_client/whiny_uri.rb,
lib/bootic_client/configuration.rb,
lib/bootic_client/stores/memcache.rb,
lib/bootic_client/response_handlers.rb,
lib/bootic_client/strategies/bearer.rb,
lib/bootic_client/strategies/strategy.rb,
lib/bootic_client/strategies/authorized.rb,
lib/bootic_client/strategies/basic_auth.rb,
lib/bootic_client/strategies/oauth2_strategy.rb,
lib/bootic_client/strategies/client_credentials.rb

Defined Under Namespace

Modules: EnumerableEntity, ResponseHandlers, Stores, Strategies, Stubbing Classes: AccessForbiddenError, AuthorizationError, Client, ClientError, Configuration, Entity, InvalidURLError, NotFoundError, Relation, ServerError, TransportError, UnauthorizedError, WhinyURI

Constant Summary collapse

VERSION =
"0.0.32".freeze
InvalidConfigurationError =
Class.new(StandardError)
VERY_BASIC_URL_CHECK =
/^(http|https):/.freeze
AUTH_HOST =
'https://auth.bootic.net'.freeze
API_ROOT =
'https://api.bootic.net/v1'.freeze

Class Method Summary collapse

Class Method Details

.auth_hostObject



25
26
27
# File 'lib/bootic_client.rb', line 25

def auth_host
  @auth_host || AUTH_HOST
end

.client(strategy_name, client_opts = {}, &on_new_token) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/bootic_client.rb', line 14

def client(strategy_name, client_opts = {}, &on_new_token)
  return @stubber if @stubber
  opts = client_opts.dup
  opts[:logging] = configuration.logging
  opts[:logger] = configuration.logger if configuration.logging
  opts[:cache_store] = configuration.cache_store if configuration.cache_store
  opts[:user_agent] = configuration.user_agent if configuration.user_agent
  require "bootic_client/strategies/#{strategy_name}"
  strategies.fetch(strategy_name.to_sym).new configuration, opts, &on_new_token
end

.configurationObject



33
34
35
# File 'lib/bootic_client.rb', line 33

def configuration
  @configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Yields:



29
30
31
# File 'lib/bootic_client.rb', line 29

def configure(&block)
  yield configuration
end

.strategiesObject



10
11
12
# File 'lib/bootic_client.rb', line 10

def strategies
  @strategies ||= {}
end

.stub!Object



37
38
39
40
# File 'lib/bootic_client.rb', line 37

def stub!
  require "bootic_client/stubbing"
  @stubber = Stubbing::StubRoot.new
end

.stub_chain(method_chain, opts = {}) ⇒ Object



42
43
44
# File 'lib/bootic_client.rb', line 42

def stub_chain(method_chain, opts = {})
  @stubber.stub_chain(method_chain, opts)
end

.unstub!Object



46
47
48
# File 'lib/bootic_client.rb', line 46

def unstub!
  @stubber = nil
end