# PingCAP Account API 文档

## 说明

> 所有的 API 调用都有频率限制，未认证用户 30 次/分钟, 认证用户 100 次/分钟，超出调用频率会返回 HTTP-Status-Code 429  

> i18n支持(zh-hans/en-us), 在请求 Header 中声明： Accept-Language: zh-hans  

> 当 cookie 中有 csrftoken 时, put|post|delete|patch 等请求需在 header 中声明: X-CSRFTOKEN  

> 以下 API 文档中均未提及 5xx 错误, 但你在使用 API 的时候应考虑到相关错误(包括网络延时)  


- [申请加入 TUG](#申请加入-TUG)


### 申请加入 TUG

#### Request

- Method: **POST**
- URL: `/api/tug/applications`
- Content-Type: application/json
- Permission: Authenticated User
- Body:

  ```json
  {
    "real_name" : "daivd",  // 必填, 真实姓名, 2 ~ 20 个字符
    "phone": "136xxxxxxxx", // 必填, 手机号, 后端仅在用户个人信息不存在手机号时校验合法性
    "email": "wa***@163.com", // 必填, 邮箱, 后端仅在用户个人信息不存在邮箱时校验合法性
    "company_name": "北京平凯星辰科技发展有限公司",  // 必填, 公司名称, 后端仅在用户未加入公司时校验合法性
    "job_title": "d2bcq9UIf", // 必填, 职位名称, 代码参考: https://gist.github.com/wd0517/c5d407f165b6a0485cbc66d6acaa47ae
    "stage_of_company_use_of_tidb": "",  // 必填, 公司对 TiDB 的使用处于什么阶段
    "reason_for_application": "", // 必填, 加入 TUG 的原因, 5 ~ 500 个字符
    "preferred_way_of_sharing": [""], // 必填, 更倾向于哪些分享方式
    "roles_want_to_play": [""], // 必填, 希望担任的角色
    "wechat_id": "",  // 必填, 微信 ID, 2 ~ 25 个字符
    "bio": "",  // 非必填, 个人介绍, 5 ~ 200 个字符
    "channel": ["PingCAP Education", "TUG 企业行"], // 非必填, 在哪得知 TUG
    "referrer": "", // 非必填, 推荐人, 2 ~ 10 个字符
  }
  ```

#### Response

- Success

  - HTTP/1.1 200

    ```json
    {
      "detail": "success",
    }
    ```

- Failed

  - HTTP/1.1 400

    ```json
    {
      "detail": "something wrong",
      "errors":{
        "real_name": [ "this feild is required" ],
        "email": [ "invalid email address" ]
      }
    }
    ```

  - HTTP/1.1 401

    ```json
    {
      "detail": "Authentication credentials were not provided"
    }
    ```

  - HTTP/1.1 409  用户已经提交过申请，或者已经加入 TUG 了

    ```json
    {
      "detail": "You have successfully applied for TUG membership, please do not submit information repeatedly"
    }
    ```

    ```json
    {
      "detail": "Your membership application is under review, please do not submit information repeatedly"
    }
    ```

