planr-backend

API documentation for Planr backend

Auth

Auth - Login user

post
/users/login

Parameter

Field Type Description
email String

email, must be unique

password String

password

name String

name

role_id Integer

user's role_id

{
    "email": "janedoe@example.com",
    "password": "thisisabadpassword",
    "name": "Jane Doe",
    "role_id": 3
}

Success 200

Field Type Description
message String

welcome message

user_id Integer

user's id

token String

JSON web token

HTTP/1.1 200 OK
  {
     "message": "Welcome Jane Doe!",
     "user_id": 3,
     "token" : "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InRlc3RAZXhhbXBsZS5jb20iLCJpYXQiOjE1NjkzMDA3NTUsImV4cCI6MTU2OTM4NzE1NX0.MqSP9WknoX-hqVuhPxcqgeMDUyt9DA4nU34OjTQLo2k"
  }

Error 4xx

Name Type Description
UnauthorizedUser 404

The user's credentials are invalid

HTTP/1.1 404 Unauthorized
{
  "message": "Invalid credentials."
}

Auth - Register user

post
/users/register

Parameter

Field Type Description
email String

email, must be unique

password String

password

{
  "email": "janedoe@example.com",
  "password": "thisisabadpassword",
}

201

Field Type Description
message String

welcome message

user_id Integer

user's id

token String

JSON web token

HTTP/1.1 201 CREATED
  {
     "message": "Welcome Jane Doe!",
     "user_id": 3,
     "token" : "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InRlc3RAZXhhbXBsZS5jb20iLCJpYXQiOjE1NjkzMDA3NTUsImV4cCI6MTU2OTM4NzE1NX0.MqSP9WknoX-hqVuhPxcqgeMDUyt9DA4nU34OjTQLo2k"
  }

Budget Items

Budget_Items - Get budget items

get
/budget-items

Query string

Field Type Description
limit Integer

Limit count to rows.

sortBy String

Sort rows by column specified.

sortDir String

Order rows by ascending (ASC) or descending (DESC) by default.

EXAMPLE Example
/budget-items?limit=5&sortDir=ASC&sortBy=cost 

Queries budget_items table as follows:

SELECT * FROM budget_items ORDER BY cost ASC LIMIT 5 

Success 200

Field Type Description
budget-items Object[]

Array of budget items (dynamically queried based on query params)

HTTP/1.1 200 OK (GET /api/budget-items?limit=2&sortBy=name&sortDir=asc)
[
  {
    "id": 5,
    "name": "Burritos",
    "quantity": 30,
    "cost": 10,
    "completed": false,
    "event_id": 3,
    "vendor_id": 2
  },
  {
    "id": 3,
    "name": "Business catering package",
    "quantity": 1,
    "cost": 600,
    "completed": false,
    "event_id": 1,
    "vendor_id": 2
  }
]

Events

Events - Get event (expanded) by id

get
events/:id

Success 200

Field Type Description
id Number

event id

created_by Number

created by user id

name String

event name

budget Decimal

event budget

location String

event location

start_date Date

event start date

end_date Date

event end date, can be null

events Object[]

Array of budgetItems

vendors Object[]

Array of vendors

HTTP/1.1 200 OK
{
"id": 3,
"created_by": 1,
"name": "Surprise Birthday",
"description": "A surprise birthday party for the ceo",
"budget": 2210,
"location": "Banquet room",
"start_date": "2019-03-04",
"end_date": "2019-03-05",
"budgetItems": [
   {
    "name": "Rental buses",
     "cost": 300,
     "completed": false,
     "quantity": 10
   },
   {
     "name": "Lobby rental",
     "cost": 800,
     "completed": true,
     "quantity": 1
  }
],
"vendors": [
   {
     "id": 1,
     "name": "Catering Co.",
     "type": "Food & Beverage"
   },
   {
     "id": 2,
     "name": "Fairfax Hotel",
     "type": "Lodging"
   }
]
}

Events - Get event budget item metrics by event id

get
events/:id

Success 200

Field Type Description
id Number

event id

sum_total_items_cost Number

total cost of all budget items on event

sum_completed_items_cost Number

cost of completed (true) budget items

sum_remaining_items_cost Number

cost of competed (false) budget items

HTTP/1.1 200 OK

{
  "event_id": "3",
  "sum_items_cost": 3310,
  "sum_completed_items_cost": 0,
  "sum_remaining_items_cos": 3310
}

Events - Get events

get
/events

Success 200

Field Type Description
events Object[]

Array of events

HTTP/1.1 200 OK
[
  {
    "id": 1,
    "created_by": 1,
    "name": "Company Party",
    "description": "A company-wide party to celebrate acquisition.",
    "budget": 23230,
    "location": "Building A, Room 232",
    "start_date": "2019-01-21",
    "end_date": "2019-01-23"
  },
  {
    "id": 2,
    "created_by": 1,
    "name": "Company luncheon",
    "description": "A company-wide lunch",
    "budget": 12320,
    "location": "Courtyard near the lobby",
    "start_date": "2019-02-15",
    "end_date": null
  },
]

Users

Users - Get user (expanded) by id

get
/users

Success 200

Field Type Description
id Integer

user id

name String

user's name

email String

user's email

role_id Integer

user's role_id

createdEvents Object[]

Array of events created by the user

HTTP/1.1 200 OK
 {
  "id": 1,
  "name": "John Smith",
  "email": "john@test.com",
  "role_id": 1,
  "role_name": "admin",
  "createdEvents": [
    {
      "event_id": 1,
      "event_name": "Company Party"
    },
    {
      "event_id": 3,
      "event_name": "Surprise Birthday"
    }
  ]
}

Users - Get users

get
/users

Success 200

Field Type Description
events Object[]

Array of users

HTTP/1.1 200 OK

[
  {
    "id": 1,
    "name": "John Smith",
    "email": "john@test.com",
    "role_id": 1
  },
  {
    "id": 2,
    "name": "Jane Doe",
    "email": "jane@test.com",
    "role_id": 1
  }
]
Generated with apidoc 0.17.7 - 2019-09-26T11:16:10.000Z