Skip to content

Instantly share code, notes, and snippets.

@CITGuru
Last active September 23, 2019 09:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CITGuru/8c57990c2b139f5f0967a384396d4262 to your computer and use it in GitHub Desktop.
Save CITGuru/8c57990c2b139f5f0967a384396d4262 to your computer and use it in GitHub Desktop.

API

Authentication

Login

route: /login method: POST

Request Body

{
username: "username",
password: "password",
}`

Response

{
token: "zzsfgozkfgIAUSWO(URFE(FIEOF"
}

Authenticating

To send request route that requires login, add this to the header: Authorization: JWT <token>

List of Housing Unit

route: /housing method: GET header: Authorization: JWT <token> Response

[{}, {}...]

Add Housing

route: /housing method: POST header: Authorization: JWT <token> Request body:

{
estate: "zlrgkfg",
firstName":"Oyetoke",
...
}

Response

{
message: "Created succesfully",
formID: "kENkf"
}

GET Housing

route: /housing/:formID method: GET header: Authorization: JWT <token> Response

{
estate: "zlrgkfg",
firstName":"Oyetoke",
formID: "kENkf",
...
}

Update Housing

route: /housing/:formID method: POST header: Authorization: JWT <token> Request body:

{
estate: "zlrgkfg",
firstName":"Toby",
...
}

Response

{
estate: "zlrgkfg",
firstName":"Oyetoke",
formID: "kENkf",
...
}

Upload File

route: /upload method: POST header: Authorization: JWT <token> Request body:

{
image: "<byte>",
formID: ""
...
}

Response

{
fileID: "jdj",
message: "Uploaded successfully"
...
}

GET Upload Files

route: /upload method: GET header: Authorization: JWT <token> Response

[{}...]

GET Upload File

route: /upload/:fileID method: GET header: Authorization: JWT <token> Response

{
fileID: "sjflskf",
image: "lKSNs"
}

Upload Housing Documents

This contains addition body params base on the type of documents you are upload. You need to specify the type of documents you want to upload. If you send allocation_letter as the type of the document, you need to send along the year, or if you chose other you'll need to send along description. fileID is the id of the file you uploaded using the upload file route.

route: /documents method: POST header: Authorization: JWT <token> Request body:

{
type: "allocation_letter",
fileID: "9ofuffufifpfopfpfujpruf",
year: "2019",
description: ""
...
}

Response

{
uploadID: "fjljf",
message: "Uploaded successfully"
...
}

Get Housing Documents

route: /documents method: GET header: Authorization: JWT <token> Params body:

{
type: "allocation_letter",
...
}

Response

[{}, {}]

Estates

route: /estates method: GET header: Authorization: JWT <token>

Response

```js
[{}...]

Upload Document

To upload a document, you need to send two requests to same endpoint. The first one is to upload the file with a generated uuid and have it return a file_id which is same as the uuid, the second one is to create a document object with the file_id (guid), form_id and extra info

Upload Document : Step 1

You must generate a valid uuid known as guid and send a post request along with it in the url. The header must contain Content-Disposition: inline filename=<name>;

route: /upload/<guid> method: POST header: Content-Disposition: inline filename=<name>; body:

file: "some binary"
}

Upload Document : Step 2

This step is to create a document object as mentioned earlier. Just send along, the file_id, description, year and form_id

route: /upload/<guid> method: PUT body:

    file_id: <guid>,
    description: "tobi ti pe ju",
    year: null // 2018,
    form_id: "83fjfd"
}```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment