Class: Trufina
- Inherits:
-
Object
- Object
- Trufina
- Defined in:
- lib/trufina.rb,
lib/config.rb,
lib/elements.rb,
lib/requests.rb,
lib/responses.rb,
lib/exceptions.rb
Overview
This file defines all Trufina Exceptions
Defined Under Namespace
Modules: AllowCreationFromHash, Elements, Exceptions, Requests, Responses Classes: Config, Response
Class Method Summary collapse
-
.access_request(auth = {}, data = {}) ⇒ Object
Given either an auth hash containing a PUR and a PRT (e.g. from an InfoResponse or LoginInfoResponse) or a suitable Trufina::*Response object directly (i.e. we can just pass the results of a Trufina.login_info_request directly for auth), as well as a data hash containing any data fields we wish to request about the specified user, sends a request for data off to Trufina.
-
.handle_access_notification(raw_xml) ⇒ Object
This should be exposed to the internet to receive Trufina’s postback after a user follows the login_url and completes a profile.
-
.info_request(tnid) ⇒ Object
Given a TNID, send info_request.
-
.login_info_request(tlid) ⇒ Object
Given a TLID, send login_info_request.
-
.login_request(prt, opts = {}) ⇒ Object
Creates and sends a login request for the specified PRT.
-
.login_url(prt, opts = {}) ⇒ Object
Given a PRT, send the login request an return the redirect URL.
-
.schema ⇒ Object
Retreive Trufina’s XSD Schema.
Class Method Details
.access_request(auth = {}, data = {}) ⇒ Object
Given either an auth hash containing a PUR and a PRT (e.g. from an InfoResponse or LoginInfoResponse) or a suitable Trufina::*Response object directly (i.e. we can just pass the results of a Trufina.login_info_request directly for auth), as well as a data hash containing any data fields we wish to request about the specified user, sends a request for data off to Trufina. Trufina will respond immediately with a status of “pending” for the newly requested information, will notify the user via email that we’re requesting new info, and finally will notify us via an AccessNotification if/when the user grants us access to the additional data.
75 76 77 78 79 |
# File 'lib/trufina.rb', line 75 def access_request(auth = {}, data = {}) auth = {:pur => auth.pur, :prt => auth.prt} unless auth.is_a?(Hash) xml = Requests::AccessRequest.new( auth.merge(:data => data) ).render sendToTrufina(xml) end |
.handle_access_notification(raw_xml) ⇒ Object
This should be exposed to the internet to receive Trufina’s postback after a user follows the login_url and completes a profile
Receives the access notification, and automatically sends a request for the actual information.
50 51 52 |
# File 'lib/trufina.rb', line 50 def handle_access_notification(raw_xml) info_request( parseFromTrufina(raw_xml).tnid ) end |
.info_request(tnid) ⇒ Object
Given a TNID, send info_request
55 56 57 58 |
# File 'lib/trufina.rb', line 55 def info_request(tnid) xml = Requests::InfoRequest.new(:tnid => tnid).render sendToTrufina(xml) end |
.login_info_request(tlid) ⇒ Object
Given a TLID, send login_info_request
61 62 63 64 |
# File 'lib/trufina.rb', line 61 def login_info_request(tlid) xml = Requests::LoginInfoRequest.new(:tlid => tlid).render sendToTrufina(xml) end |
.login_request(prt, opts = {}) ⇒ Object
Creates and sends a login request for the specified PRT
Examples:
Trufina.login_request(Time.now)
Trufina.login_request(Time.now, :requested => [:phone], :seed => {:name => {:first => 'Foo', :last => 'Bar'}})
Options:
* requested -- Hash of requested info to be returned once the user is done with Trufina
* seed -- Hash of seed data used to prefill the user's forms at Trufina's website
21 22 23 24 25 |
# File 'lib/trufina.rb', line 21 def login_request(prt, opts = {}) opts[:requested] ||= {:name => [:first, :last]} xml = Requests::LoginRequest.new(:prt => prt, :data => opts[:requested], :seed => remove_empties_from_hash(opts[:seed] || [])).render sendToTrufina(xml) end |
.login_url(prt, opts = {}) ⇒ Object
Given a PRT, send the login request an return the redirect URL
Sends login request to get a PLID from Trufina, then uses that to build a redirect URL specific to this user.
Once user completes filling out their information and makes it available to us, Trufina will ping us with an access_notification to let us know it’s there and we should ask for it.
Options:
* demo -- Boolean value. If true, and Trufina::Config.staging? is true, returns demo URL
* requested -- Hash of requested info to be returned once the user is done with Trufina
* seed -- Hash of seed data used to prefill the user's forms at Trufina's website
40 41 42 43 |
# File 'lib/trufina.rb', line 40 def login_url(prt, opts = {}) plid = login_request(prt, :requested => opts.delete(:requested), :seed => opts.delete(:seed)).plid login_url_from_plid( plid, opts.delete(:demo) ) end |
.schema ⇒ Object
Retreive Trufina’s XSD Schema
82 83 84 |
# File 'lib/trufina.rb', line 82 def schema @@schema ||= XML::Schema.from_string(open("http://www.trufina.com/api/truapi.xsd").read) end |