Skip to content

Commit f7075d7

Browse files
committed
add existing tech test spec
1 parent 3af2825 commit f7075d7

File tree

2 files changed

+228
-1
lines changed

2 files changed

+228
-1
lines changed

Diff for: README.md

+115-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,115 @@
1-
# scala-dev-homework
1+
# ClearScore - Backend Technical Test
2+
3+
To get an idea of your technical experience, we’d like you to develop a simple microservice that collates financial products from a small selection of partners. You can use Scala, Java or Kotlin, along with any tools, frameworks and libraries you feel are appropriate.
4+
5+
We'll be looking for the following when reviewing:
6+
7+
- documented code with a coherent project structure
8+
- products being returned in a timely manner
9+
- behaviour when upstream APIs returning errors or taking too long to respond
10+
- unit tests (we're huge fans of TDD!)
11+
12+
Once completed please include the following in a single ZIP file:
13+
14+
- all code, including tests
15+
- a bash script start.sh that will start up your service locally, it should support the following environment variables:
16+
- `HTTP_PORT`: The port to expose your service on
17+
- `CSCARDS_ENDPOINT`: The url for CSCards
18+
- `SCOREDCARDS_ENDPOINT`: The url for ScoredCards
19+
- a short README outlining how you’ve designed your service and how you’d intend to deploy it
20+
21+
## The Challenge
22+
23+
Your microservice should expose a single endpoint that consumes some information about the user’s financial situation and return credit cards recommended for them, sorted based on their eligibility and the cards’ APR (annual percentage rate).
24+
25+
A swagger definition (microservice-swagger.json) which your API should conform to is included in this repo. The data you’ll be returning comes from two partner APIs, described in the sections below. The provider endpoints below are public and do not require any authorisation tokens to access, but make sure you’ve got a User Agent header available.
26+
27+
Each partner returns an eligibility rating (i.e. how likely it is the user will be approved) and an APR for each card (watch out for the scales in the sections below), these should be used along with the formula below to sort the cards returned from your API, with the highest scoring cards being ranked higher. The score should be returned in the response for each card as cardScore.
28+
29+
$$ sortingScore = eligibility ∗ ((1/apr)^2) $$
30+
31+
Here’s an example request and response from the service:
32+
```javascript
33+
POST /creditcards
34+
{
35+
"name": "Ada Lovelace",
36+
"creditScore": 341,
37+
"salary": 28000
38+
}
39+
40+
Response:
41+
[
42+
{
43+
"provider": "ScoredCards"
44+
"name": "ScoredCard Builder",
45+
"apr": 19.4,
46+
"cardScore": 0.212
47+
},
48+
{
49+
"provider": "CSCards",
50+
"name": "SuperSaver Card",
51+
"apr": 21.4,
52+
"cardScore": 0.137
53+
},
54+
{
55+
"provider": "CSCards",
56+
"name": "SuperSpender Card",
57+
"apr": 19.2,
58+
"cardScore": 0.135
59+
}
60+
]
61+
```
62+
63+
### Partner 1 - CSCards
64+
65+
The first partner provides a JSON API to get eligible cards. They’re only interested in a user’s full name and credit score to make their decisions. The response is a list of cards, including an eligibility rating from 0.0 to 10.0. See below for an example request and response, and see [https://app.clearscore.com/api/global/backend-tech-test/v1/doc/](https://app.clearscore.com/api/global/backend-tech-test/v1/doc/) for their API definition.
66+
67+
**API endpoint**: [https://app.clearscore.com/api/global/backend-tech-test/v1/cards](https://app.clearscore.com/api/global/backend-tech-test/v1/cards)
68+
69+
```javascript
70+
POST https://app.clearscore.com/api/global/backend-tech-test/v1/cards
71+
{
72+
"name": "Ada Lovelace",
73+
"creditScore": 341
74+
}
75+
76+
Response:
77+
[
78+
{
79+
"cardName": "SuperSaver Card",
80+
"apr": 21.4,
81+
"eligibility": 6.3
82+
},
83+
{
84+
"cardName": "SuperSpender Card",
85+
"apr": 19.2,
86+
"eligibility": 5.0
87+
}
88+
]
89+
```
90+
91+
### Partner 2 - ScoredCards
92+
93+
Our other partner uses all the user’s information to make their scoring decisions.
94+
95+
The eligibility rating is provided in the `approvalRating` field and is on a scale from 0.0 to 1.0. An example request and response is below, and see [https://app.clearscore.com/api/global/backend-tech-test/v2/doc/](https://app.clearscore.com/api/global/backend-tech-test/v2/doc/) for the swagger definition.
96+
97+
**API endpoint**: [https://app.clearscore.com/api/global/backend-tech-test/v2/creditcards](https://app.clearscore.com/api/global/backend-tech-test/v2/creditcards)
98+
99+
```javascript
100+
POST https://app.clearscore.com/api/global/backend-tech-test/v2/creditcards
101+
{
102+
"name": "Ada Lovelace",
103+
"score": 341,
104+
"salary": 28000
105+
}
106+
107+
Response:
108+
[
109+
{
110+
"card": "ScoredCard Builder",
111+
"apr": 19.4,
112+
"approvalRating": 0.8
113+
}
114+
]
115+
```

Diff for: microservice-swagger.json

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
{
2+
"swagger": "2.0",
3+
"info": {
4+
"description": "ClearScore Technical Test Microservice",
5+
"version": "1.0",
6+
"title": "ClearScore Technical Test"
7+
},
8+
"host": "localhost",
9+
"basePath": "/",
10+
"schemes": [
11+
"http"
12+
],
13+
"paths": {
14+
"/creditcards": {
15+
"post": {
16+
"summary": "Find credit cards user is eligible for",
17+
"description": "Returns a list of credit cards that our partners have indicated the user is eligible to apply for.",
18+
"consumes": [
19+
"application/json"
20+
],
21+
"produces": [
22+
"application/json"
23+
],
24+
"parameters": [
25+
{
26+
"in": "body",
27+
"name": "body",
28+
"required": true,
29+
"schema": {
30+
"$ref": "#/definitions/CreditCardRequest"
31+
}
32+
}
33+
],
34+
"responses": {
35+
"200": {
36+
"description": "A sorted list of credit cards the user is eligible to apply for.",
37+
"schema": {
38+
"$ref": "#/definitions/CreditCardResponse"
39+
}
40+
},
41+
"400": {
42+
"description": "The request contained invalid parameters"
43+
}
44+
}
45+
}
46+
}
47+
},
48+
"definitions": {
49+
"CreditCardRequest": {
50+
"type": "object",
51+
"required": [
52+
"name",
53+
"creditScore",
54+
"salary"
55+
],
56+
"properties": {
57+
"name": {
58+
"type": "string",
59+
"example": "John Smith",
60+
"description": "Users full name"
61+
},
62+
"creditScore": {
63+
"type": "integer",
64+
"format": "int32",
65+
"description": "Credit score between 0 and 700",
66+
"minimum": 0,
67+
"maximum": 700
68+
},
69+
"salary": {
70+
"type": "integer",
71+
"format": "int32",
72+
"description": "Users annual salary",
73+
"minimum": 0
74+
}
75+
}
76+
},
77+
"CreditCardResponse": {
78+
"type": "array",
79+
"items": {
80+
"$ref": "#/definitions/CreditCard"
81+
}
82+
},
83+
"CreditCard": {
84+
"type": "object",
85+
"required": [
86+
"apr",
87+
"name",
88+
"provider",
89+
"cardScore"
90+
],
91+
"properties": {
92+
"provider": {
93+
"type": "string",
94+
"description": "Name of the partner that provides the credit card"
95+
},
96+
"name": {
97+
"type": "string",
98+
"description": "Name of the credit card product"
99+
},
100+
"apr": {
101+
"type": "number",
102+
"format": "double",
103+
"description": "Annual percentage rate for the card"
104+
},
105+
"cardScore": {
106+
"type": "number",
107+
"format": "double",
108+
"description": "The score given to the credit card based on the scoring algorithm"
109+
}
110+
}
111+
}
112+
}
113+
}

0 commit comments

Comments
 (0)