Allows users to upload a csv file of employees. The router then loops over each employee and adds each employee to the database.
URL
/csv
Method:
POST
Post Object
Requires a csv file be attached to the request.
Success Response:
- Code: 200
Example Content:Succesfully uploaded 5 users
Error Response:
If none of the employees have the required information or if the required headers are wrong
- Code: 400
Content:Each employee needs a 'First Name', 'Last name', 'Job title' and 'Email'
Sample Call:
One option for handling sending a csv file on the front end is to use the FormData() constructor. The following is an example of using FormData() to attach a csv file to the post request_
const handleSubmit = e => {
e.preventDefault();
const data = new FormData(); // creates a form object
data.append('bulkupload', file); // attaches the csv
axiosWithAuth()
.post('/csv', data)
.then(response => {
console.log('success');
})
.catch(error => {
console.log(error.response);
});
};
```
You will also need to verify that the file uploaded is a csv file. Here is an example of how to handle that.
const onDrop = useCallback(acceptedFiles => {
acceptedFiles.forEach(file => {
if (file.name.substr(file.name.length - 3) === 'csv') {
const reader = new FileReader();
reader.onabort = () => setError('file reading was aborted');
reader.onerror = () => setError('file reading has failed');
reader.onload = () => {
setFile(file);
};
reader.readAsArrayBuffer(file);
} else {
setError('Please choose a CSV file.');
}
});
}, []);
```
- Fetch All Employees
- Fetch Employees In The Logged-in User's Organization
- Fetch One Employee by ID
- Delete An Employee
- Edit An Employee
- Add An Employee
Retrieves data about every employee.
URL
/employees
Method:
GET
Success Response:
- Code: 200
Example Content:[ { "user_id": 1, "first_name": "Matt", "last_name": "Masters", "email": null, "profile_picture": "https://kansha-bucket.s3-us-west-1.amazonaws.com/avatarblank.png", "job_title": "Dev God", "user_type": "Admin", "department": "Department of Gods", "org_id": 1, "id": 1, "org_name": "IonQ" }, { "user_id": 2, "first_name": "Ty", "last_name": "Lippe", "email": null, "profile_picture": "https://kansha-bucket.s3-us-west-1.amazonaws.com/avatarblank.png", "job_title": "Dev Apprentice", "user_type": "Mod", "department": "Department of Devs", "org_id": 1, "id": 2, "org_name": "IonQ" }]
Error Response:
- Code: 500
Content:Employee List could not be retrieved from the database
Sample Call:
axiosWithAuth()
.get('/employees')
.then(response => {
console.log(response);
})
.catch(error => {
console.log(error.response);
});
URL
/employees/organizations
Method:
GET
Success Response: returns an array of employees as well as a count that represents the number of employees in the organization
- Code: 200
Example Content:{ "count": 1, "employees": [ { "id": 50, "first_name": "Joss", "last_name": "Stancek", "profile_picture": "https://kansha-bucket.s3-us-west-1.amazonaws.com/avatarblank.png", "job_title": "Dev Popcicle", "user_type": "Admin", "department": "Department of Popcicles", "org_name": "Kevin's Funhouse" } ] }
Error Response:
- Code: 500
Content:Employee List could not be retrieved from the database
Sample Call:
axiosWithAuth()
.get('/employees/organizations')
.then(response => {
console.log(response);
})
.catch(error => {
console.log(error.response);
});
URL
/employees/:id
Method:
GET
URL Params
Required:
id=[integer]
Success Response:
- Code: 200
Example Content:{ "user_id": 7, "first_name": "Andrew1", "last_name": "Ackerman", "email": null, "profile_picture": "https://kansha-bucket.s3-us-west-1.amazonaws.com/avatarblank.png", "job_title": "SoftwareDev", "user_type": "Admin", "department": "Software", "org_id": 15, "id": 9, "org_name": "Ionn" }
Error Response:
- Code: 500
Content:Employee could not be retrieved from the database
OR
if the id doesn't exist
- Code: 404
Content:There is no employee with that id
Sample Call:
axiosWithAuth()
.get('/employees/7')
.then(response => {
console.log(response);
})
.catch(error => {
console.log(error.response);
});
URL
/employees/:id
Method:
DELETE
URL Params
Required:
id=[integer]
Success Response:
- Code: 204
Error Response:
- Code: 500
Content:Error deleting employee
OR
if the id doesn't exist
- Code: 404
Content:There is no employee with that id
Sample Call:
axiosWithAuth()
.delete('/employees/7')
.then(response => {
console.log(response);
})
.catch(error => {
console.log(error.response);
});
URL
/employees/:id
Method:
EDIT
Data Params
-
Optional:
first_name(string)last_name(string)email(string) must be uniqueuser_type(string) should be "Admin" or "Standard"department(string)job_title(string)
URL Params
Required:
id=[integer]
Success Response:
- Code: 200
Content: returns the employee that was updated
Error Response:
- Code: 500
Content:Failed to Update the Employee
OR
if the id doesn't exist
- Code: 404
Content:There is no employee with that id
Sample Call:
axiosWithAuth()
.put('/employees/7')
.then(response => {
console.log(response);
})
.catch(error => {
console.log(error.response);
});
URL
/employees
Method:
POST
Data Params
-
Required:
first_name(string)last_name(string)email(string) must be uniqueuser_type(string) should be "Admin" or "Standard"
-
Optional:
department(string)job_title(string)
Success Response:
- Code: 201
Content: returns the added employee
Error Response:
- Code: 500
Content:Error adding user
OR
if first name, last name, or email weren't included in the post
- Code: 400
Content:You need to pass in first_name, last_name, and email
OR
if user type wasn't included in the post
- Code: 500
Content:Error adding user
Sample Call:
axiosWithAuth()
.post('/employees', {first_name: "Jane", last_name: "Smith", email: "jane@kansharewards.com", user_type: "Admin", department: "Sales", job_title: "manager"})
.then(response => {
console.log(response);
})
.catch(error => {
console.log(error.response);
});
Notes:
If you add an employee using an email address that is not already in the user database, then that user is added to the user database as well as the employee database
- Fetch All Organizations
- Add an Organization
- Fetch One Organization
- Edit an Organization
- Delete One Organization
Retrieves data about every organization.
URL
/organizations
Method:
GET
Success Response:
- Code: 200
Example Content:[{ "id": 2, "name": "Kevin's Funhouse" }, { "id": 12, "name": "Blurgh Company" }, { "id": 15, "name": "Ionn" }]
Error Response:
- Code: 500
Content:Error getting all orgs
Sample Call:
axiosWithAuth()
.get('/organizations')
.then(response => {
console.log(response);
})
.catch(error => {
console.log(error.response);
});
URL
/organizations
Method:
POST
Data Params
- Required:
name(string)
Success Response:
- Code: 201
Example Content: returns the org object that was just created
Error Response:
- Code: 500
Content:Error adding organization
OR
if you don't pass in the name property
- Code: 400
Content:Organization needs a name
Sample Call:
axiosWithAuth()
.post('/organizations', {name: "organization-name"})
.then(response => {
console.log(response);
})
.catch(error => {
console.log(error.response);
});
URL
/organizations/:id
Method:
GET
URL Params
Required:
id=[integer]
Success Response:
- Code: 200
Example Content: returns the org object that was just requested
Error Response:
- Code: 500
Content:Error getting org
OR
if the id you pass in doesn't match with any org in the database
- Code: 400
Content:there is no org with that id
OR
if you're trying to update an org that's not the org you're logged in with
- Code: 406
Content:Not Acceptable
URL
/organizations/:id
Method:
PUT
URL Params
Required:
id=[integer]
Data Params
-
Optional:
name(string)
Success Response:
- Code: 200
Example Content: returns the org object that was just updated
Error Response:
- Code: 500
Content:Failed to update the organization
OR
if the id you pass in doesn't match with any org in the database
- Code: 400
Content:there is no org with that id
OR
if you're trying to update an org that's not the org you're logged in with
- Code: 406
Content:Not Acceptable
URL
/organizations/:id
Method:
DELETE
URL Params
Required:
id=[integer]
Success Response:
- Code: 204
Example Content:Successfully deleted organization
Error Response:
- Code: 500
Content:Error Deleting org
OR
if the id you pass in doesn't match with any org in the database
- Code: 400
Content:there is no org with that id
OR
if you're trying to update an org that's not the org you're logged in with
- Code: 406
Content:Not Acceptable
URL
/feed
Method
GET
Data Params
- Required:
org_id(integer)
Success Response:
- Code: 200
Example Content: returns all recognitions belonging to the organization of the org_id provided
Error Response:
- Code: 500
URL
/feed/live
Method
GET
Data Params
- Required:
org_id(integer)
Success Response:
- Code: 200
Example Content: returns all live recognitions belonging to the organization of the org_id provided
- Get an Organizations Reports
- Get an Organizations Report for Top Thankers and Receivers
- Get an Organizations Report for Employee Engagement
- Get an Organizations Report for Recognition Count in given date range
URL
/reports
Method
GET
URL Params
Optional:
You can pass in "years" "months" or "weeks" to get how many recognitions were sent over that time period. It uses 'years' by default
time=[string]
Success Response:
- Code: 200
Example Content:5
Error Response:
- Code: 500
Sample Call:
axiosWithAuth()
.put('/reports?time=months')
.then(response => {
console.log(response);
})
.catch(error => {
console.log(error.response);
});
Notes:
The idea behind this endpoint is that the user can see how many people have sent or received thanks in the organization over a given time period. This can be useful for charts on the admin dashboard.
URL
/reports/top
Method
GET
URL Params
Optional:
You can pass in "years" "months" or "weeks" to get the top employees over that time period. It returns 'years' by default
time=[string]
You can pass in "recipient" or "sender" to get either the top thanked or the top thankful, respectively. By default it returns top thankful
type=[string]
You can pass in the number of employees you want to receive back
limit=[integer]
Success Response:
- Code: 200
Example Content:{ "count": 5, "employees": [{first_name: "Aaron", last_name: "Gillies", recipient: 47, profile_picture: "https://kansha-bucket.s3.us-west-1.amazonaws.com/1583441408751", count: "7"}, {first_name: "John", last_name: "Smith", recipient: 55, profile_picture: "https://kansha-bucket.s3.us-west-1.amazonaws.com/1583441408751", count: "5"}, {first_name: "Jane", last_name: "Johnson", recipient: 43, profile_picture: "https://kansha-bucket.s3.us-west-1.amazonaws.com/1583441408751", count: "4"}, {first_name: "Mark", last_name: "Cuban", recipient: 83, profile_picture: "https://kansha-bucket.s3.us-west-1.amazonaws.com/1583441408751", count: "3"}, {first_name: "Juliet", last_name: "Capulet", recipient: 34, profile_picture: "https://kansha-bucket.s3.us-west-1.amazonaws.com/1583441408751", count: "1"}] }
Error Response:
- Code: 500
Sample Call:
axiosWithAuth()
.put('/reports?time=months&type=sender&limit=5')
.then(response => {
console.log(response);
})
.catch(error => {
console.log(error.response);
});
URL
/reports/engagement
Method
GET
URL Params
Optional:
You can pass in "years" "months" or "weeks" to get percent of people engaged over that time period
time=[string]
You can pass in "recipient" or "sender" to get either the percent of people who received thanks or sent thanks respectively
person=[string]
Success Response:
- Code: 200
Example Content:{ "numberOfPeople": 2, "numberOfPeopleInOrg": 4, "percentThanked": 50 }
Error Response:
- Code: 500
Sample Call:
axiosWithAuth()
.put('/reports?time=months&person=sender')
.then(response => {
console.log(response);
})
.catch(error => {
console.log(error.response);
});
URL
/reports/range
Method
GET
URL Params
Optional:
You can pass in "years" "months" or "weeks" to get data over those time periods
time=[string]
Success Response:
- Code: 200
Example Content:{ "count": 10, "results": { "March": 4, "February": 3, "January": 2, "December": 0, "November": 1, "October": 0, "September": 0, "August": 0, "July": 0, "June": 0, "May": 0, "April": 0 } }
Error Response:
- Code: 500
URL
/profile/:id
Method
GET
URL Params
Required:
id=[integer]
Success Response:
-
Code: 200
Example Content: returns the user's profile datapeer: { "id": 1 "first_name": "Matt", "last_name": "Masters", "profile_picture": "https://kansha-bucket.s3-us-west-1.amzononaws.com/avatarblank.png", "job_title": "Dev God", "user_type": "Admin", "org_name": "Ion", "teams": [ { "team_id": 21, "name": "rockstars", "member_id": 12, "team_role": "manager" }, { "team_id": 23, "name": "winners", "member_id": 13, "team_role": "manager" } ], "rec":[ { "id":1, "recipeient": 1, "sender": 2. "message": "Go forth and be a God". "date": "2019-11-13T07:00:00.000Z", "badge_id": null, "org_id": 1, "first_name" "Ty", "last_name": "Lippe", "profile_pic": "https://kansha-bucket.s3-us-west-1.amzononaws.com/avatarblank.png" }, { "id":3, "recipeient": 3, "sender": 1. "message": "Go be a popsicle!". "date": "2019-11-13T07:00:00.000Z", "badge_id": null, "org_id": 1, "first_name" "Andrew", "last_name": "Maddocks", "profile_pic": "https://kansha-bucket.s3-us-west-1.amzononaws.com/avatarblank.png" }, ] }
Error Response:
- Code: 500
Example Content: error message
- Fetch Reactions for a given Recognition
- Post a Reaction for a given Recognition
- Delete a Reaction for a given Recognition
URL
/reactions/:rec_id
Method
GET
URL Params
Required:
rec_id=[integer]
Success Response:
- Code: 200
Example Content: returns the recognition's reactions
Error Response:
- Code: 500
Example Content: error message
Code: 404
Example Content: {message: 'reactions not found'}
URL
/reactions/
Method
POST
URL Params
Required:
rec_id=[integer]
Success Response:
- Code: 201
Example Content: returns the newly created reaction
Error Response:
- Code: 500
Example Content: error message
URL
/reactions/:id
Method
DELETE
URL Params
Required:
id=[integer]
Success Response:
- Code: 204
Error Response:
- Code: 500
Example Content: error message
- Fetch Comments for a given Recognition
- Post a new Comment for a given Recognition
- Delete a Comment for a given Recognition
URL
/comments/rec_id
Method
GET
URL Params
Required:
rec_id=[integer]
Success Response:
- Code: 200
Example Content: returns the recognition's comments
Error Response:
- Code: 500
Example Content: error message
Code: 404
Example Content: {message: 'post not found'}
URL
/comments/
Method
POST
Success Response:
- Code: 201
Example Content: returns the newly created comment
Error Response:
- Code: 500
Example Content: error message
URL
/comments/:id
Method
DELETE
Data Params
- Required:
rec_id(integer)id(integer)
Success Response:
- Code: 204
Error Response:
- Code: 500
Example Content: error message
URL
/badges/
Method
GET
Success Response:
- Code: 200
Example Content: returns an array of badges
Error Response:
- Code: 500
Example Content: error message
- Fetch All Recognitions
- Fetch All Recognitions in a given Organization
- Fetch One Recognition by recid
- Post a New Recognition
- Delete a Recognition by recid
- Edit a Recognition by recid
URL
/rec/
Method
GET
Success Response:
- Code: 200
Example Content: returns array of all recognitions
Error Response:
- Code: 500
Example Content: error message
URL
/rec/admin
Method
GET
Data Params
- Required:
org_id(integer)
Success Response:
- Code: 200
Example Content: returns array of organization's recognitions
Error Response:
- Code: 500
Example Content: {error: 'Recognition List could not be retrieved from the database'}
URL
/rec/:id
Method
GET
Success Response:
- Code: 200
Example Content: returns recognition
Error Response:
- Code: 500
Example Content: {error: 'Recognition List could not be retrieved from the database'}
Code: 404 Example Content: {message: 'post not found'}
URL
/rec/
Method
POST
Success Response:
- Code: 201
Example Content: returns newly created recognition
Error Response:
- Code: 500
Example Content: error message
URL
/rec/:id
Method
DELETE
Success Response:
- Code: 204
Error Response:
- Code: 500
Example Content: error message
URL
/rec/:id
Method
PUT
Success Response:
- Code: 200
Example Content: returns edited recognition
Error Response:
- Code: 500
Example Content: error message
URL
/profile-pic/
Method
POST
Success Response:
- Example Content: returns a json object with the picture url referencing the file location.
URL
/users/
Method
GET
Success Response:
- Code: 200
Example Content: returns array of all users
Error Response:
- Code: 500
Example Content: error message
URL
/users/:id
Method
GET
Success Response:
- Code: 200
Example Content: returns user object
Error Response:
- Code: 500
Example Content: error message
Code: 404 Example Content: {message: 'user not found'}
URL
/users/
Method
POST
Success Response:
- Code: 201
Example Content: returns newly created user
Error Response:
- Code: 500
Example Content: error message
URL
/users/:id
Method
DELETE
Success Response:
- Code: 204
Error Response:
- Code: 500
Example Content: error message
URL
/users/:id
Method
PUT
Success Response:
- Code: 200
Example Content: returns edited user
Error Response:
- Code: 500
Example Content: error message
Returns all teams and team members for an organization.
URL
/teams
Method:
GET
Success Response:
- Code: 200
Example Content:[{ "team_id": 21, "name": "rockstars", "count":7, "managers": [ { "member_id": 1, "user_id": 17, "first_name": "d", "last_name": "cluddles" }, { "member_id": 10, "user_id": 10, "first_name": "kevin", "last_name": "gilles" } ] }, { "team_id": 23, "name": "winners", "count":1, "managers": [ { "member_id": 5, "user_id": 13, "first_name": "kevin", "last_name": "gilles" } ] } ]
Error Response:
- Code: 500
Content: error: 'Teams could not be retrieved from the database'
Sample Call:
axiosWithAuth()
.get('/teams')
.then(response => {
console.log(response);
})
.catch(error => {
console.log(error.response);
});
Returns one team with team members.
URL
/teams/:id
Method:
GET
URL Params
Required:
id=[integer]
Success Response:
- Code: 200
Example Content:{"team_members": [ { "id": 1, "user_id": 17, "first_name": "d", "last_name": "cluddles", "profile_picture": "https://kansha-bucket.s3-us-west-1.amzononaws.com/avatarblank.png" }, { "id": 2, "user_id": 16, "first_name": "jessica", "last_name": "peter", "profile_picture": "https://kansha-bucket.s3-us-west-1.amzononaws.com/avatarblank.png" }, { "id": 3, "user_id": 15, "first_name": "jacey", "last_name": "san", "profile_picture": "https://kansha-bucket.s3-us-west-1.amzononaws.com/avatarblank.png" } ]}
Error Response:
- Code: 500
Content: error: 'Team could not be retrieved from the database'
Sample Call:
axiosWithAuth()
.get('/teams/21')
.then(response => {
console.log(response);
})
.catch(error => {
console.log(error.response);
});
Adds new team with multiple team members.
URL
/teams
Method:
POST
Data Params
Required:
Team name required.
name(string)
Optional:
To add multiple team members.
newMembersArray: [{"user_id": 15, "team_role": "manager"}, {"user_id": 18, "team_role": "member"}, {"user_id": 19, "team_role": "member"}]
Success Response:
- Code: 201
Example Content: "message": "Successfully added 3 members to team rockstars!"
Error Response:
-
Code: 400
Content: error: 'Team needs a name' -
Code: 500
Content: error: 'Error adding team'
Sample Call:
axiosWithAuth()
.post('/teams, {name: "team-name")
.then(response => {
console.log(response);
})
.catch(error => {
console.log(error.response);
});
Adds a new team member to a team
URL
/teams/:id
URL_PARAMS
Required:
team's id
id=[integer]
Data Params
Required:
user_id(integer)team_role(string)
Method:
POST
Success Response:
- Code: 200
Example Content:{ "id": 11, "user_id": 14, "team_id": 21, "team_role": "manager", "active": true, "team_name": "rockstars", "first_name": "vanessa", "last_name": "san", "profile_picture": "https://kansha-bucket.s3-us-west-1.amazonaws.com/avatarblank.png" }
Error Response:
- Code: 500
Content:error: 'Error adding member'
Sample Call:
axiosWithAuth()
.post('/teams/1', {"id": 1, "team_role": "manager"})
.then(response => {
console.log(response);
})
.catch(error => {
console.log(error.response);
});
Deletes a Team by ID and also deletes all team members on that team
URL
/teams/:id
URL_PARAMS
Required:
team's id
id=[integer]
Method:
DELETE
Success Response:
- Code: 200
Example Content:
Error Response:
- Code: 500
Content:
Sample Call:
axiosWithAuth()
.delete('/teams/1')
.then(response => {
console.log(response);
})
.catch(error => {
console.log(error.response);
});
Edits a team by ID
URL
/teams/:id
URL_PARAMS
Required:
team's id
id=[integer]
Method:
PUT
Success Response:
- Code: 200
Example Content:{ "id": 21, "name": "rockstars", "org_id": 1 }
Error Response:
-
Code: 500
Content:error: 'Failed to update Team'Sample Call:axiosWithAuth() .put('/teams/1') .then(response => { console.log(response); }) .catch(error => { console.log(error.response); });
Returns information for a team member
URL
/teams/members/:id
URL_PARAMS
Required:
team member's id
id=[integer]
Method:
GET
Success Response:
- Code: 200
Example Content:{ "id": 5, "user_id": 13, "team_id": 23, "team_role": "member", "active": false, "team_name": "winners", "first_name": "kevin", "last_name": "gillies", "profile_picture": "https://kansha-bucket.s3-us-west-1.amazonaws.com/avatarblank.png" }
Error Response:
- Code: 500
Content:error: 'Member could not be retrieved from the database'
Sample Call:
axiosWithAuth()
.get('/teams/members/1')
.then(response => {
console.log(response);
})
.catch(error => {
console.log(error.response);
});
Returns record of deleted team member
URL
/teams/members/:id
Method:
DELETE
Success Response:
- Code: 200
Example Content:1
Error Response:
- Code: 500
Content:error: 'Error Deleting team member'
Sample Call:
axiosWithAuth()
.delete('/teams/members/1')
.then(response => {
console.log(response);
})
.catch(error => {
console.log(error.response);
});
Returns edited team and team members
URL
teams/members/:id
URL_PARAMS
Required:
team member's id
id=[integer]
Method:
PUT
Success Response:
- Code: 200
Example Content:{ "id": 5, "user_id": 13, "team_id": 23, "team_role": "member", "active": false, "team_name": "winners", "first_name": "kevin", "last_name": "gillies" "profile_picture": "https://kansha-bucket.s3-us-west-1.amazonaws.com/avatarblank.png" }
Error Response:
-
Code: 500
Example Content: error: 'Failed to update Team Member'
Sample Call:axiosWithAuth() .put('/teams/members/1') .then(response => { console.log(response); }) .catch(error => { console.log(error.response); });