kdonovan-trufina 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +27 -5
- data/VERSION +1 -1
- data/lib/elements.rb +1 -1
- data/lib/trufina.rb +2 -2
- data/trufina.gemspec +1 -1
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -31,7 +31,7 @@ do this by hand, a template file will be created automatically the first time yo
|
|
31
31
|
Trufina will raise a ConfigFileError until you fill out the config file with meaningful data.
|
32
32
|
|
33
33
|
|
34
|
-
==
|
34
|
+
== Examples
|
35
35
|
|
36
36
|
Once installation has been completed, using the code itself is really easy -- the most complicated step is understanding
|
37
37
|
Trufina[http://www.trufina.com]'s various flows. We'll walk through an example:
|
@@ -58,7 +58,7 @@ you'll be redirected to whatever you put as your success endpoint in +trufina.ym
|
|
58
58
|
information about the user Trufina[http://www.trufina.com] has verified.
|
59
59
|
|
60
60
|
info = Trufina.login_info_request(870)
|
61
|
-
info.data.present_and_verified # => [{:name=>[{:first=>"
|
61
|
+
info.data.present_and_verified # => [{:name=>[{:first=>"FIRSTNAME"}, {:last=>"LASTNAME"}]}] (or whatever names you entered on the staging server)
|
62
62
|
|
63
63
|
|
64
64
|
That completes the simplest use-case. Say we decide we want more information about the user, like their middle
|
@@ -90,18 +90,40 @@ data used to prepopulate the fields the user will encounter on Trufina.com (see
|
|
90
90
|
for all options). Prepopulated data will be specified as the value of a :seed key in the options hash of either
|
91
91
|
method. Example:
|
92
92
|
|
93
|
-
Trufina.login_request(4, :seed => {:name => {:first => 'Foo', :
|
93
|
+
Trufina.login_request(4, :seed => {:name => {:first => 'Foo', :last => 'Bar'}})
|
94
94
|
|
95
95
|
=== Request Data
|
96
96
|
|
97
97
|
A number of the API calls allow you to supply a list of the data you'd like returned about the user in question.
|
98
98
|
You may do this as follows:
|
99
99
|
|
100
|
-
Trufina.login_request(4, :requested => [:age, {:name => [:first, :middle, :
|
100
|
+
Trufina.login_request(4, :requested => [:age, {:name => [:first, :middle, :last]}])
|
101
101
|
|
102
102
|
or
|
103
103
|
|
104
|
-
Trufina.access_request({:pur => 4, :prt => 4}, [:age, {:name => [:first, :middle, :
|
104
|
+
Trufina.access_request({:pur => 4, :prt => 4}, [:age, {:name => [:first, :middle, :last]}])
|
105
|
+
|
106
|
+
Note that an array item creates an empty node (e.g. <age/>) unless it's a hash, in which case it creates a node named from the hash key containing and recurses into the hash value inside the node. That is to say,
|
107
|
+
|
108
|
+
:name => [:first, :middle, :last]
|
109
|
+
|
110
|
+
will generate something like:
|
111
|
+
|
112
|
+
<name>
|
113
|
+
<first/>
|
114
|
+
<middle/>
|
115
|
+
<last/>
|
116
|
+
</name>
|
117
|
+
|
118
|
+
which is exactly the format Trufina requires to indicate we want to receive the first and middle names of the specified user. Note that the gem does some additional work to hide irregularities of the Trufina API from the user (i.e. you), so the above code really renders:
|
119
|
+
|
120
|
+
<Name>
|
121
|
+
<First/>
|
122
|
+
<MiddleName/>
|
123
|
+
<Surname/>
|
124
|
+
</Name>
|
125
|
+
|
126
|
+
(meaning you don't have to remember that Trufina randomly uses Surname, and breaks their convention by using MiddleName rather than simply Middle).
|
105
127
|
|
106
128
|
|
107
129
|
== Unsupported functionality
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/lib/elements.rb
CHANGED
@@ -89,7 +89,7 @@ class Trufina
|
|
89
89
|
element :first, String, :tag => 'First', :attributes => RESPONSE_XML_ATTRIBUTES
|
90
90
|
element :middle, String, :tag => 'MiddleName', :attributes => RESPONSE_XML_ATTRIBUTES
|
91
91
|
element :middle_initial, String, :tag => 'MiddleInitial', :attributes => RESPONSE_XML_ATTRIBUTES
|
92
|
-
element :
|
92
|
+
element :last, String, :tag => 'Surname', :attributes => RESPONSE_XML_ATTRIBUTES
|
93
93
|
element :suffix, String, :tag => 'Suffix', :attributes => RESPONSE_XML_ATTRIBUTES
|
94
94
|
end
|
95
95
|
|
data/lib/trufina.rb
CHANGED
@@ -13,13 +13,13 @@ class Trufina
|
|
13
13
|
# Examples:
|
14
14
|
#
|
15
15
|
# Trufina.login_request(Time.now)
|
16
|
-
# Trufina.login_request(Time.now, :requested => [:phone], :seed => {:name => {:first => 'Foo', :
|
16
|
+
# Trufina.login_request(Time.now, :requested => [:phone], :seed => {:name => {:first => 'Foo', :last => 'Bar'}})
|
17
17
|
#
|
18
18
|
# Options:
|
19
19
|
# * requested -- Hash of requested info to be returned once the user is done with Trufina
|
20
20
|
# * seed -- Hash of seed data used to prefill the user's forms at Trufina's website
|
21
21
|
def login_request(prt, opts = {})
|
22
|
-
opts[:requested] ||= {:name => [:first, :
|
22
|
+
opts[:requested] ||= {:name => [:first, :last]}
|
23
23
|
opts[:seed]
|
24
24
|
xml = Requests::LoginRequest.new(:prt => prt, :data => opts[:requested], :seed => opts[:seed]).render
|
25
25
|
sendToTrufina(xml)
|
data/trufina.gemspec
CHANGED