Skip to content

Commit 4200583

Browse files
committed
Merge pull request #9 from ryanahall/rhall/use_v4_endpoint
use the v4 api endpoint
2 parents 67401f1 + 54d7056 commit 4200583

20 files changed

+642
-598
lines changed

README.md

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,49 +19,66 @@ import blockscore
1919
client = blockscore.Client({'api_key':'Your API Key'})
2020
```
2121

22-
## Verifications
23-
24-
### List all verifications
22+
## People
23+
24+
### List all people
2525

2626
```python
27-
verification_list = client.verification.all()
28-
verification_list = verification_list.body
27+
people_list = client.people.all()
28+
people_list = people_list.body
2929
```
3030

31-
### List `5` verifications
31+
### List `5` people
3232

3333
```python
34-
verification_list = client.verification.all(count=5)
35-
verification_list = verification_list.body
34+
people_list = client.people.all(count=5)
35+
people_list = people_list.body
3636
```
37-
38-
### View a verification by ID
37+
38+
### View a person by ID
3939

4040
```python
41-
verification = client.verification.retrieve(verification_id)
42-
verification = verification.body
41+
person = client.people.retrieve(person_id)
42+
person = person.body
4343
```
4444

45-
### Create a new verification
45+
### Create a new person
4646

4747
```python
48-
verification = client.verification.create('1980-01-01',{'ssn': '0000'},{'first': 'john', 'last': 'doe'},{'street1': '1 Infinite Loop', 'city': 'Palo Alto', 'state': 'ca', 'postal_code': '94309', 'country_code': 'us'})
49-
verification = verification.body
48+
test_identity = {
49+
"name_first": "John",
50+
"name_middle": "Pearce",
51+
"name_last": "Doe",
52+
"birth_day": "23",
53+
"birth_month": "8",
54+
"birth_year": "1980",
55+
"document_type": "ssn",
56+
"document_value": "0000",
57+
"address_street1": "1 Infinite Loop",
58+
"address_street2": "Apt 6",
59+
"address_city": "Cupertino",
60+
"address_subdivision": "CA",
61+
"address_postal_code": "95014",
62+
"address_country_code": "US",
63+
}
64+
65+
person = client.people.create(test_identity)
66+
person = person.body
5067
```
5168

5269
## Question Sets
5370

5471
### Create a new question set
5572

5673
```python
57-
question_set = client.question_set.create(verification_id)
74+
question_set = client.question_sets.create(person_id)
5875
question_set = question_set.body
5976
```
6077

6178
### Score a question set
6279

6380
```python
64-
score = self.client.question_set.score(verif_id, qset_id, [
81+
score = self.client.question_sets.score(qset_id, [
6582
{'question_id':1, 'answer_id':1},
6683
{'question_id':2, 'answer_id':1},
6784
{'question_id':3, 'answer_id':1},
@@ -90,7 +107,7 @@ score = score.body
90107

91108

92109
## Contributing to BlockScore
93-
110+
94111
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
95112
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
96113
* Fork the project.

blockscore/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
from .client import Client
2-
api_key = None # use blockscore.api_key = 'your_api_key' after importing blockscore
1+
from blockscore.client import Client
2+
api_key = None # use blockscore.api_key = 'your_api_key' after importing blockscore
3+

blockscore/api/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# Import all the classes into api module
2-
from . import verification
3-
from . import question_set
2+
from blockscore.api import people
3+
from blockscore.api import question_sets
4+
from blockscore.api import companies

blockscore/api/companies.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,32 @@
44

55
class Companies():
66

7-
def __init__(self, client):
8-
self.client = client
9-
10-
#
11-
# '/companies' POST
12-
#
13-
def create(self, options = {}):
14-
return self.client.post(COMPANIES_PATH, options)
15-
16-
#
17-
# '/companies/:id' GET
18-
#
19-
def retrieve(self, id, options = {}):
20-
body = options['query'] if 'query' in options else {}
21-
return self.client.get('%s/%s' % (COMPANIES_PATH, str(id)), body)
22-
23-
#
24-
# '/companies' GET
25-
#
26-
def all(self, count = None, offset = None, options = {}):
27-
body = options['body'] if 'body' in options else {}
28-
29-
if count:
30-
body['count'] = count
31-
if offset:
32-
body['offset'] = offset
33-
34-
return self.client.get(COMPANIES_PATH, body)
7+
def __init__(self, client):
8+
self.client = client
9+
10+
#
11+
# '/companies' POST
12+
#
13+
def create(self, options = {}):
14+
return self.client.post(COMPANIES_PATH, options)
15+
16+
#
17+
# '/companies/:id' GET
18+
#
19+
def retrieve(self, id, options = {}):
20+
body = options['query'] if 'query' in options else {}
21+
return self.client.get('%s/%s' % (COMPANIES_PATH, str(id)), body)
22+
23+
#
24+
# '/companies' GET
25+
#
26+
def all(self, count = None, offset = None, options = {}):
27+
body = options['body'] if 'body' in options else {}
28+
29+
if count:
30+
body['count'] = count
31+
if offset:
32+
body['offset'] = offset
33+
34+
return self.client.get(COMPANIES_PATH, body)
3535

blockscore/api/people.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Returns user api instance
2+
3+
PEOPLE_PATH = '/people'
4+
5+
class People():
6+
7+
def __init__(self, client):
8+
self.client = client
9+
10+
#
11+
# '/people' POST
12+
#
13+
# date_of_birth -
14+
# identification -
15+
# name -
16+
# address -
17+
def create(self, options = {}):
18+
response = self.client.post(PEOPLE_PATH, options)
19+
return response
20+
21+
#
22+
# '/people/:id' GET
23+
#
24+
# id -
25+
def retrieve(self, id, options = {}):
26+
body = options['query'] if 'query' in options else {}
27+
response = self.client.get('%s/%s' % (PEOPLE_PATH, str(id)), body)
28+
return response
29+
30+
#
31+
# '/people' GET
32+
#
33+
def all(self, count=None, offset=None, options = {}):
34+
body = options['body'] if 'body' in options else {}
35+
36+
if count != None:
37+
body['count'] = count
38+
if offset != None:
39+
body['offset'] = offset
40+
41+
response = self.client.get(PEOPLE_PATH, body)
42+
return response
43+

blockscore/api/question_set.py

Lines changed: 0 additions & 43 deletions
This file was deleted.

blockscore/api/question_sets.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
2+
QUESTION_SET_PATH = '/question_sets'
3+
4+
class QuestionSets():
5+
6+
def __init__(self, client):
7+
self.client = client
8+
9+
#
10+
# '/question_sets' POST
11+
#
12+
# verification_id -
13+
def create(self, person_id, options = {}):
14+
body = options['body'] if 'body' in options else {}
15+
body['person_id'] = person_id
16+
17+
response = self.client.post(QUESTION_SET_PATH, body)
18+
return response
19+
20+
#
21+
# '/question_sets/:id/:score' POST
22+
#
23+
# answers -
24+
def score(self, id, answers):
25+
body = {}
26+
body['answers'] = answers
27+
28+
options = {}
29+
options['request_type'] = 'json'
30+
31+
response = self.client.post('%s/%s/score' % (QUESTION_SET_PATH, str(id)), body, options)
32+
return response
33+
34+
#
35+
# '/question_sets/:id' GET
36+
#
37+
# id -
38+
def retrieve(self, id):
39+
body = {}
40+
response = self.client.get('%s/%s' % (QUESTION_SET_PATH, str(id)), body)
41+
return response
42+
43+
#
44+
# '/question_sets' GET
45+
#
46+
def all(self, count=None, offset=None, options = {}):
47+
body = options['body'] if 'body' in options else {}
48+
49+
if count:
50+
body['count'] = count
51+
if offset:
52+
body['offset'] = offset
53+
54+
response = self.client.get(QUESTION_SET_PATH, body)
55+
return response
56+

blockscore/api/verification.py

Lines changed: 0 additions & 50 deletions
This file was deleted.

blockscore/client.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
from .http_client import HttpClient
1+
from blockscore.http_client import HttpClient
22

33
# Assign all the api classes
4-
from .api.verification import Verification
5-
from .api.question_set import QuestionSet
6-
from .api.companies import Companies
4+
from blockscore.api.people import People
5+
from blockscore.api.question_sets import QuestionSets
6+
from blockscore.api.companies import Companies
77

88
class Client():
99

10-
def __init__(self, auth = {}, options = {}):
11-
self.http_client = HttpClient(auth, options)
12-
self.verification = Verification(self.http_client)
13-
self.question_set = QuestionSet(self.http_client)
14-
self.companies = Companies(self.http_client)
10+
def __init__(self, auth = {}, options = {}):
11+
self.http_client = HttpClient(auth, options)
12+
self.people = People(self.http_client)
13+
self.question_sets = QuestionSets(self.http_client)
14+
self.companies = Companies(self.http_client)
1515

0 commit comments

Comments
 (0)