Code Monkey home page Code Monkey logo

vt-todo-list's Introduction

vt-todo-list API接口

API 列表

  • get all to-do lists
  • get one to-do list
  • create one to-do list
  • update one to-do list
  • delete one to-do list
  • delete all to-do list
  • generate a new token
  • get token status (Only if tokens with TTL or RefreshToken)

API 規格

:: 取得 Auth Token

  • 使用方式

    POST /api/token

  • 參數

    Body

    email=[string]

    password=[string]

  • 範例

curl -X POST \
  -H 'Content-Type: application/json' \
  -d '{"email":"[email protected]","password":"Dnm97Katf5R6adax"}'     https://vt.liweitw.com/api/token
  • 結果
{
    "token": "751274df-4bc2-4634-b6b5-a23465045e60"
}

:: 檢查 Auth Token 有效性

  • 使用方式

    POST /api/token/{token}

  • 參數

    URL

    token=[string]

  • 範例

curl --request GET \
  --url https://vt.liweitw.com/api/token/7fbc201c-d073-4093-9515-831c1acd151d
  • 結果
{
    "isValid": true,
    "userId": 1,
    "expiredAt": "2019-04-06T05:54:17+00:00"
}

:: 建立一筆 Todo

  • 使用方式

    POST /api/todo/

  • 參數

    Header

    todo-token=[string]

    Body

    title=[string]

    content=[string]

    attachment=[string]

  • 範例

curl --request POST \
  --url https://vt.liweitw.com/api/todo \
  --header 'todo-token: 7fbc201c-d073-4093-9515-831c1acd151d' \
  --form 'title=買牛奶' \
  --form 'content=冰箱沒牛奶了,要買兩罐' \
  --form 'attachment=https://zh.wikipedia.org/wiki/%E7%89%9B%E5%A5%B6#/media/File:Milk_glass.jpg'
  • 結果
{
    "data": [
        {
            "id": 1,
            "user_id": 1,
            "title": "買牛奶",
            "content": "冰箱沒牛奶了,要買兩罐",
            "attachment": "https://zh.wikipedia.org/wiki/%E7%89%9B%E5%A5%B6#/media/File:Milk_glass.jpg",
            "done_at": 0,
            "deleted_at": null,
            "created_at": "2019-03-30 06:07:51",
            "updated_at": "2019-03-30 06:07:51"
        }
    ]
}

:: 取得特定 Todo

  • 使用方式

    GET /api/todo/{todo_id}

  • 參數

    URL

    todo_id=[string]

    Header

    todo-token=[string]

  • 範例

curl --request GET \
  --url https://vt.liweitw.com/api/todo/1 \
  --header 'todo-token: 7fbc201c-d073-4093-9515-831c1acd151d'
  • 結果
{
    "data": {
        "id": 1,
        "user_id": 1,
        "title": "買牛奶",
        "content": "冰箱沒牛奶了,要買兩罐",
        "attachment": "https://zh.wikipedia.org/wiki/%E7%89%9B%E5%A5%B6#/media/File:Milk_glass.jpg",
        "done_at": 0,
        "deleted_at": null,
        "created_at": "2019-03-30 06:07:51",
        "updated_at": "2019-03-30 06:07:51"
    }
}

:: 取得所有 Todo

  • 使用方式

    GET /api/todo/

  • 參數

    Header

    todo-token=[string]

  • 範例

curl --request GET \
  --url https://vt.liweitw.com/api/todo \
  --header 'todo-token: 7fbc201c-d073-4093-9515-831c1acd151d'
  • 結果
{
    "data": [
        {
            "id": 1,
            "user_id": 1,
            "title": "買牛奶",
            "content": "冰箱沒牛奶了,要買兩罐",
            "attachment": "https://zh.wikipedia.org/wiki/%E7%89%9B%E5%A5%B6#/media/File:Milk_glass.jpg",
            "done_at": 0,
            "deleted_at": null,
            "created_at": "2019-03-30 06:07:51",
            "updated_at": "2019-03-30 06:07:51"
        }
    ]
}

:: 更新特定 Todo

  • 使用方式

    POST /api/todo/{todo_id}

  • 參數

    URL

    todo_id=[string]

    Header

    todo-token=[string]

    Body

    title=[string]

    content=[string]

    attachment=[string]

    dontAt=[timestamp]

  • 範例

curl --request POST \
  --url https://vt.liweitw.com/api/todo/1 \
  --header 'todo-token: 7fbc201c-d073-4093-9515-831c1acd151d' \
  --form 'title=要買咖啡豆' \
  --form 'content=買一包' \
  --form 'attachment=https://zh.wikipedia.org/wiki/%E5%92%96%E5%95%A1#/media/File:A_small_cup_of_coffee.JPG' \
  --form doneAt=1553926743
  • 結果
{
    "hasSuccess": true,
    "data": {
        "id": 1,
        "user_id": 1,
        "title": "要買咖啡豆",
        "content": "買一包",
        "attachment": "https://zh.wikipedia.org/wiki/%E5%92%96%E5%95%A1#/media/File:A_small_cup_of_coffee.JPG",
        "done_at": "1553926743",
        "deleted_at": null,
        "created_at": "2019-03-30 06:07:51",
        "updated_at": "2019-03-30 06:20:24"
    }
}

:: 刪除特定 Todo

  • 使用方式

    DELETE /api/todo/{todo_id}

  • 參數

    URL

    todo_id=[string]

    Header

    todo-token=[string]

  • 範例

curl --request DELETE \
  --url https://vt.liweitw.com/api/todo/1 \
  --header 'todo-token: 7fbc201c-d073-4093-9515-831c1acd151d'
  • 結果
{
    "hasSuccess": true,
    "data": {
        "id": 1,
        "user_id": 1,
        "title": "要買咖啡豆",
        "content": "買一包",
        "attachment": "https://zh.wikipedia.org/wiki/%E5%92%96%E5%95%A1#/media/File:A_small_cup_of_coffee.JPG",
        "done_at": 1553926743,
        "deleted_at": null,
        "created_at": "2019-03-30 06:07:51",
        "updated_at": "2019-03-30 06:20:24"
    }
}

:: 刪除所有 Todo

  • 使用方式

    DELETE /api/todo/

  • 參數

    URL

    todo_id=[string]

    Header

    todo-token=[string]

  • 範例

curl --request DELETE \
  --url https://vt.liweitw.com/api/todo/ \
  --header 'todo-token: 7fbc201c-d073-4093-9515-831c1acd151d'
  • 結果
{
    "deleted": 2
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.