Module: RPXNow

Extended by:
RPXNow
Included in:
RPXNow
Defined in:
lib/rpx_now.rb

Defined Under Namespace

Classes: ServerError

Instance Attribute Summary collapse

Instance Method Summary collapse

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_versionObject

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 embed_code(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, options = extract_key_version_and_options!(args)
  options = {:identifier=>identifier,:primaryKey=>primary_key,:apiKey=>api_key}.merge options
  secure_json_post("https://rpxnow.com/api/v#{version}/map", options)
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, options = extract_key_version_and_options!(args)
  options = {:primaryKey=>primary_key,:apiKey=>api_key}.merge options
  data = secure_json_post("https://rpxnow.com/api/v#{version}/mappings", options)
  data['identifiers']
end


55
56
57
58
59
60
61
# File 'lib/rpx_now.rb', line 55

def popup_code(text, subdomain, url, options = {})
  if options[:unobtrusive]
    unobtrusive_popup_code(text, subdomain, url, options)
  else
    obtrusive_popup_code(text, subdomain, url, options)
  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, options = extract_key_version_and_options!(args)
  options = {:identifier=>identifier,:primaryKey=>primary_key,:apiKey=>api_key}.merge options
  secure_json_post("https://rpxnow.com/api/v#{version}/unmap", options)
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, options = extract_key_version_and_options!(args)
  options = {:token=>token,:apiKey=>api_key}.merge options

  begin
    data = secure_json_post("https://rpxnow.com/api/v#{version}/auth_info", options)
  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