1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
[Truly.co](https://truly.co/) is an enterprise VOIP company. They were hiring
for a Clojure developer. Even though I'm an expert in Clojure, I opted to use
Haskell because I really wanted to play with the
[acid-state](https://github.com/acid-state/acid-state) library, and this seemed
like a great opportunity to do so.
## The [exercise](https://docs.google.com/document/d/1ZWcTzQdQ9zSZ8Tv4XDyCrju40_FuSJ7W6qu4-pUU-ZA/pub) is a Caller Id Service:
The goal of this exercise is for you to implement a standalone service that will
respond to requests seeking caller id information.
### Api Requirements/Notes
- Api should return json
- Phone numbers should be in E.164 format.
- Appropriate http codes should be returned on error.
### API Endpoints
#### GET /query
Fetches caller id information.
Params:
number - the number we want caller id information for.
Example query:
GET http://localhost/query?number=%2B15556789090
Response:
{results: [{ “name”: “Bob Barker”, “number”: “+15556789090”, “context”: “personal”}]}
#### `POST /number`
Adds caller id data to the service.
Body:
name - contact name
number - the number in E.164 format
context - the context for the phone number.
Note: A phone number may be present multiple times, but can only appear once per
context. In other words you can think of a <number,context> pair as unique.
#### Seed Data
Normally a service like this would call other services in turn, but to keep
things simple we are going to provide seed data for the service as a csv
file. Your service will need to read in that initial data and use it to serve
requests.
Line format:
<phone number>,<context>,<caller id>
Example:
5556780909,work,John Doe
The seed data can be downloaded via [this
link](https://www.dropbox.com/s/0hmkx242o42g924/interview-callerid-data.csv.gz).
### Service Requirements
- We prefer if your service is standalone, this means that it shouldn’t require
additional server software (tomcat/apache/etc) to run. If it does require such
software you will need to provide setup instructions.
- The port on which the service listens should be configurable without editing
code.
- Your code should include a README file with instructions on how to run your
service. Shell scripts are also appreciated but not required.
- You may NOT use an external datastore.
### Misc/Other Notes
- Once again to keep things simple data submitted to your service does not need
to be persisted.
- While our main goal is to look at your code, we will run your code and test
it.
- There is no timeline, please take as long as you want. However if you take
especially long we may check in.
- If you have any questions please ask.
## How to run this code
1. Have [stack](http://haskellstack.org/) installed
2. Optional: have [nix](https://nixos.org/nix/) installed. If you *don't* use nix, delete line 3 of `main.hs`.
3. Run `./main.hs` and the server will startup
To bootstrap the db, do `curl -XPOST "localhost:3000/bootstrap"`. This takes
like 3 seconds or so.
See `test.http` for some other examples.
|