lenddo 1.2.0 → 2.0.0
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.
- checksums.yaml +4 -4
- data/README.md +100 -26
- data/lib/lenddo/network_service/self.rb +4 -8
- data/lib/lenddo/response.rb +19 -0
- data/lib/lenddo/score_service/self.rb +4 -8
- data/lib/lenddo/service_client.rb +6 -5
- data/lib/lenddo/version.rb +2 -2
- data/lib/lenddo/white_label_client.rb +4 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 603cfccd052d8658a46e83938799ae942fa48980
|
4
|
+
data.tar.gz: 71c60182b2cc54af3c10583a61dbf9caadad69b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8dc3ba9ee5422458f5beb11f76c87f77779015433d3611c43d5a9933991d87f59a0606347f00acf01b6cefd19e71504f5c9d342a128e9f6271b401b2477501d5
|
7
|
+
data.tar.gz: 1a696ba8287a6a8e8c1f54aa9faa26a8c07c2431f6ea94c7be324a6075294254d1d44ee8a586d4c4a83fcbc4cb0dca1e0ed62895525e25be9aac97a510ae043d
|
data/README.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# ruby-lenddo
|
2
2
|
|
3
3
|
ruby-lenddo allow you to contact Lenddo's REST based services.
|
4
|
+
|
5
|
+
Note: 2.0 is not compatible with 1.X.X version for more info click [here](https://github.com/Lenddo/ruby-lenddo/wiki/Breaking-changes-with-2.0)
|
6
|
+
|
4
7
|
## Installation
|
5
8
|
|
6
9
|
Add this line to your application's Gemfile:
|
@@ -40,42 +43,53 @@ The `ServiceClient` allows the client to send extra information or retrieve the
|
|
40
43
|
|
41
44
|
To retrieve the score you'll need the application ID and the partner script ID that you used to create the application.
|
42
45
|
|
43
|
-
|
46
|
+
Usage:
|
47
|
+
|
48
|
+
require 'lenddo/service_client'
|
44
49
|
|
45
|
-
|
50
|
+
Lenddo::ServiceClient.application_score(@application_id, @partnerscript_id)
|
46
51
|
|
47
52
|
### Get Multiple scores
|
48
53
|
|
49
54
|
Return an array of LenddoScore records for the supplied application id using models specifically tuned to the applicant pool of the partner associated with the current API user. LenddoScore is a measure of the expected creditworthiness of a Lenddo user. It ranges is from 0 (the highest risk) to 1000 (the lowest risk). Lenddo's scoring algorithms consider over 300 features per user when generating a score. These features are calculated from Lenddo's proprietary social graph as well as from any data specifically shared by the partner. In the event that a score cannot be correctly calculated, the LenddoScore will be returned as -1 along with an array of flag codes.
|
50
55
|
|
51
|
-
|
56
|
+
Usage:
|
57
|
+
|
58
|
+
require 'lenddo/service_client'
|
52
59
|
|
53
|
-
|
60
|
+
Lenddo::ServiceClient.application_multiple_scores(@application_id, @partnerscript_id)
|
54
61
|
|
55
62
|
### Get a Verification
|
56
63
|
|
57
64
|
To retrieve the verification you'll need the application ID and the partner script ID that you used to create the application.
|
58
65
|
|
59
|
-
|
66
|
+
Usage:
|
67
|
+
|
68
|
+
require 'lenddo/service_client'
|
60
69
|
|
61
|
-
|
70
|
+
Lenddo::ServiceClient.application_verification(@application_id, @partnerscript_id)
|
62
71
|
|
63
72
|
### Get an Application Decision
|
64
73
|
|
65
74
|
To retrieve the decision you'll need the application ID and the partner script ID that you used to create the application.
|
66
75
|
|
67
|
-
|
76
|
+
Usage:
|
77
|
+
|
78
|
+
require 'lenddo/service_client'
|
68
79
|
|
69
|
-
|
80
|
+
Lenddo::ServiceClient.application_decision(@application_id, @partnerscript_id)
|
70
81
|
|
71
82
|
### Get MobileData
|
72
83
|
|
73
84
|
If you want to retrieve the mobile data stream from your partner script ID you can use this method.
|
74
85
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
86
|
+
Usage:
|
87
|
+
|
88
|
+
require 'lenddo/service_client'
|
89
|
+
|
90
|
+
Lenddo::ServiceClient.mobile_data(@partnerscript_id)
|
91
|
+
|
92
|
+
|
79
93
|
### Send Extra Application Data
|
80
94
|
|
81
95
|
If you're sending extra information with your application you can use this method to submit it. Extra Application Data may be used to enhance the model performance based on data you may already have about a user.
|
@@ -109,20 +123,29 @@ PartnerToken has the following arguments:
|
|
109
123
|
|
110
124
|
3. **OAuth key** - this is the key returned by OAuth for interacting with the token.
|
111
125
|
|
112
|
-
|
126
|
+
Note: The key and secret are not your application key and secret. They're the values which are returned after a user successfully authenticates with the social network's OAuth.
|
113
127
|
OAuth secret - optional, leave null if not applicable. Some OAuth providers may return a secret when this is returned Lenddo will require the secret to using the token.
|
114
128
|
|
115
129
|
4. **token data** - This is the raw token as it was received from the provider in an Hash format. This may include a **extra_data** key.
|
116
130
|
|
117
|
-
|
131
|
+
Usage:
|
132
|
+
|
133
|
+
require 'lenddo/white_label_client'
|
134
|
+
|
135
|
+
application_id = "GENERATED_UNIQUE_ID"
|
136
|
+
oauth_key = "USER_ACCESS_TOKEN"
|
137
|
+
|
138
|
+
response = Lenddo::WhiteLabelClient.partner_token(@application_id, provider = "Facebook", @oauth_key, oauth_secret = nil, token_data = {})
|
118
139
|
|
119
|
-
|
120
|
-
oauth_key = "USER_ACCESS_TOKEN"
|
140
|
+
Response:
|
121
141
|
|
122
|
-
|
123
|
-
|
142
|
+
puts response.response_code
|
143
|
+
=> 200
|
144
|
+
puts response.status
|
145
|
+
=> "200 OK"
|
146
|
+
puts response.body
|
147
|
+
=> {"profile_id": "100000000000000FB"}"
|
124
148
|
|
125
|
-
|
126
149
|
#### Errors
|
127
150
|
|
128
151
|
* **BAD_REQUEST** *HTTP Status Code: 400* Request was malformed, or missing required data.
|
@@ -144,15 +167,66 @@ CommitPartnerJob has the following arguments:
|
|
144
167
|
3. **profile ids** - This is an array of ID's composed from the results of the `Lenddo::WhiteLabelClient.partner_token` service call.
|
145
168
|
|
146
169
|
4. **verification** - This is an optional argument which will allow you to send probe data with the verification object.
|
147
|
-
|
148
|
-
|
170
|
+
|
171
|
+
Sample verification object:
|
172
|
+
|
173
|
+
verificationData = {
|
174
|
+
"name": {
|
175
|
+
"first": "John",
|
176
|
+
"middle": "J",
|
177
|
+
"last": "Doe"
|
178
|
+
},
|
179
|
+
"date_of_birth": "1990-01-01",
|
180
|
+
"employer": "LenddoEFL",
|
181
|
+
"phone": {
|
182
|
+
"mobile": "55512456789",
|
183
|
+
"home": "0254897"
|
184
|
+
},
|
185
|
+
"employment_period": {
|
186
|
+
"start_date": "2010-05-01",
|
187
|
+
"end_date": "2015-02-30"
|
188
|
+
},
|
189
|
+
"mothers_maiden_name": {
|
190
|
+
"first": "Martha",
|
191
|
+
"middle": "K",
|
192
|
+
"last": "Smith"
|
193
|
+
},
|
194
|
+
"government_ids": {[
|
195
|
+
"ID1": "555"
|
196
|
+
]},
|
197
|
+
"university": "University Name",
|
198
|
+
"email": "John@gmail.com",
|
199
|
+
"work_email": "John@work.com",
|
200
|
+
"address": {
|
201
|
+
"latitude" : "40.758896",
|
202
|
+
"longitude" : "-73.985130",
|
203
|
+
"line_1": "Street 1",
|
204
|
+
"line_2": "Street 2",
|
205
|
+
"administrative_division" : "Manhattan",
|
206
|
+
"city": "New York",
|
207
|
+
"postal_code":"39531",
|
208
|
+
"country_code: "USA"
|
209
|
+
}
|
210
|
+
}
|
211
|
+
|
212
|
+
Usage:
|
213
|
+
|
214
|
+
require 'lenddo/white_label_client'
|
149
215
|
|
150
|
-
|
151
|
-
|
152
|
-
|
216
|
+
partnerscript_id = "YOUR_PARTNERSCRIPT_ID"
|
217
|
+
application_id = "GENERATED_UNIQUE_ID"
|
218
|
+
profile_ids = ["100000000000000FB"]
|
153
219
|
|
154
|
-
|
155
|
-
|
220
|
+
response = Lenddo::WhiteLabelClient.commit_partner_job(@partnerscript_id, @application_id, @profile_ids, verification = nil)
|
221
|
+
|
222
|
+
Response:
|
223
|
+
|
224
|
+
puts response.response_code
|
225
|
+
=> 200
|
226
|
+
puts response.status
|
227
|
+
=> "200 OK"
|
228
|
+
puts response.body
|
229
|
+
=> {"success": true}
|
156
230
|
|
157
231
|
### Errors
|
158
232
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Lenddo
|
2
2
|
class NetworkService
|
3
3
|
def mobile_data(partnerscript_id)
|
4
|
-
|
4
|
+
signed_request(
|
5
5
|
method: "GET",
|
6
6
|
host: Lenddo.configuration.network_service,
|
7
7
|
path: "/MobileData",
|
@@ -9,11 +9,10 @@ module Lenddo
|
|
9
9
|
partner_script_id: partnerscript_id
|
10
10
|
}
|
11
11
|
)
|
12
|
-
JSON.parse(response.body)
|
13
12
|
end
|
14
13
|
|
15
14
|
def extra_application_data(application_id, partnerscript_id, extra_data)
|
16
|
-
|
15
|
+
signed_request(
|
17
16
|
method: "POST",
|
18
17
|
host: Lenddo.configuration.network_service,
|
19
18
|
path: "/ExtraApplicationData",
|
@@ -23,11 +22,10 @@ module Lenddo
|
|
23
22
|
extra_data: extra_data
|
24
23
|
}.to_json
|
25
24
|
)
|
26
|
-
JSON.parse(response.body)
|
27
25
|
end
|
28
26
|
|
29
27
|
def partner_token(application_id, provider, token_data, oauth_key, oauth_secret)
|
30
|
-
|
28
|
+
signed_request(
|
31
29
|
method: "POST",
|
32
30
|
host: Lenddo.configuration.network_service,
|
33
31
|
path: "/PartnerToken",
|
@@ -40,11 +38,10 @@ module Lenddo
|
|
40
38
|
client_id: application_id
|
41
39
|
}.to_json
|
42
40
|
)
|
43
|
-
JSON.parse(response.body)
|
44
41
|
end
|
45
42
|
|
46
43
|
def commit_partner_job(partnerscript_id, application_id, profile_ids, verification)
|
47
|
-
|
44
|
+
signed_request(
|
48
45
|
method: "POST",
|
49
46
|
host: Lenddo.configuration.network_service,
|
50
47
|
path: "/CommitPartnerJob",
|
@@ -55,7 +52,6 @@ module Lenddo
|
|
55
52
|
verification_data: verification
|
56
53
|
}.to_json
|
57
54
|
)
|
58
|
-
JSON.parse(response.body)
|
59
55
|
end
|
60
56
|
end
|
61
57
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Lenddo
|
2
|
+
class Response
|
3
|
+
def initialize(http_response)
|
4
|
+
@http_response = http_response
|
5
|
+
end
|
6
|
+
|
7
|
+
def status
|
8
|
+
@http_response.status
|
9
|
+
end
|
10
|
+
|
11
|
+
def response_code
|
12
|
+
@http_response.response_code
|
13
|
+
end
|
14
|
+
|
15
|
+
def body
|
16
|
+
JSON.parse(@http_response.body)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Lenddo
|
2
2
|
class ScoreService
|
3
3
|
def application_score(application_id, partnerscript_id)
|
4
|
-
|
4
|
+
signed_request(
|
5
5
|
method: "GET",
|
6
6
|
host: Lenddo.configuration.score_service,
|
7
7
|
path: "/ClientScore/#{application_id}",
|
@@ -9,11 +9,10 @@ module Lenddo
|
|
9
9
|
partner_script_id: partnerscript_id
|
10
10
|
}
|
11
11
|
)
|
12
|
-
JSON.parse(response.body)
|
13
12
|
end
|
14
13
|
|
15
14
|
def application_multiple_scores(application_id, partnerscript_id)
|
16
|
-
|
15
|
+
signed_request(
|
17
16
|
method: "GET",
|
18
17
|
host: Lenddo.configuration.score_service,
|
19
18
|
path: "/ApplicationMultipleScores/#{application_id}",
|
@@ -21,11 +20,10 @@ module Lenddo
|
|
21
20
|
partner_script_id: partnerscript_id
|
22
21
|
}
|
23
22
|
)
|
24
|
-
JSON.parse(response.body)
|
25
23
|
end
|
26
24
|
|
27
25
|
def application_verification(application_id, partnerscript_id)
|
28
|
-
|
26
|
+
signed_request(
|
29
27
|
method: "GET",
|
30
28
|
host: Lenddo.configuration.score_service,
|
31
29
|
path: "/ClientVerification/#{application_id}",
|
@@ -33,11 +31,10 @@ module Lenddo
|
|
33
31
|
partner_script_id: partnerscript_id
|
34
32
|
}
|
35
33
|
)
|
36
|
-
JSON.parse(response.body)
|
37
34
|
end
|
38
35
|
|
39
36
|
def application_decision(application_id, partnerscript_id)
|
40
|
-
|
37
|
+
signed_request(
|
41
38
|
method: "GET",
|
42
39
|
host: Lenddo.configuration.score_service,
|
43
40
|
path: "/ApplicationDecision/#{application_id}",
|
@@ -45,7 +42,6 @@ module Lenddo
|
|
45
42
|
partner_script_id: partnerscript_id
|
46
43
|
}
|
47
44
|
)
|
48
|
-
JSON.parse(response.body)
|
49
45
|
end
|
50
46
|
end
|
51
47
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require "lenddo"
|
2
2
|
require "lenddo/authentication"
|
3
|
+
require "lenddo/response"
|
3
4
|
require "lenddo/score_service/self"
|
4
5
|
|
5
6
|
include Lenddo::Authentication
|
@@ -13,35 +14,35 @@ module Lenddo
|
|
13
14
|
# @param string partnerscript_id
|
14
15
|
def application_score(application_id, partnerscript_id)
|
15
16
|
@score_service ||= ScoreService.new
|
16
|
-
@score_service.application_score(application_id, partnerscript_id)
|
17
|
+
Response.new @score_service.application_score(application_id, partnerscript_id)
|
17
18
|
end
|
18
19
|
# Calls the Lenddo Service with the provided application_id and partner_script_id to return an array of LenddoScore records
|
19
20
|
# @param string application_id
|
20
21
|
# @param string partnerscript_id
|
21
22
|
def application_multiple_scores(application_id, partnerscript_id)
|
22
23
|
@score_service ||= ScoreService.new
|
23
|
-
@score_service.application_multiple_scores(application_id, partnerscript_id)
|
24
|
+
Response.new @score_service.application_multiple_scores(application_id, partnerscript_id)
|
24
25
|
end
|
25
26
|
# Calls the Lenddo Service with the provided application_id and partner_script_idto return a application verification result.
|
26
27
|
# @param string application_id
|
27
28
|
# @param string partnerscript_id
|
28
29
|
def application_verification(application_id, partnerscript_id)
|
29
30
|
@score_service ||= ScoreService.new
|
30
|
-
@score_service.application_verification(application_id, partnerscript_id)
|
31
|
+
Response.new @score_service.application_verification(application_id, partnerscript_id)
|
31
32
|
end
|
32
33
|
# Calls the Lenddo Service with the provided application_id and partner_script_id to return a application decision result.
|
33
34
|
# @param string application_id
|
34
35
|
# @param string partnerscript_id
|
35
36
|
def application_decision(application_id, partnerscript_id)
|
36
37
|
@score_service ||= ScoreService.new
|
37
|
-
@score_service.application_decision(application_id, partnerscript_id)
|
38
|
+
Response.new @score_service.application_decision(application_id, partnerscript_id)
|
38
39
|
end
|
39
40
|
|
40
41
|
# Get mobile data using the partner_script_id
|
41
42
|
# @param string partnerscript_id
|
42
43
|
def mobile_data(partnerscript_id)
|
43
44
|
@network_service ||= NetworkService.new
|
44
|
-
@network_service.mobile_data(partnerscript_id)
|
45
|
+
Response.new @network_service.mobile_data(partnerscript_id)
|
45
46
|
end
|
46
47
|
end
|
47
48
|
end
|
data/lib/lenddo/version.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "lenddo"
|
2
2
|
require "lenddo/authentication"
|
3
|
+
require "lenddo/response"
|
3
4
|
require "lenddo/network_service/self"
|
4
5
|
|
5
6
|
include Lenddo::Authentication
|
@@ -18,7 +19,7 @@ module Lenddo
|
|
18
19
|
if !extra_data.is_a?(Hash)
|
19
20
|
raise ArgumentError.new("@extra_data must be a Hash.")
|
20
21
|
else
|
21
|
-
@network_service.extra_application_data(application_id, partnerscript_id, extra_data)
|
22
|
+
Response.new @network_service.extra_application_data(application_id, partnerscript_id, extra_data)
|
22
23
|
end
|
23
24
|
end
|
24
25
|
# Posting network tokens, if successful, returns a "Profile ID" which is used when submitting a client for scoring.
|
@@ -35,7 +36,7 @@ module Lenddo
|
|
35
36
|
elsif !token_data.is_a?(Hash)
|
36
37
|
raise ArgumentError.new("@token_data must be a Hash.")
|
37
38
|
else
|
38
|
-
@network_service.partner_token(application_id, provider, token_data, oauth_key, oauth_secret)
|
39
|
+
Response.new @network_service.partner_token(application_id, provider, token_data, oauth_key, oauth_secret)
|
39
40
|
end
|
40
41
|
end
|
41
42
|
# Submit an application with profile ids for scoring to Lenddo.
|
@@ -52,7 +53,7 @@ module Lenddo
|
|
52
53
|
elsif profile_ids.empty?
|
53
54
|
raise ArgumentError.new("@profile_ids must contain at least one entry.")
|
54
55
|
else
|
55
|
-
@network_service.commit_partner_job(partnerscript_id, application_id, profile_ids, verification)
|
56
|
+
Response.new @network_service.commit_partner_job(partnerscript_id, application_id, profile_ids, verification)
|
56
57
|
end
|
57
58
|
end
|
58
59
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lenddo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- arjay salvadora
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -103,6 +103,7 @@ files:
|
|
103
103
|
- lib/lenddo/configuration.rb
|
104
104
|
- lib/lenddo/errors/configuration.rb
|
105
105
|
- lib/lenddo/network_service/self.rb
|
106
|
+
- lib/lenddo/response.rb
|
106
107
|
- lib/lenddo/score_service/self.rb
|
107
108
|
- lib/lenddo/service_client.rb
|
108
109
|
- lib/lenddo/version.rb
|