Path | Method | Description |
---|---|---|
/users/register | POST | create new user account |
/users/login | POST | login with existing account |
/users/:id | GET | Get user by ID |
/users/:id | PATCH | Update user by ID |
/users/:id | DELETE | Delete user by ID |
Create new user account.
URL : /users/register
Method : POST
Auth required : No
Permissions required : None
Data constraints : { name: String, password : String, email: String (Unique) }
Condition : User Account successfully created.
Code : 201 OK
Content : { message : "User Successfully created", data:{} }
Condition : The requirements for creating new user account is not fullfilled.
Code : 500 Error
Content :
{
message : <Error message depending on the data error>,
data:{
<Error data if in development, in production mode it's empty>
}
}
Login with existing account.
URL : /users/login
Method : POST
Auth required : No
Permissions required : None
Data constraints : { password : String, email: String }
Condition : User Successfully logged in.
Code : 200 OK
Content : { token: "<token generated by server>" }
Condition : Error when logging in, either wrong password or email
Code : 400 Not found
Content :
{
message : "Wrong password or email",
data:{}
}
Show user by ID
URL : /users/:id
Method : GET
Auth required : YES
Permissions required : YES
Data constraints : {}
Condition : User found with such ID.
Code : 200 OK
Content :
{
message: "User found",
data:{
name:"<user name>",
orders:["<List of orders done by user>"],
receive:["<List of received packets>"],
email:"<user's email>"
}
}
Condition : User not found
Code : 400 Not found
Content :
{
message : "User not found",
data:{}
}
Update user by ID
URL : /users/:id
Method : PATCH
Auth required : YES
Permissions required : YES
Data constraints : { name:"<user's new name>", password:"<user's new password>", }
Condition : User found with such ID.
Code : 200 OK
Content :
{
message: "User Modified",
data:{
<user's data after modification>
}
}
Condition : User not found
Code : 400 Not found
Content :
{
message : "User not found",
data:{}
}
Delete user by ID
URL : /users/:id
Method : DELETE
Auth required : YES
Permissions required : YES
Data constraints : {}
Condition : User found with such ID.
Code : 200 OK
Content :
{
message: "User successfully deleted",
data:{
<user's data that was deleted>
}
}
Condition : User not found
Code : 400 Not found
Content :
{
message : "User not found",
data:{}
}
Path | Method | Description |
---|---|---|
/parcels | POST | Create new Parcel |
/parcels | GET | Get all parcels |
/parcels/:id | GET | Get parcel by ID |
/parcels/:id | PATCH | Update parcel by ID |
/parcels/:id | DELETE | Delete parcel by ID |
Create new Parcel entity.
URL : /parcels
Method : POST
Auth required : Yes
Permissions required : Yes
Data constraints : { deviceID: String, gyro : String, gps: String }
Condition : Parcel successfully created.
Code : 201 OK
Content : { message : "Parcel Successfully created", data:{} }
Condition : The requirements for creating new parcel is not fullfilled.
Code : 500 Error
Content :
{
message : <Error message depending on the data error>,
data:{
<Error data if in development, in production mode it's empty>
}
}
Show parcel by ID
URL : /parcels/:id
Method : GET
Auth required : YES
Permissions required : YES
Data constraints : {}
Condition : Parcel found with such ID.
Code : 200 OK
Content :
{
message: "Parcel found",
data:{
_id:"<parcel id>",
gyro:{
threshold:<boolean>
},
gps: {
location:{
long:<number>
lat:<number>
}
}
}
}
Condition : Parcel not found
Code : 400 Not found
Content :
{
message : "Parcel not found",
data:{}
}
Update Parcel by ID
URL : /parcels/:id
Method : PATCH
Auth required : YES
Permissions required : YES
Data constraints :
{
long: number,
lat: number,
threshold: boolean
}
Condition : Parcel found with such ID.
Code : 200 OK
Content :
{
message: "Parcel Modified",
data:{
<parcel's data after modification>
}
}
Condition : Parcel not found
Code : 400 Not found
Content :
{
message : "Parcel not found",
data:{}
}
Delete parcel by ID
URL : /parcels/:id
Method : DELETE
Auth required : YES
Permissions required : YES
Data constraints : {}
Condition : Parcel found with such ID.
Code : 200 OK
Content :
{
message: "Parcel successfully deleted",
data:{
<parcel's data that was deleted>
}
}
Condition : Parcel not found
Code : 400 Not found
Content :
{
message : "Parcel not found",
data:{}
}
Path | Method | Description |
---|---|---|
/orders | POST | Create new Order |
/orders/me/send | GET | Get order where logged in user is the sender |
/orders/me/receive | GET | Get order where logged in user is the receiver |
/orders/:id | GET | Get order by ID |
/orders/:id | PATCH | Update order by ID |
/orders/:id | DELETE | Delete order by ID |
Create new Order entity from where Logged in user is the sender
URL : /orders
Method : POST
Auth required : Yes
Permissions required : No
Data constraints : { deviceID: String, gyro : String, gps: String }
Condition : Order successfully created.
Code : 201 OK
Content : { message : "Order Successfully created", data:{} }
Condition : The requirements for creating new Order is not fullfilled.
Code : 500 Error
Content :
{
message : <Error message depending on the data error>,
data:{
<Error data if in development, in production mode it's empty>
}
}
show orders where user's role is sender
URL : /orders/me/send
Method : GET
Auth required : Yes
Permissions required : No
Data constraints : {[]}
Condition : Order successfully Retrived, but no data yet.
Code : 200 OK
Content :
{
message : "Order found",
data:[]
}
Condition : Order successfully Retrived with data.
Code : 200 OK
Content :
{
message : "Order found",
data:[
{
<Order's data>
},
{
<Order's data>
}
]
}
show orders where user's role is receiver
URL : /orders/me/receive
Method : GET
Auth required : Yes
Permissions required : No
Data constraints : {[]}
Condition : Order successfully Retrived, but no data yet.
Code : 200 OK
Content :
{
message : "Order found",
data:[]
}
Condition : Order successfully Retrived with data.
Code : 200 OK
Content :
{
message : "Order found",
data:[
{
<Order's data>
},
{
<Order's data>
}
]
}
Show orders by ID
URL : /orders/:id
Method : GET
Auth required : YES
Permissions required : YES
Data constraints : {}
Condition : Orders found with such ID.
Code : 200 OK
Content :
{
message: "Orders found",
data:{
_id:"<parcel id>",
status: <status enum>,
sender: <ref to user>
receiver: <ref to user>
destination: "Pondok Indah"
}
}
Condition : Order not found
Code : 400 Not found
Content :
{
message : "Order not found",
data:{}
}
Update Order by ID
URL : /orders/:id
Method : PATCH
Auth required : YES
Permissions required : YES
Data constraints :
{
sender:<new sender id>,
receiver:<new reciever id>
status:<new status>,
}
Condition : Order found with such ID and modified.
Code : 200 OK
Content :
{
message: "Orders Modified",
data:{
<order's data after modification>
}
}
Condition : Order not found
Code : 400 Not found
Content :
{
message : "Order not found",
data:{}
}
Delete Order by ID
URL : /orders/:id
Method : DELETE
Auth required : YES
Permissions required : YES
Data constraints : {}
Condition : Order found with such ID.
Code : 200 OK
Content :
{
message: "Order successfully deleted",
data:{
<order's data that was deleted>
}
}
Condition : Order not found
Code : 400 Not found
Content :
{
message : "Order not found",
data:{}
}