遍历客户

  1. 请求地址:GET /customers

  2. 接口概述:

    遍历客户数据。

  3. 请求参数:

    参数名 参数类型 参数说明 必需 备注
    offset integer 响应结果起始下标 默认0
    limit integer 响应结果的数量 默认50,最大1000

    如何遍历?

  4. 请求体:

  5. 请求示例:

    GET /bitanswer/api/customers HTTP/1.1
    Host: back-office-api.bitanswer.cn
    bitkey: ••••••
  6. 响应示例:

    {
       "status": 0,
       "data": {
           "total": 79,
           "items": [
               {
                   "name": "unitTest_customer_0",
                   "groupName": "group_name",
                   "regDate": "2023-10-23 14:49:05"
               },
               {
                   "name": "unitTest_customer_1",
                   "regDate": "2023-10-24 13:27:51",
                   "address": "unitTest_haidian",
                   "referenceId": "100"
               }
           ]
       }
    }

    响应体说明

查询客户

  1. 请求地址:POST /customers/data

  2. 接口概述:

    根据限定的条件查询、排序符合的客户。

  3. 请求参数:

    参数名 参数类型 参数说明 必需 备注
    offset integer 响应结果起始下标 默认0
    limit integer 响应结果的数量 默认50,最大1000

    如何遍历?

  4. 请求体:

    参数名 参数类型 参数说明 必需 备注
    querys array 查询参数
    sorts array 排序参数

    如何查询?

    querys

    支持:namegroupName

    sorts

    支持:name

    参数说明

  5. 请求示例

    POST /bitanswer/api/sns/data?offset={offset}&limit={limit} HTTP/1.1
    Host: back-office-api.bitanswer.cn
    Content-Type: application/json
    bitkey: ••••••
    
    {
       "querys": [
           {
               "name": "name",
               "op": "like",
               "values": [
                   "bitanswer%",
                   "test%"
               ]
           }
       ],
       "sorts": [
           {
               "name": "name"
           }
       ]
    }
  6. 响应示例

    {
       "status": 0,
       "data": {
           "total": 1,
           "items": [
               {
                   "name": "bitanswer1",
                   "description": "",
                   "regDate": "2023-10-25 10:13:43",
                   "officeNumber": "11111111111",
                   "referenceId": "0001"
               },
               {
                   "name": "test0",
                   "description": "",
                   "regDate": "2023-10-25 12:13:15",
                   "city": "北京",
                   "country": "中国",
                   "referenceId": "1001"
               }
           ]
       }
    }

    响应体说明

批量更新/添加客户

  1. 请求地址:

    • PATCH /customers
    • POST /customers
  2. 接口概述:

    按客户名和客户组名查找指定的客户,进行更新/添加客户。

    PATCH 方法用于部分更新数据,首先根据客户名和客户组名查找指定客户,若客户不存在则报错;若客户存在则执行更新操作,仅对请求中明确输入的内容进行修改,其他内容保持原有值不变。

    POST 方法用于新增或全量重置数据,首先根据客户名和客户组名查找指定客户,若客户不存在则进行添加(并关联指定的客户组);若客户存在则执行全量重置操作,会以请求中输入的内容覆盖原有值,未输入内容则被置为空值。(不推荐用于部分更新数据,易导致未输入数据被误清空)

  3. 请求参数:

  4. 请求体:

    参数名 参数类型 参数说明 必需 备注
    name string 客户名
    groupName string 客户组名 客户有组时需要传指定客户组名,没有组则不传
    description string 说明
    officeNumber string 电话
    mobileNumber string 手机
    email string 邮件地址
    address string 地址
    city string 城市
    country string 国家/地区
    postcode string 邮政编码
    contact string 联系人
    referenceId string 编号

    参数说明

    请求体以数组形式输入。

  5. 请求示例:

    PATCH /bitanswer/api/customers HTTP/1.1
    Host: back-office-api.bitanswer.cn
    Content-Type: application/json
    bitkey: ••••••
    
    [
       {
           "name":"unitTest_customer_0",
           "city":"shanghai",
           "mobileNumber":"xxxxxxxxxxx"
       }
    ]
  6. 响应示例:

    {
       "status": 0,
       "data": {
           "total": 1,
           "items": [
               {
                   "name": "unitTest_customer_0",
                   "description": "",
                   "regDate": "2024-08-15 10:47:46",
                   "officeNumber": "",
                   "mobileNumber": "xxxxxxxxxxx",
                   "email": "",
                   "address": "",
                   "city": "shanghai",
                   "country": "",
                   "postcode": "",
                   "contact": "",
                   "referenceId": "0001"
               }
           ]
       }
    }

    响应体说明

批量删除客户

  1. 请求地址:DELETE /api/customers

  2. 接口概述:

    批量删除客户。

  3. 请求参数:

  4. 请求体:

    参数名 参数类型 参数说明 必需 备注
    name string 客户名
    groupName string 客户组名 客户有组时需要传指定客户组名,没有组则不传

    请求体以数组形式输入。

  5. 请求示例:

    DELETE /bitanswer/api/customers HTTP/1.1
    Host: back-office-api.bitanswer.cn
    Content-Type: application/json
    bitkey: ••••••
    
    [
       {"name": "unit_customer_0", "groupName": "group_name"},
       {"name": "unit_customer_1"}
    ]
  6. 响应示例:

    {
       "status": 0,
       "data": {
           "total": 1,
           "items": [
               {
                   "name": "unit_customer_0"
               },
               {
                   "name": "unit_customer_1"
               }
           ]
       }
    }

按客户名查询客户

  1. 请求地址:GET /customers/customer/{name}

  2. 接口概述:

    根据客户名称和客户组名查询指定客户。

  3. 请求参数:

    参数名 参数类型 参数说明 必需 备注
    groupName string 客户组名 客户有组时需要传指定客户组名,没有组则不传

    地址参数

    参数名 参数类型 参数说明 必需 备注
    name string 客户名
  4. 请求体:

  5. 请求示例:

    GET /bitanswer/api/customers/customer/{name}?groupName={groupName} HTTP/1.1
    Host: back-office-api.bitanswer.cn
    bitkey: ••••••
  6. 响应示例:

    {
       "status": 0,
       "data": {
           "total": 1,
           "items": [
               {
                   "name": "unit_customer",
                   "description": "description",
                   "regDate": "2024-08-14 17:25:46",
                   "address": "beijing"
               }
           ]
       }
    }

    响应体说明

按客户名更新/添加客户

  1. 请求地址:

    • PATCH /customers/customer/{name}
    • POST /customers/customer/{name}
  2. 接口概述:

    按客户名和客户组名查找指定的客户,进行更新/添加客户。

    PATCH 方法用于部分更新数据,首先根据客户名和客户组名查找指定客户,若客户不存在则报错;若客户存在则执行更新操作,仅对请求中明确输入的内容进行修改,其他内容保持原有值不变。

    POST 方法用于新增或全量重置数据,首先根据客户名和客户组名查找指定客户,若客户不存在则进行添加(并关联指定客户组);若客户存在则执行全量重置操作,会以请求中输入的内容覆盖原有值,未输入内容则被置为空值。(不推荐用于部分更新数据,易导致未输入数据被误清空)

  3. 请求参数:

    地址参数

    参数名 参数类型 参数说明 必需 备注
    name string 客户名
  4. 请求体:

    参数名 参数类型 参数说明 必需 备注
    name string 客户名
    groupName string 客户组名 客户有组时需要传指定客户组名,没有组则不传
    description string 说明
    officeNumber string 电话
    mobileNumber string 手机
    email string 邮件地址
    address string 地址
    city string 城市
    country string 国家/地区
    postcode string 邮政编码
    contact string 联系人
    referenceId string 编号

    参数说明

  5. 请求示例:

    PATCH /bitanswer/api/customers/customer/{name} HTTP/1.1
    Host: back-office-api.bitanswer.cn
    bitkey: ••••••
    
    {
       "officeNumber":"xxx-xxx-xxx",
       "mobileNumber":"15515515515",
       "email":"email@qq.com",
       "city":"beijing",
       "postcode":"100000"
    }
  6. 响应示例:

    {
       "status": 0,
        "data": {
           "total": 1,
           "items": [
               {
                   "name": "unit_customer",
                   "description": "description",
                   "regDate": "2024-08-14 19:24:47",
                   "officeNumber": "xxx-xxx-xxx",
                   "mobileNumber": "15515515515",
                   "email": "email@qq.com",
                   "address": "beijing",
                   "city": "beijing",
                   "postcode": "100000"
               }
           ]
       }
    }

    响应体说明

按客户名删除客户

  1. 请求地址:DELETE /customers/customer/{name}

  2. 接口概述:

    根据客户名和客户组名删除指定客户。

  3. 请求参数:

    参数名 参数类型 参数说明 必需 备注
    groupName string 客户组名 客户有组时需要传指定客户组名,没有组则不传

    地址参数

    参数名 参数类型 参数说明 必需 备注
    name string 客户名
  4. 请求体:

  5. 请求示例:

    DELETE /bitanswer/api/customers/customer/{name}?groupName={groupName} HTTP/1.1
    Host: back-office-api.bitanswer.cn
    bitkey: ••••••
  6. 响应示例:

    {
       "status": 0,
       "data": {
           "total": 1,
           "items": [
               {
                   "name": "unit_customer",
                   "groupName": "groupName"
               }
           ]
       }
    }

    响应体说明