Module: RPXNow
Defined Under Namespace
Classes: ServerError
Instance Attribute Summary collapse
-
#api_key ⇒ Object
writeonly
Sets the attribute api_key.
-
#api_version ⇒ Object
Returns the value of attribute api_version.
Instance Method Summary collapse
- #embed_code(subdomain, url) ⇒ Object
-
#map(identifier, primary_key, *args) ⇒ Object
maps an identifier to an primary-key (e.g. user.id).
-
#mappings(primary_key, *args) ⇒ 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
-
#unmap(identifier, primary_key, *args) ⇒ Object
un-maps an identifier to an primary-key (e.g. user.id).
-
#user_data(token, *args) ⇒ Object
retrieve the users data, or return nil when nothing could be read/token was invalid or data was not found.
Instance Attribute Details
#api_key=(value) ⇒ Object (writeonly)
Sets the attribute api_key
6 7 8 |
# File 'lib/rpx_now.rb', line 6 def api_key=(value) @api_key = value end |
#api_version ⇒ Object
Returns the value of attribute api_version.
7 8 9 |
# File 'lib/rpx_now.rb', line 7 def api_version @api_version end |
Instance Method Details
#embed_code(subdomain, url) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/rpx_now.rb', line 47 def (subdomain,url) <<EOF <iframe src="https://#{subdomain}.rpxnow.com/openid/embed?token_url=#{url}" scrolling="no" frameBorder="no" style="width:400px;height:240px;"> </iframe> EOF end |
#map(identifier, primary_key, *args) ⇒ Object
maps an identifier to an primary-key (e.g. user.id)
26 27 28 29 30 |
# File 'lib/rpx_now.rb', line 26 def map(identifier, primary_key, *args) api_key, version, = (args) = {:identifier=>identifier,:primaryKey=>primary_key,:apiKey=>api_key}.merge secure_json_post("https://rpxnow.com/api/v#{version}/map", ) end |
#mappings(primary_key, *args) ⇒ Object
returns an array of identifiers which are mapped to one of your primary-keys (e.g. user.id)
40 41 42 43 44 45 |
# File 'lib/rpx_now.rb', line 40 def mappings(primary_key, *args) api_key, version, = (args) = {:primaryKey=>primary_key,:apiKey=>api_key}.merge data = secure_json_post("https://rpxnow.com/api/v#{version}/mappings", ) data['identifiers'] end |
#popup_code(text, subdomain, url, options = {}) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/rpx_now.rb', line 55 def popup_code(text, subdomain, url, = {}) if [:unobtrusive] unobtrusive_popup_code(text, subdomain, url, ) else obtrusive_popup_code(text, subdomain, url, ) end end |
#unmap(identifier, primary_key, *args) ⇒ Object
un-maps an identifier to an primary-key (e.g. user.id)
33 34 35 36 37 |
# File 'lib/rpx_now.rb', line 33 def unmap(identifier, primary_key, *args) api_key, version, = (args) = {:identifier=>identifier,:primaryKey=>primary_key,:apiKey=>api_key}.merge secure_json_post("https://rpxnow.com/api/v#{version}/unmap", ) end |
#user_data(token, *args) ⇒ Object
retrieve the users data, or return nil when nothing could be read/token was invalid or data was not found
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rpx_now.rb', line 12 def user_data(token, *args) api_key, version, = (args) = {:token=>token,:apiKey=>api_key}.merge begin data = secure_json_post("https://rpxnow.com/api/v#{version}/auth_info", ) rescue ServerError return nil if $!.to_s =~ /token/ or $!.to_s=~/Data not found/ raise end if block_given? then yield(data) else read_user_data_from_response(data) end end |