Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LG - backend implementation #8

Merged
merged 14 commits into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ dmypy.json

# production
/build
coach_db.json

# misc
.DS_Store
Expand All @@ -148,4 +149,4 @@ dmypy.json

npm-debug.log*
yarn-debug.log*
yarn-error.log*
yarn-error.log*
114 changes: 114 additions & 0 deletions docs/http-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# HTTP API

The general URL format is `http[s]://<baseurl>/api/<version>/<object>?<param>=<value>&<param>=<value>&...`.

The API should be RESTful:
- GET - get data about '\<object\>' corresponding to parameters given in the URL
- POST - create/update '\<object\>' with data given in a JSON body
- DELETE - delete '\<object\>' corresponding to parameters given in the URL


## Coaches

The 'coaches' object supports POST, GET and DELETE.

`/api/v1/coaches`

The JSON fields used to represent a coach are as follows:
- name: string
- bio: string
- available: boolean
- birth_year: integer
- gender: string ('male', 'female' or 'other')
- languages: object {\<language\>:string: \<proficiency\>:integer}
- need: list \[integer\]
- rights: list \[integer\]
- housing: list \[integer\]


### Create new coach (POST)

`POST /api/v1/coaches`

#### Request body

JSON object with fields from the coach representation (all *required*).

#### Response

JSON object with the following fields:
- \<all fields from the coach representation\>
- id: integer


### Edit coach (POST)

`POST /api/v1/coaches/<id>`

#### Request body

JSON object with any fields from the coach representation (all *optional*).

#### Response

JSON object with the following fields:
- \<all fields from the coach representation\>
- id: integer


### Fetch all coaches (GET)

`GET /api/v1/coaches/`

#### Response

List of JSON objects with the following fields:
- \<all fields from the coach representation\>
- id: integer


### Look up coach by ID (GET)

`GET /api/v1/coaches/<id>`

#### Response

JSON object with the following fields:
- \<all fields from the coach representation\>
- id: integer


### Delete coach (DELETE)

`DELETE /api/v1/coaches/<id>`

#### Response

Empty.



## Coach matches

The 'coach-matches' object supports GET only. This corresponds to looking up coaches based on their suitability to a set of parameters.

`/api/v1/coach-matches`

### Look up coach matches (GET)

`GET /api/v1/coach-matches?<params>`

Parameters are as follows (all *optional*):
- birth_year: integer
LewisGaul marked this conversation as resolved.
Show resolved Hide resolved
- gender: string ('male', 'female' or 'other')
- languages: string (a comma separated list of "\<language\>:\<proficiency\>")
- need: integer
- rights: integer
- housing: integer

#### Response

A list of JSON objects in order of match score. Each element in the list has the following fields:
- \<all fields from the coach representation\>
- id: integer
- match_score: integer
21 changes: 21 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
aiofiles==0.5.0
certifi==2020.6.20
chardet==3.0.4
contextvars==2.4
h11==0.9.0
h2==3.2.0
hpack==3.0.0
hstspreload==2020.8.18
httptools==0.1.1
httpx==0.11.1
hyperframe==5.2.0
idna==2.10
immutables==0.14
multidict==4.7.6
rfc3986==1.4.0
sanic==20.6.3
sniffio==1.1.0
ujson==3.1.0
urllib3==1.25.10
uvloop==0.14.0
websockets==8.1
Loading