Module: Userbin

Defined in:
lib/userbin/utils.rb,
lib/userbin.rb,
lib/userbin/jwt.rb,
lib/userbin/client.rb,
lib/userbin/request.rb,
lib/userbin/version.rb,
lib/userbin/models/user.rb,
lib/userbin/token_store.rb,
lib/userbin/models/event.rb,
lib/userbin/configuration.rb,
lib/userbin/session_store.rb,
lib/userbin/session_token.rb,
lib/userbin/support/rails.rb,
lib/userbin/models/account.rb,
lib/userbin/models/context.rb,
lib/userbin/models/pairing.rb,
lib/userbin/models/session.rb,
lib/userbin/models/challenge.rb,
lib/userbin/models/monitoring.rb,
lib/userbin/models/backup_codes.rb,
lib/userbin/support/cookie_store.rb,
lib/userbin/models/trusted_device.rb,
lib/userbin/models/model.rb

Overview

TODO: scope Userbin::Utils

Defined Under Namespace

Modules: CookieStore, Request, UserbinClient Classes: Account, ApiError, BackupCodes, BadRequestError, Challenge, ChallengeRequiredError, Client, Config, Configuration, ConfigurationError, Context, Error, Event, ForbiddenError, InvalidParametersError, JWT, Location, Model, Monitoring, NotFoundError, Pairing, RequestError, SecurityError, Session, SessionStore, SessionToken, TokenStore, TrustedDevice, UnauthorizedError, User, UserAgent, UserUnauthorizedError

Constant Summary collapse

API =
Userbin.setup_api
VERSION =
"1.7.1"

Class Method Summary collapse

Class Method Details

.api_secret=(api_secret) ⇒ Object



17
18
19
# File 'lib/userbin/configuration.rb', line 17

def api_secret=(api_secret)
  config.api_secret = api_secret
end

.configObject



13
14
15
# File 'lib/userbin/configuration.rb', line 13

def config
  @configuration ||= Userbin::Configuration.new
end

.configure(config_hash = nil) {|config| ... } ⇒ Object

Yields:



3
4
5
6
7
8
9
10
11
# File 'lib/userbin/configuration.rb', line 3

def configure(config_hash=nil)
  if config_hash
    config_hash.each do |k,v|
      config.send("#{k}=", v)
    end
  end

  yield(config) if block_given?
end

.setup_api(api_secret = nil) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/userbin/utils.rb', line 5

def setup_api(api_secret = nil)
  api_endpoint = ENV.fetch('USERBIN_API_ENDPOINT') {
    "https://api.userbin.com/v1"
  }

  Her::API.setup url: api_endpoint do |c|
    c.use Userbin::Request::Middleware::BasicAuth, api_secret
    c.use Userbin::Request::Middleware::RequestErrorHandler
    c.use Userbin::Request::Middleware::EnvironmentHeaders
    c.use Userbin::Request::Middleware::ContextHeaders
    c.use Userbin::Request::Middleware::SessionToken
    c.use FaradayMiddleware::EncodeJson
    c.use Userbin::Request::Middleware::JSONParser
    c.use Faraday::Adapter::NetHttp
  end
end