Module: RPXNow
- Extended by:
- RPXNow
- Included in:
- RPXNow
- Defined in:
- lib/rpx_now.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: ApiError, ContactsCollection, ServerError, ServiceUnavailableError, UserProxy
Constant Summary collapse
- HOST =
'rpxnow.com'
- SSL_CERT =
File.join(File.dirname(__FILE__), '..', 'certs', 'ssl_cert.pem')
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(*args) ⇒ Object
- #contacts(identifier, *args) ⇒ Object (also: #get_contacts)
- #embed_code(subdomain, url, options = {}) ⇒ 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
-
#set_status(identifier, status, *args) ⇒ Object
set the users status.
-
#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 ⇒ Object
Returns the value of attribute api_key.
12 13 14 |
# File 'lib/rpx_now.rb', line 12 def api_key @api_key end |
#api_version ⇒ Object
Returns the value of attribute api_version.
13 14 15 |
# File 'lib/rpx_now.rb', line 13 def api_version @api_version end |
Instance Method Details
#all_mappings(*args) ⇒ Object
66 67 68 69 70 |
# File 'lib/rpx_now.rb', line 66 def all_mappings(*args) api_key, version, = (args) data = secure_json_post("/api/v#{version}/all_mappings", {:apiKey => api_key}.merge()) data['mappings'] end |
#contacts(identifier, *args) ⇒ Object Also known as: get_contacts
72 73 74 75 76 77 |
# File 'lib/rpx_now.rb', line 72 def contacts(identifier, *args) api_key, version, = (args) = {:apiKey => api_key, :identifier=> identifier}.merge() data = secure_json_post("/api/v#{version}/get_contacts", ) RPXNow::ContactsCollection.new(data['response']) end |
#embed_code(subdomain, url, options = {}) ⇒ Object
80 81 82 83 84 85 86 87 |
# File 'lib/rpx_now.rb', line 80 def (subdomain,url,={}) = {:width => '400', :height => '240', :language => 'en'}.merge() <<EOF <iframe src="https://#{subdomain}.#{HOST}/openid/embed?token_url=#{url}&language_preference=#{[:language]}" scrolling="no" frameBorder="no" style="width:#{[:width]}px;height:#{[:height]}px;"> </iframe> EOF end |
#map(identifier, primary_key, *args) ⇒ Object
maps an identifier to an primary-key (e.g. user.id)
45 46 47 48 49 |
# File 'lib/rpx_now.rb', line 45 def map(identifier, primary_key, *args) api_key, version, = (args) = {:identifier=>identifier,:primaryKey=>primary_key,:apiKey=>api_key}.merge secure_json_post("/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)
59 60 61 62 63 64 |
# File 'lib/rpx_now.rb', line 59 def mappings(primary_key, *args) api_key, version, = (args) = {:primaryKey=>primary_key,:apiKey=>api_key}.merge data = secure_json_post("/api/v#{version}/mappings", ) data['identifiers'] end |
#popup_code(text, subdomain, url, options = {}) ⇒ Object
89 90 91 92 93 94 95 |
# File 'lib/rpx_now.rb', line 89 def popup_code(text, subdomain, url, = {}) if [:unobtrusive] unobtrusive_popup_code(text, subdomain, url, ) else obtrusive_popup_code(text, subdomain, url, ) end end |
#set_status(identifier, status, *args) ⇒ Object
set the users status
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rpx_now.rb', line 32 def set_status(identifier, status, *args) api_key, version, = (args) = {:identifier => identifier, :status => status, :apiKey => api_key}.merge begin data = secure_json_post("/api/v#{version}/set_status", ) rescue ServerError return nil if $!.to_s=~/Data not found/ raise end end |
#unmap(identifier, primary_key, *args) ⇒ Object
un-maps an identifier to an primary-key (e.g. user.id)
52 53 54 55 56 |
# File 'lib/rpx_now.rb', line 52 def unmap(identifier, primary_key, *args) api_key, version, = (args) = {:identifier=>identifier,:primaryKey=>primary_key,:apiKey=>api_key}.merge secure_json_post("/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
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rpx_now.rb', line 18 def user_data(token, *args) api_key, version, = (args) = {:token=>token,:apiKey=>api_key}.merge begin data = secure_json_post("/api/v#{version}/auth_info", ) rescue ServerError return nil if $!.to_s=~/Data not found/ raise end if block_given? then yield(data) else read_user_data_from_response(data) end end |