Module: RPXNow
- Extended by:
- RPXNow
- Included in:
- RPXNow
- Defined in:
- lib/rpx_now.rb,
lib/rpx_now/api.rb,
lib/rpx_now/user_proxy.rb,
lib/rpx_now/user_integration.rb,
lib/rpx_now/contacts_collection.rb
Defined Under Namespace
Modules: UserIntegration Classes: Api, ApiError, ContactsCollection, ServerError, ServiceUnavailableError, UserProxy
Constant Summary collapse
- VERSION =
File.read( File.join(File.dirname(__FILE__),'..','VERSION') ).strip
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#api_version ⇒ Object
Returns the value of attribute api_version.
Instance Method Summary collapse
- #all_mappings(options = {}) ⇒ Object
- #contacts(identifier, options = {}) ⇒ Object (also: #get_contacts)
-
#embed_code(subdomain, url, options = {}) ⇒ Object
iframe for rpx login options: :width, :height, :language, :flags.
- #extract_version(options) ⇒ Object
-
#map(identifier, primary_key, options = {}) ⇒ Object
maps an identifier to an primary-key (e.g. user.id).
-
#mappings(primary_key, options = {}) ⇒ Object
returns an array of identifiers which are mapped to one of your primary-keys (e.g. user.id).
-
#popup_code(text, subdomain, url, options = {}) ⇒ Object
popup window for rpx login options: :language / :flags / :unobtrusive.
-
#popup_source(subdomain, url, options = {}) ⇒ Object
javascript for popup only needed in combination with popup_code(x,y,z, :unobtrusive => true).
-
#set_status(identifier, status, options = {}) ⇒ Object
set the users status.
-
#unmap(identifier, primary_key, options = {}) ⇒ Object
un-maps an identifier to an primary-key (e.g. user.id).
-
#user_data(token, options = {}) ⇒ Object
retrieve the users data - cleaned Hash - complete/unclean response when block was given user_data{|response| …; return hash } - nil when token was invalid / data was not found.
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
13 14 15 |
# File 'lib/rpx_now.rb', line 13 def api_key @api_key end |
#api_version ⇒ Object
Returns the value of attribute api_version.
14 15 16 |
# File 'lib/rpx_now.rb', line 14 def api_version @api_version end |
Instance Method Details
#all_mappings(options = {}) ⇒ Object
57 58 59 |
# File 'lib/rpx_now.rb', line 57 def all_mappings(={}) Api.call("all_mappings", )['mappings'] end |
#contacts(identifier, options = {}) ⇒ Object Also known as: get_contacts
61 62 63 64 |
# File 'lib/rpx_now.rb', line 61 def contacts(identifier, ={}) data = Api.call("get_contacts", .merge(:identifier => identifier)) RPXNow::ContactsCollection.new(data['response']) end |
#embed_code(subdomain, url, options = {}) ⇒ Object
iframe for rpx login options: :width, :height, :language, :flags
69 70 71 72 73 74 75 76 |
# File 'lib/rpx_now.rb', line 69 def (subdomain, url, ={}) = {:width => '400', :height => '240'}.merge() <<-EOF <iframe src="#{Api.host(subdomain)}/openid/embed?#{(url, )}" scrolling="no" frameBorder="no" style="width:#{[:width]}px;height:#{[:height]}px;"> </iframe> EOF end |
#extract_version(options) ⇒ Object
106 107 108 |
# File 'lib/rpx_now.rb', line 106 def extract_version() [:api_version] || api_version end |
#map(identifier, primary_key, options = {}) ⇒ Object
maps an identifier to an primary-key (e.g. user.id)
43 44 45 |
# File 'lib/rpx_now.rb', line 43 def map(identifier, primary_key, ={}) Api.call("map", .merge(:identifier => identifier, :primaryKey => primary_key)) end |
#mappings(primary_key, options = {}) ⇒ Object
returns an array of identifiers which are mapped to one of your primary-keys (e.g. user.id)
53 54 55 |
# File 'lib/rpx_now.rb', line 53 def mappings(primary_key, ={}) Api.call("mappings", .merge(:primaryKey => primary_key))['identifiers'] end |
#popup_code(text, subdomain, url, options = {}) ⇒ Object
popup window for rpx login options: :language / :flags / :unobtrusive
80 81 82 83 84 85 86 |
# File 'lib/rpx_now.rb', line 80 def popup_code(text, subdomain, url, = {}) if [:unobtrusive] unobtrusive_popup_code(text, subdomain, url, ) else obtrusive_popup_code(text, subdomain, url, ) end end |
#popup_source(subdomain, url, options = {}) ⇒ Object
javascript for popup only needed in combination with popup_code(x,y,z, :unobtrusive => true)
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/rpx_now.rb', line 90 def popup_source(subdomain, url, ={}) <<-EOF <script src="#{Api.host}/openid/v#{extract_version()}/widget" type="text/javascript"></script> <script type="text/javascript"> //<![CDATA[ RPXNOW.token_url = '#{url}'; RPXNOW.realm = '#{subdomain}'; RPXNOW.overlay = true; #{ "RPXNOW.language_preference = '#{[:language]}';" if [:language] } #{ "RPXNOW.default_provider = '#{[:default_provider]}';" if [:default_provider] } #{ "RPXNOW.flags = '#{[:flags]}';" if [:flags] } //]]> </script> EOF end |
#set_status(identifier, status, options = {}) ⇒ Object
set the users status
34 35 36 37 38 39 40 |
# File 'lib/rpx_now.rb', line 34 def set_status(identifier, status, ={}) = .merge(:identifier => identifier, :status => status) data = Api.call("set_status", ) rescue ServerError return nil if $!.to_s=~/Data not found/ raise end |
#unmap(identifier, primary_key, options = {}) ⇒ Object
un-maps an identifier to an primary-key (e.g. user.id)
48 49 50 |
# File 'lib/rpx_now.rb', line 48 def unmap(identifier, primary_key, ={}) Api.call("unmap", .merge(:identifier => identifier, :primaryKey => primary_key)) end |
#user_data(token, options = {}) ⇒ Object
retrieve the users data
-
cleaned Hash
-
complete/unclean response when block was given user_data{|response| …; return hash }
-
nil when token was invalid / data was not found
23 24 25 26 27 28 29 30 31 |
# File 'lib/rpx_now.rb', line 23 def user_data(token, ={}) begin data = Api.call("auth_info", .merge(:token => token)) if block_given? then yield(data) else parse_user_data(data) end rescue ServerError return nil if $!.to_s=~/Data not found/ raise end end |