Class: NexaasID::Resources::Widget

Inherits:
Base
  • Object
show all
Defined in:
lib/nexaas_id/resources/widget.rb

Overview

A wrapper to Nexaas ID's widget API

API

Documentation:

Examples:

Obtaining the user's navbar URL:

client = NexaasID::Client::Identity.new(credentials)
client.widget.navbar_url

Inviting a new user to Nexaas ID (on behalf of an application):

client = NexaasID::Client::Application.new
client..create('[email protected]')

See Also:

Instance Attribute Summary

Attributes inherited from Base

#configuration

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from NexaasID::Resources::Base

Instance Method Details

Retrieves the user's navbar URL

API

Method: GET /api/v1/widgets/navbar

Documentation:


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/nexaas_id/resources/widget.rb', line 26

def navbar_url(redirect_uri = nil)
  access_token = api.token
  querystring =
    if access_token && !access_token.empty?
      { access_token: access_token }
    elsif redirect_uri
      {
        client_id: configuration.application_token,
        redirect_uri: redirect_uri
      }
    else
      nil
    end
  uri = Addressable::URI.parse(configuration.url)
  uri.path = '/api/v1/widgets/navbar'
  uri.query_values = querystring
  uri.to_s
end

#widget_url(callback = 'initWidget') ⇒ String

Retrieves the user's widget URL

API

Method: GET /api/v1/widgets/user

Documentation:


53
54
55
# File 'lib/nexaas_id/resources/widget.rb', line 53

def widget_url(callback = 'initWidget')
  %(#{configuration.url}/api/v1/widgets/user.js?access_token=#{api.token}&callback=#{callback})
end