Sha256: 7dd3f4b5508dece0504585d73643a2ec01b627297de6f3be973b4b5233140bbc

Contents?: true

Size: 813 Bytes

Versions: 1

Compression:

Stored size: 813 Bytes

Contents

# Nexaas ID Client for resources not owned by an Identity
#
# [API]
#   Documentation:
#
# @example Inviting a new user:
#   client = NexaasID::Client::Application.new
#   client.sign_up.create(invited: 'john.doe@example.com')
#
class NexaasID::Client::Application

  def initialize
    @tokens = {}
  end

  # Provides a SignUp resource.
  # @return [NexaasID::Resources::SignUp] the signup resource.
  def sign_up
    NexaasID::Resources::SignUp.new(token(:invite))
  end

  private

  attr_reader :tokens, :credentials

  def client
    @client ||= NexaasID::Client::OAuth.build
  end

  def token(scope = nil)
    token = tokens[scope]
    return token unless token.nil? || token.expired?
    tokens[scope] = NexaasID::Client::ExceptionWrapper.new(client.client_credentials.get_token(scope: scope))
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nexaas_id-client-0.5.0 lib/nexaas_id/client/application.rb