# 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 的时候应考虑到相关错误(包括网络延时)

- [合作伙伴-认证列表](#合作伙伴-认证列表)
- [合作伙伴申请-发送验证码](#合作伙伴申请-发送验证码)
- [合作伙伴申请-提交](#合作伙伴申请-提交)
- [合作伙伴申请-列表](#合作伙伴申请-列表)
- [合作伙伴申请-详情](#合作伙伴申请-详情)

### 合作伙伴-认证列表

#### Request

- Method: **GET**
- URL: `/api/partner/compatibility-certifications`
- Permission: Authenticated User
- Params:

  | 字段    | 类型 | 必填 | 说明 |
  | -------- | -------- | -------- | -------- |
  | currentPage | int   | 非必填     | 页码, 默认 1 |
  | perPage | int   | 非必填     | 每页条数, 默认 10 |
  | search | string   | 非必填     | 搜索关键字 |

#### Response Example

- Success

  - HTTP/1.1 200

    ```json
    {
        "detail": "success",
        "data": [
            {
                "number": "S148230704",
                "company": "pingcap",
                "compatible_database_version": "平凯数据库企业版软件[简称：TiDB]V7.1",
                "solution_type": "平凯星辰应用联合解决方案互认证",
                "status": "approved",
                "status_display": "approved",
                "created_at": "2025-05-20 17:32:06",
                "cert_valid_from": "2023-07-04",
                "cert_valid_to": "2025-07-03"
            }
        ],
        "total_num": 1,
        "per_page": 10,
        "cur_page": 1
    }
    ```

### 合作伙伴申请-发送验证码

#### Request

- Method: **POST**
- URL: `/api/partner/compatibility-certifications/applications/send-sms-code`
- Content-Type: application/json
- Permission: Authenticated User
- Body

  ```json
  {
    "phone" : "136xxxxxxxx",  // 手机号, 必填
  }
  ```

#### Response Example

- Success

  - HTTP 200 发送成功

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

- Failed

  - HTTP 400 参数错误

    ```json
    {
      "detail": "params error",
      "errors": {
          "phone": ["this field is required"],  // 键是传入的名参数; 值是一个数组, 其中包含了具体的错误信息
      }
    }
    ```

  - HTTP 429 频率限制, 同一手机号, 1 分钟内只能发送一次验证码

    ```json
    {
      "detail": "rate limit"
    }
    ```

### 合作伙伴申请-提交

#### Request

- Method: **POST**
- URL: `/api/partner/compatibility-certifications/applications`
- Content-Type: multipart/form-data
- Permission: Authenticated User
- Body:

  | 字段    | 类型 | 必填 | 说明 |
  | -------- | -------- | -------- | -------- |
  | company  | string   | 必填     | 公司名称，最多 100 字 |
  | company_address  | string   | 必填     | [公司地址](https://gist.github.com/wd0517/c5d407f165b6a0485cbc66d6acaa47ae#file-pingcap_crm_options-txt-L61)   |
  | contact_name | string   | 必填     | 联系人姓名，最多 100 字 |
  | contact_phone | string   | 必填     | 联系人手机号，11 位 |
  | phone_code | string   | 必填     | 联系人手机号验证码，6 位 |
  | contact_email | string   | 必填     | 联系人邮箱 |
  | contact_job_title | string   | 必填     | [联系人职务](https://github.com/pingcap-inc/account/blob/f984a266bf6681dd434195f912b0e818f86fcb05/src/pingcap_sso/utils/crm.py#L19) |
  | product_name | string   | 必填     | 产品名称，最多 100 字 |
  | product_description | string   | 必填     | 产品描述，最多 200 字 |
  | purpose_of_certification | string   | 必填     | 认证用途，最多 100 字 |
  | shipping_address | string   | 必填     | 证书邮寄地址，最多 200 字 |
  | solution_type | string   | 必填     | [解决方案类型](https://github.com/pingcap-inc/account/blob/6699102a951d6d164a0370ea9089af89c265a171/src/pingcap_sso/utils/crm.py#L428) |
  | product_industry | string   | 必填     | [应用行业](https://github.com/pingcap-inc/account/blob/6699102a951d6d164a0370ea9089af89c265a171/src/pingcap_sso/utils/crm.py#L434) |
  | compatible_database_version | string   | 必填     | [兼容数据库版本](https://github.com/pingcap-inc/account/blob/6699102a951d6d164a0370ea9089af89c265a171/src/pingcap_sso/utils/crm.py#L454) |
  | infra_category | string   | solution_type 为 "ke76LBbs7" 时必填     | [基础设施分类](https://github.com/pingcap-inc/account/blob/6699102a951d6d164a0370ea9089af89c265a171/src/pingcap_sso/utils/crm.py#L460) |
  | attachment_1 | 文件   | 必填     | 必须为 doc、docx 文件，限制 20M 大小 |
  | company_logo | 图片文件 | 必填     | 必须为图片文件，限制 20M 大小 |
  | cert_owner_name | string   | 必填     | 合作伙伴证书负责人姓名，最多 100 字 |
  | cert_owner_job_title | string   | 必填     | 合作伙伴证书负责人职务|

#### Response Example

- Success
  - HTTP/1.1 200

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

- Failed

  - HTTP/1.1 400

    ```json
    {
      "detail": "params error",
      "errors": {
        "company_address": [ "this field is required" ],  // 键是传入的名参数; 值是一个数组, 其中包含了具体的错误信息
        "phone_code": [ "this field is required" ],
      }
    }
    ```

### 合作伙伴申请-列表

#### Request

- Method: **GET**
- URL: `/api/partner/compatibility-certifications/applications`
- Permission: Authenticated User
- Params:

  | 字段    | 类型 | 必填 | 说明 |
  | -------- | -------- | -------- | -------- |
  | currentPage | int   | 非必填     | 页码, 默认 1 |
  | perPage | int   | 非必填     | 每页条数, 默认 10 |

#### Response Example

- Success
  - HTTP/1.1 200

    ```json
    {
        "detail": "success",
        "data": [
            {
                "number": "AP202505202024021181",
                "company": "pingcap",
                "status": "pending",
                "status_display": "pending",
                "staff_comment": null,
                "created_at": "2025-05-20 20:24:03"
            },
            {
                "number": "AP202505201732051237",
                "company": "pingcap",
                "status": "approved",
                "status_display": "approved",
                "staff_comment": null,
                "created_at": "2025-05-20 17:32:06"
            }
        ],
        "total_num": 2,
        "per_page": 10,
        "cur_page": 1
    }
    ```

### 合作伙伴申请-详情

#### Request

- Method: **GET**
- URL: `/api/partner/compatibility-certifications/applications/<application_number>`
- Permission: Authenticated User

#### Response Example

- Success
  - HTTP/1.1 200

    ```json
    {
      "detail": "success",
      "data": {
      "number": "AP202506271500124275",
      "company": "pingcap",
      "company_address": "河北",
      "contact_name": "wd",
      "contact_phone": "138888888",
      "contact_email": "example@pingcap.com",
      "contact_job_title": "2G3agrmyP",
      "product_name": "product name 1",
      "product_description": "desc",
      "purpose_of_certification": "purpose",
      "shipping_address": "shipping_address",
      "solution_type": "ke76LBbs7",
      "product_industry": "Bn80Skg3C",
      "compatible_database_version": "EfFmza3Nr",
      "infra_category": "option_ecosystem_tool__c",
      "cert_owner_name": "owner",
      "cert_owner_job_title": "CEO",
      "attachment_1": "/api/partner/compatibility-certifications/applications/AP202506271500124275/attachment-1",
      "company_logo": "/api/partner/compatibility-certifications/applications/AP202506271500124275/company-logo",
      "status": "rejected",
      "staff_comment": "用于测试使用"
      }
    }
    ```

- Failed
  - HTTP/1.1 404

    ```json
    {
      "detail": "application not found"
    }
    ```
