There are four main route collections.
- Auth
- User
- Contacts
- Memories
The auth route is used to get authorization-token to access the rest of the API. When calling a route the internal system will:
- Get relevant information from the database
- run the retrieved information and the request information through a layer of rules.
- If the rules are satisfied by the request, the information will be persisted and/or the caller will get the requested information.
- If the rules are not satisfied the caller will get an status code and a message explaining the error.
The rules are built from simple rules that are putted together by the rule assembler.
The basic url to the server is to be added
Authorization can currently be done by the following methods:
- Username and password
If the authorization is successful an jwt-token is received, containing the following:
- Expiration time
- The users guid
The token is to be added to each request against the API.
POST: /auth/login
Type | Parameter | value |
---|---|---|
json | clientId | An id that is distributed by the API-admin |
json | password | The users password. |
json | username | The users username |
200
{
"token": "<auth key>"
}
400
{
"error": {
"code": "INVALID_CLIENT_ID"
}
}
403
{
"error": {
"code": "LOGIN_FAILED"
}
}
404
{
"error": {
"code": "USER_DOES_NOT_EXISTS"
}
}
GET: /user
Type | Parameter | value |
---|---|---|
Head | Authorization | Bearer <auth token> |
200
{
name: 'Kristoffer',
guid: "bjbsnjfhdfngjdf4541154dsfds"
id: 'hgfisds44',
email: '[email protected]'
}
{
error: {
code: 'USER_DOES_NOT_EXISTS'
}
}
POST: /user
Type | Parameter | value |
---|---|---|
json | username | 'kristoffer' |
json | password | '*********' |
json | clientId | 'client.id.se' |
200
{
"guid": "<guid>"
}
400
{
"error: {
code: 'INVALID_USERNAME' | 'INVALID_EMAIL' | INVALID_PASSWORD | INVALID_CLIENT_ID
}
}
403
{
"error": {
"code": "USERNAME_ALREADY_TAKEN"
}
}
GET: /contacts
Type | Parameter | value |
---|---|---|
Head | Authorization | Bearer <auth token> |
200
[
{
"username": "contactname",
"guid": "s4f754sd2fsfajfdsda54",
"id": "-L2WrCY1G-N89gRxxXek",
"email": "[email protected]"
},
{
"username": "contactname2",
"guid": "4dfgdfgdfgfdg845453d",
"id": "-L2lk7TNfL3WzGuyoyM1",
"email": "[email protected]"
}
...
]
POST: /contacts
This functionality should be changed so that the added contact must accept the adder.
Type | Parameter | value |
---|---|---|
Head | Authorization | Bearer <auth token> |
json | contactGuid | dsfhiuhsdf46574dfs7486sd4 |
200
{
"contactList": [
"dfks4sdfsdf854fdsfsd",
"dsf4dsfg7sdr48g6vdg7fd6",
"sd45gfd6f4ds68f54ds6f8s4",
"dsfhiuhsdf46574dfs7486sd4" // <-- New contact
]
}
"error" {
"code": ALREADY_A_CONTACT
}
{
"error": {
"code": USER_DOES_NOT_EXISTS | CONTACT_DOES_NOT_EXISTS
}
}
GET: /memories/sent
Type | Parameter | value |
---|---|---|
Head | Authorization | Bearer <auth token> |
json | contactGuid | dsfhiuhsdf46574dfs7486sd4 |
200
[
{
"guid": "memory-1519512694957445",
"filePath": "public\\images\\memory-1519512694957445.jpg",
"message": "Hello, and look att this!",
"recipients": [
"1tb642H6453nD57R16by83Q5au6mw6E15",
"5784ddff42H6453gdgweygtas7gh8dfsE"
],
"sender": "Ceu0I78uW0RC52B5UtuiKe4K6vF5LNqt6"
},
{
"guid": "memory-1519513401034576",
"filePath": "public\\images\\memory-1519513401034576.jpg",
"message": "Wat about a grasshopper for dinner?",
"recipients": [
"1tb642H6453nD57R16by83Q5au6mw6E15"
],
"sender": "Ceu0I78uW0RC52B5UtuiKe4K6vF5LNqt6"
}
]
GET: /image/?filePath=....
Type | Parameter | value |
---|---|---|
Head | Authorization | Bearer <auth token> |
GET (query param) | filePath | "public\\images\\memory-1519512694957445.jpg" |
200
image
{
"error": {
"code": "INVALID_IMAGE" // The requested file does not exist or can not be accessed
}
}
POST: baseURL/memory
Type | Parameter | value |
---|---|---|
Head | Authorization | Bearer <auth token> |
Post | memory | Image (.png or .jpeg |
Post | recipients | [<guid>, <guid>,...] |
Post | message | "Hello there!" |
200
{
"failedToSendTo": []
}
{
"error": {
"code": "INVALID_IMAGE"
}
}
{
"error": {
"code": "USER_DOES_NOT_EXISTS"
}
}