owned this note
owned this note
Published
Linked with GitHub
---
tags: api文件
---
{%hackmd QnyEFBdERZebn4iQDXNPnA %}
# Task_management api
# Get Token
**Base URL:https://dodo.gill.gq/api**
**URI = Base URL + endpoint**
**example:
https://dodo.gill.gq/api/userToken**
## Request表
| 編號 | method | endpoint | 說明 |
| -------- | -------- | -------- |-----
| 1 | POST | userToken | 輸入帳密取得Token驗證碼
| 2 | POST | register | 註冊帳號密碼
## 1. POST Token 取得token驗證碼
### request
- **URL**
https://dodo.gill.gq/api/userToken
- **method**
POST
- **header**
```json=
{
"Content-Type" : "application/json"
}
```
- **body**
```json=
{
"password":"00000000",
"email" : "ishida624@gmail.com"
}
```
### response
- **status code 200**
```json=
{
"status": true,
"login_data": {
"userToken": "Kno0kILecxEGdic"
}
}
```
- **status code 400**
```json=
{
"status": false,
"error": "email or password false"
}
```
## 2. POST register 註冊帳號密碼
### request
- **URL**
https://dodo.gill.gq/api/register
- **method**
POST
- **header**
```json=
{
"Content-Type" : "application/json"
}
```
- **body**
```json=
{
"username": "admin",
"password":"00000000",
"email" : "ishida624@gmail.com"
}
```
### response
- **status code 201**
```json=
{
"status": true
}
```
- **status code 400 (此帳號已存在)**
```json=
{
"status": false,
"error": "This account already exists"
}
```
- **status code 400** (帳號或密碼格式錯誤)
```json=
{
"status": false,
"error": "username can not over 16 characters. The password format is invalid. The email must be a valid email address."
}
```
## 3.Get forget password(忘記密碼)
> 說明:
> 使用這支api後,成功會寄出email,內有連結,點入後會將密碼改為a00000000,請使用者登入後自行修改密碼
### request
- **URL:** https://dodo.gill.gq/api/forget/password/{email}
- **method:**
GET
- **header**
N/A
- **body**
N/A
### response
- **status code 200**
```json=
{
"status": true
}
```
- **status code 400**
```json=
{
"status": false,
"error": "email false"
}
```
## 3.Google oauth login (google第3方登入)
> 說明:
> 請前端輸入idToken登入
### request
- **URL:** https://dodo.gill.gq/api/google/oauth/login
- **method:**
POST
- **header**
N/A
- **body**
```json=
{
"idToken":"XXX"
}
```
### response
- **status code 200**
```json=
{
"status": true,
"login_data": {
"userToken": "fQzrAEFjc6brUDY"
}
}
```
- **status code 400**
idToken不符合jwt格式時會有此錯誤
```json=
{
"status": false,
"message": "idToken is invalid"
}
```
- **status code 400**
當使用google登入,email已經被使用則會有此錯誤
```json=
{
"status": false,
"message": "This email is already exists"
}
```
---
# Card
**Base URL:https://dodo.gill.gq/api/**
**URI = Base URL + endpoint**
**example:
https://dodo.gill.gq/api/card**
## Request表
編號 | method | endpoint |說明
--|--| -----|----
1| GET | card | 列出 cards
2| POST | card | 新增 card
3| GET | card/{id} | 查詢 card
4| PUT/PATCH | card/{id} |更新
5| DELETE | card/{id} | 刪除
## 1. GET all card (列出所有todos)
### request
- **URL**
https://dodo.gill.gq/api/card
- **method**
GET
- ### header
```json=
{
"Content-Type" : "application/json",
"userToken" : "userToken"
}
```
https://dodo.gill.gq/api/userToken body.data內取得
- ### body
N/A
### Response
<br>
**response範例(jason):**
- **status code 200:**
```json=
{
"status": true,
"user_data": {
"id": 1,
"username": "admin",
"email": "ishida624@gmail.com",
"image": null,
"created_at": "2020-09-04T15:38:22.000000Z",
"updated_at": "2020-09-04T16:15:00.000000Z",
"show_cards": [
{
"id": 1,
"card_name": "hahaha",
"create_user": "admin",
"created_at": "2020-09-04T16:17:53.000000Z",
"updated_at": "2020-09-04T16:17:53.000000Z",
"private": false,
"pivot": {
"users_id": 1,
"card_id": 1
},
"show_tasks": [
{
"id": 1,
"title": "task1",
"status": false,
"create_user": "admin",
"update_user": "admin",
"description": null,
"tag": null,
"image": null,
"card_id": 1,
"created_at": "2020-09-04T16:22:13.000000Z",
"updated_at": "2020-09-04T16:22:13.000000Z"
}
]
}
]
}
}
```
- **status code 401**
```json=
{
"status": false,
"error": "token false"
}
```
- **status code 401**
```json=
{
"status": false,
"error": "token out time"
}
```
<br>
## 2. POST card (新增card)
## request
- **URL**
https://dodo.gill.gq/api/card
- **method**
POST
- ### header
```json=
{
"Content-Type" : "application/json",
"userToken" : "userToken"
}
```
https://dodo.gill.gq/api/userToken body.data內取得
- ### body
**title範例(jason):**
```json=
{
"card_name":"card name"
}
```
## response
- **status code 201:**
```json=
{
"status": true,
"card_data": {
"card_name": "card2",
"create_user": "admin",
"private": true,
"updated_at": "2020-09-04T16:34:32.000000Z",
"created_at": "2020-09-04T16:34:32.000000Z",
"id": 3
}
}
```
- **status code 400:**
```json=
{
"status": false,
"error": "card_name can not null."
}
```
- **status code 400:**
```json=
{
"status": false,
"error": "title can not over 255 characters"
}
```
- **status code 401**
```json=
{
"status": false,
"error": "token false"
}
```
- **status code 401**
```json=
{
"status": false,
"error": "token out time"
}
```
<br>
## 3. GET card (用id查詢card)
## request
- **URL**
https://dodo.gill.gq/api/card/{id}
- **method**
GET
- ### header
```json=
{
"Content-Type" : "application/json",
"userToken" : "userToken"
}
```
- ### body
N/A
https://dodo.gill.gq/api/userToken body.data內取得
## response
- **status code 200**
```json=
{
"status": true,
"card_data": {
"id": 10,
"card_name": "card",
"create_user": "admin",
"private": true,
"created_at": "2020-09-04T15:55:43.000000Z",
"updated_at": "2020-09-04T15:55:43.000000Z",
"pivot": {
"users_id": 2,
"card_id": 10
},
"show_tasks": []
}
}
```
- **status code 401**
```json=
{
"status": false,
"error": "token false"
}
```
- **status code 401**
```json=
{
"status": false,
"error": "token out time"
}
```
<br>
## 4. PUT card (更新card)
## request
- **URL**
https://dodo.gill.gq/api/card/{id}
- **method**
PUT
- ### header
```json=
{
"Content-Type" : "application/json",
"userToken" : "userToken"
}
```
https://dodo.gill.gq/api/userToken body.data內取得
- ### body
**範例(json):**
```json=
{
"card_name" : "card name"
}
```
## response
- **status code 200**
```json=
{
"status": true,
"card_data": {
"id": 10,
"card_name": "card name",
"create_user": "admin",
"created_at": "2020-09-04T15:55:43.000000Z",
"updated_at": "2020-09-07T05:16:49.000000Z",
"private": false,
"pivot": {
"users_id": 2,
"card_id": 10
},
"show_tasks": []
}
}
```
- **status code 400:**
```json=
{
"status": false,
"error": "card_name can not null."
}
```
- **status code 400:**
```json=
{
"status": false,
"error": "title can not over 255 characters"
}
```
- **status code 400:**
```json=
{
"status": false,
"error": "card serch not found"
}
```
- **status code 401**
```json=
{
"status": false,
"error": "token false"
}
```
- **status code 401**
```json=
{
"status": false,
"error": "token out time"
}
```
<br>
## 5. DELETE card (刪除card)
## request
- **URL**
https://dodo.gill.gq/api/card/{id}
- **method**
DELETE
- ### header
```json=
{
"Content-Type" : "application/json",
"userToken" : "userToken"
}
```
https://dodo.gill.gq/api/userToken body.data內取得
- ### body
N/A
## response
```json=
{
"status": true
}
```
- **status code 400**
```json=
{
"status": false,
"error": "card serch not found"
}
```
- **status code 401**
```json=
{
"status": false,
"error": "token false"
}
```
- **status code 401**
```json=
{
"status": false,
"error": "token out time"
}
```
----
# Task
**Base URL:https://dodo.gill.gq/api/**
**URI = Base URL + endpoint**
**example:
https://dodo.gill.gq/api/task**
## request表
編號 | method | endpoint |說明
--|--| -----|----
1| GET | task | 列出 tasks
2| POST | task | 新增 task
3| PUT/PATCH | task/{id} |更新
4| DELETE | task/{id} | 刪除
5| POST | task/upload/{id} | 上傳圖片
## 1. GET task (列出所有 tasks)
### request
- **URL**
https://dodo.gill.gq/api/task
- **method**
GET
- **header**
```json=
{
"Content-Type" : "application/json",
"userToken" : "userToken"
}
```
https://dodo.gill.gq/api/userToken body.data內取得
- **body**
NA
### response
- **status code 200**
```json=
{
"status": true,
"task_data": [
{
"id": 2,
"titel": "task1",
"status": false,
"create_user": "admin",
"update_user": "admin",
"description": null,
"tag": null,
"image": null,
"card_id": 10,
"created_at": "2020-09-07T05:31:09.000000Z",
"updated_at": "2020-09-07T05:31:09.000000Z"
},
{
"id": 3,
"title": "task2",
"status": false,
"create_user": "admin",
"update_user": "admin",
"description": null,
"tag": null,
"image": null,
"card_id": 10,
"created_at": "2020-09-07T07:12:25.000000Z",
"updated_at": "2020-09-07T07:12:25.000000Z"
}
]
}
```
- **status code 401**
```json=
{
"status": false,
"error": "token false"
}
```
- **status code 401**
```json=
{
"status": false,
"error": "token out time"
}
```
## 2. POST task (新增 tasks)
### request
- **URL**
https://dodo.gill.gq/api/task
- **method**
POST
- **header**
```json=
{
"Content-Type" : "multipart/form-data",
"userToken" : "userToken"
}
```
https://dodo.gill.gq/api/userToken body.data內取得
- **body(multipart/form-data)**
範例:
| Key | value | 說明 | type |
| -------- | -------- | -------- |----
| card_id | 1 | 新增在哪個card(必填)| int |
| image | XXX.jpeg | 上傳圖片 | file |
| title | task_name | 標題 | string |
| tag | red | 標記顏色 | string |
| description | task內容 | 填入task內容 | string |
**必填項目:card_id**
### request
- **status code 200**
```json=
{
"status": "true",
"task_data": {
"title": "task5",
"status": false,
"create_user": "admin",
"update_user": "admin",
"description": null,
"tag": "red",
"image": null,
"card_id": "12",
"updated_at": "2020-09-07T08:36:31.000000Z",
"created_at": "2020-09-07T08:36:31.000000Z",
"id": 9
}
}
```
- **status code 400 (card_id 輸入錯誤)**
```json=
{
"status": true,
"error": "card serch not found"
}
```
- **status code 400 (title輸入超過40位元)**
```json=
{
"status": false,
"error": "The title may not be greater than 40 characters."
}
```
- **status code 400 (description輸入超過255位元)**
```json=
{
"status": false,
"error": "The description may not be greater than 255 characters."
}
```
- **status code 401**
```json=
{
"status": false,
"error": "token false"
}
```
- **status code 401**
```json=
{
"status": false,
"error": "token out time"
}
```
## 3. PUT task (更新 tasks)
### request
- **URL**
https://dodo.gill.gq/api/task/{task_id}
- **method**
PUT
- **header**
```json=
{
"Content-Type" : "multipart/form-data",
"userToken" : "userToken"
}
```
https://dodo.gill.gq/api/userToken body.data內取得
- **body**
範例:
| Key | value | 說明 |type
| -------- | -------- | -------- |---
| card_id | 1 | 移動到哪個card 1| int |
| image | XXX.jpeg | 上傳圖片 | file |
| title | task_name | 更改標題 | string|
| tag | red | 標記顏色 | string|
| description | task內容 | 填入task詳細內容 | string|
| delete_image | true | 刪除當前task的圖片 | boolean|
- 補充
因為multipart/form-data無法使用PUT method,若用POSTMAN測試,請使用POST method,並再下面參數加上
| key | value |
| -------- | -------- |
| _method | PUT |
### response
- **status code 200**
```json=
{
"status": true,
"task_data": {
"id": 10,
"title": "task7",
"status": false,
"create_user": "admin",
"update_user": "admin",
"description": "create test",
"tag": "green",
"image": null,
"card_id": "10",
"created_at": "2020-09-09T03:24:48.000000Z",
"updated_at": "2020-09-09T03:39:47.000000Z"
}
}
```
- **status code 400 (card_id 輸入錯誤)**
```json=
{
"status": true,
"error": "card serch not found"
}
```
- **status code 400 (title輸入超過40位元)**
```json=
{
"status": false,
"error": "The title may not be greater than 40 characters."
}
```
- **status code 400 (description輸入超過255位元)**
```json=
{
"status": false,
"error": "The description may not be greater than 255 characters."
}
```
- **status code 400 (status必須為布林值)**
```json=
{
"status": false,
"error": "The status field must be true or false."
}
```
- **status code 401**
```json=
{
"status": false,
"error": "token false"
}
```
- **status code 401**
```json=
{
"status": false,
"error": "token out time"
}
```
## 4. DELETE task (刪除 tasks)
### request
- **URL**
https://dodo.gill.gq/api/task/{task_id}
- **method**
DELETE
- **header**
```json=
{
"Content-Type" : "application/json",
"userToken" : "userToken"
}
```
https://dodo.gill.gq/api/userToken body.data內取得
- **body**
N/A
### request
- **status code 200**
```json=
{
"status": true
}
```
- **status code 400**
```json=
{
"status": true,
"error": "task search not found"
}
```
- **status code 401**
```json=
{
"status": false,
"error": "token false"
}
```
- **status code 401**
```json=
{
"status": false,
"error": "token out time"
}
```
## 5. GET image in task (看在task中的圖片)
### request
**domain:**
https://dodo.gill.gq
https://storage.googleapis.com/gcs.gill.gq
**endpoint 範例:**
/images/task/2020-10-12_12:35:04_task269.jpeg
endpoint 請從 GET Task中的imgae欄位取得
**URL = domain + endponit**
- **method** : GET
- **header** : N/A
- **body** : N/A
### response
- **body**
File
# User
**Base URL:https://dodo.gill.gq/api/**
**URI = Base URL + endpoint**
**example:
https://dodo.gill.gq/api/user**
## request表
編號 | method | endpoint |說明
--|--| -----|----
1| GET | user/{email} | 使用email 查詢 user data
2| PUT/PATCH | user | 更新username、password
3| DELETE | user/image | 刪除user頭像
4| POST | user/upload | 上傳user頭像
## 1. GET user (使用email 查詢 user data)
### request
- **URI**
https://dodo.gill.gq/api/user/{email}
- **method**
GET
- **header**
```json=
{
"Content-Type" : "application/json",
"userToken" : "userToken"
}
```
https://dodo.gill.gq/api/userToken body.data內取得
- **body**
N/A
### response
- **status 200**
```json=
{
"status": true,
"user_data": {
"id": 3,
"username": "gill",
"email": "gill@gmail.com",
"image": "",
"created_at": "2020-09-15T04:01:19.000000Z",
"updated_at": "2020-09-18T09:20:10.000000Z"
}
}
```
## 2. PUT user (更新 user name、password)
### request
- **URI**
https://dodo.gill.gq/api/user
- **method**
PUT
- **header**
```json=
{
"Content-Type" : "application/json",
"userToken" : "userToken"
}
```
https://dodo.gill.gq/api/userToken body.data內取得
- **body**
範例:
```json=
{
"username":"gill",
"password":"00000000"
}
```
### response
- **status 200**
```json=
{
"status": true
}
```
- **status 400 (密碼必須超過8位元,以及必須是0-9 a-z)**
```json=
{
"status": false,
"error": "password should over 8 characters and only 0-9,a-z,A-Z. "
}
```
- **status 400 (user name 最多16位元)**
```json=
{
"status": false,
"error": "username can not over 16 characters. "
}
```
## 3. POST user/image (新增 user 頭像)
### request
- **URI**
https://dodo.gill.gq/api/user/image
- **method**
POST
- **header**
```json=
{
"Content-Type" : "multipart/form-data",
"userToken" : "userToken"
}
```
https://dodo.gill.gq/api/userToken body.data內取得
- **body**
| key | value | type |
| -------- | -------- | -------- |
| image | XXX.jpeg | file |
### response
- **status 200**
```json=
{
"status": true
}
```
- **status 400(圖片上傳失敗,可能是沒帶image參數)**
```json=
{
"status": false,
"error": "upload error"
}
```
## 4. DELETE user/image (刪除 user 頭像)
### request
- **URI**
https://dodo.gill.gq/api/user/image
- **method**
DELETE
- **header**
```json=
{
"Content-Type" : "application/json",
"userToken" : "userToken"
}
```
https://dodo.gill.gq/api/userToken body.data內取得
- **body**
N/A
### response
- **status 200**
```json=
{
"status": true
}
```
---
# Groups
**Base URL:https://dodo.gill.gq/api/**
**URI = Base URL + endpoint**
**example:
https://dodo.gill.gq/api/groups**
## request表
編號 | method | endpoint |說明
--|--| -----|----
1| GET | groups/card/users/{card_id} | 輸入card_id查詢該card的所有使用者
2| POST | groups/{card_id} | 新增user進來card
3| DELETE | groups/{card_id} | 將user踢出card
## 1. GET card users (查詢該card的所有使用者)
### request
- **URI**
https://dodo.gill.gq/api/groups/card/users/{card_id}
- **method**
GET
- **header**
```json=
{
"Content-Type" : "application/json",
"userToken" : "userToken"
}
```
https://dodo.gill.gq/api/userToken body.data內取得
- **body**
NA
### response
- **status 200**
```json=
{
"status": true,
"users_data": [
{
"id": 2,
"username": "admin",
"email": "ishida624@gmail.com",
"image": null,
"created_at": "2020-09-02T08:07:20.000000Z",
"updated_at": "2020-09-21T07:54:41.000000Z",
"pivot": {
"card_id": 1,
"users_id": 2
}
},
{
"id": 3,
"username": "gill",
"email": "gill@gmail.com",
"image": "",
"created_at": "2020-09-15T04:01:19.000000Z",
"updated_at": "2020-09-22T03:45:15.000000Z",
"pivot": {
"card_id": 1,
"users_id": 3
}
}
]
}
```
- **status 400(卡片id輸入錯誤)**
```json=
{
"status": false,
"error": "card search not found"
}
```
## 2. POST user into card (新增user進來card)
### request
- **URI**
https://dodo.gill.gq/api/groups/{card_id}
- **method**
POST
- **header**
```json=
{
"Content-Type" : "application/json",
"userToken" : "userToken"
}
```
https://dodo.gill.gq/api/userToken body.data內取得
- **body 範例**
```json=
{
"email":"gill@gmail.com"
}
```
### response
- **status 200**
```json=
{
"status": true,
"group_data": {
"users_id": 2,
"card_id": "1",
"updated_at": "2020-09-21T08:44:05.000000Z",
"created_at": "2020-09-21T08:44:05.000000Z",
"id": 19
}
}
```
- **status 400(user_id 輸入錯誤)**
```json=
{
"status": false,
"error": "user search not found"
}
```
- **status 400(card_id 輸入錯誤)**
```json=
{
"status": false,
"error": "card search not found"
}
```
- **status 400(該使用者已再card裏面)**
```json=
{
"status": false,
"error": "user is already in card"
}
```
## 3. DELETE user form card (將user踢出card)
### request
- **URI**
https://dodo.gill.gq/api/groups/{card_id}
- **method**
DELETE
- **header**
```json=
{
"Content-Type" : "application/json",
"userToken" : "userToken"
}
```
https://dodo.gill.gq/api/userToken body.data內取得
- **body 範例**
```json=
{
"user_id":2
}
```
### response
- **status 200**
```json=
{
"status": true
}
```
- **status 400(user_id 輸入錯誤)**
```json=
{
"status": false,
"error": "user search not found"
}
```
- **status 400(card_id 輸入錯誤)**
```json=
{
"status": false,
"error": "card search not found"
}
```
- **status 400(你不能刪除卡片擁有者)**
```json=
{
"status": false,
"error": "you can not delete card owner"
}
```