# Edcess API Doc
API doc for cloud functions.
Click [here](https://hackmd.io/oXZyE6j9RL6JNIZxD5R_YQ) for tutor registration API. Tutor registration API is public and shared with the wordpress developers.
# App
## Authentication
Firebase auth.
## Tutor
### Retrieve Tutor Statistics
Retrieves the average rating and number of questions answered for a given tutor.
Type: `firebase.functions().httpsCallable("getTutorStats")`
```
getTutorStats
```
Request
Data (required), type: `json`
```json
{
"userId" : "abc123"
}
```
Response payload:
```javascript
{
averageRating : 4.32,
questionsAnswered : 5
}
```
### receiveLead(tutorId): Receive Interest
Receive interest from student
Data required:
```
{
"tuto"
}
```
## Users
### Get User
URL: `/admin_api/users`
No parameters
Returns
```json
[
{
"email": "ler@abc.com",
"id": "d45nYpdZs5fhwtNYFsN9Jnnmcch1",
"role": "Student",
"username": "hellowhat",
"credits": 500
},
{
"email": "edi@abc.com",
"id": "lGy85fprblUOAMD6nzBaAOcH0vQ2",
"role": "Tutor",
"username": "alibaba"
"credits": 300
}
]
```
### Change role
URL
```
POST /admin_api/users/role
```
Request Payload
```json
{
"userId" : "d45nYpdZs5fhwtNYFsN9Jnnmcch1",
"requestType" : "toStudent"
}
```
`requestType` can be either. `toStudent` or `toTutor`
### Update tutor
Currently only support patching of `isMOE` field. Toggles the `isMOE` field on and off.
If a user is not a tutor, return 400 error.
URL:
```
PATCH /admin_api/users/tutors
```
Response
200
```json
Changed isMOE for tutor: AL8F7uWvL6QFhrXrR8ZJEr19Zto1
```