遍历客户组

  1. 请求地址:GET /customer_groups

  2. 接口概述:

    遍历客户组下的客户列表。

  3. 请求参数:

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

    如何遍历?

  4. 请求体:

  5. 请求示例:

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

    {
       "status": 0,
       "data": {
           "total": 2,
           "items": [
               {
                   "name": "group_0"
               },
               {
                   "name": "group_1"
               }
           ]
       }
    }

    响应体说明

查询客户组

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

  2. 接口概述:

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

  3. 请求参数:

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

    如何遍历?

  4. 请求体:

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

    如何查询?

    querys

    支持:name

    sorts

    支持:name

    参数说明

  5. 请求示例

    POST /bitanswer/api/customer_groups/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": [
                   "group%"
               ]
           }
       ],
       "sorts": [
           {
               "name": "name"
           }
       ]
    }
  6. 响应示例

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

    响应体说明

创建客户组

  1. 请求地址:POST /customer_groups

  2. 接口概述:

    创建客户组,已存在则跳过。

  3. 请求参数:

  4. 请求体:

    参数名 参数类型 参数说明 必需 备注
    name string 客户组名

    参数说明

  5. 请求示例:

    POST /bitanswer/api/customer_groups HTTP/1.1
    Host: back-office-api.bitanswer.cn
    Content-Type: application/json
    bitkey: ••••••
    
    {
       "name": "test_group"
    }
  6. 响应示例:

    {
       "status": 0,
       "data": {
           "items": [
               {
                   "name": "test_group"
               }
           ]
       }
    }

    响应体说明

按客户组名查询客户组

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

  2. 接口概述:

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

  3. 请求参数:

    地址参数

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

  5. 请求示例:

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

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

    响应体说明

按客户组名更新客户组

  1. 请求地址:

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

    按客户组名查找指定客户组,进行更新。

    PATCH 方法和POST 方法都用于更新客户组名,首先根据客户组名查找指定客户组,若客户组不存在则报错;若客户组存在则修改客户组名。

  3. 请求参数:

    地址参数

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

    参数名 参数类型 参数说明 必需 备注
    name string 客户组名

    参数说明

  5. 请求示例:

    PATCH /bitanswer/api/customer_groups/{name} HTTP/1.1
    Host: back-office-api.bitanswer.cn
    Content-Type: application/json
    bitkey: ••••••
    
    {
       "name": "new_group_name"
    }
  6. 响应示例:

    {
       "status": 0,
       "data": {
           "items": [
               {
                   "name": "new_group_name"
               }
           ]
       }
    }

    响应体说明

按客户组名删除客户组

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

  2. 接口概述:

    根据客户组名删除指定客户组。客户组下存在客户时不可删除。

  3. 请求参数:

    地址参数

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

  5. 请求示例:

    DELETE /bitanswer/api/customer_groups/{name} HTTP/1.1
    Host: back-office-api.bitanswer.cn
    bitkey: ••••••
  6. 响应示例:

    {
       "status": 0,
       "data": {
           "items": [
               {
                   "name": "group_to_delete"
               }
           ]
       }
    }

    响应体说明

遍历客户组下的客户

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

  2. 接口概述:

    遍历指定客户组下的客户。

  3. 请求参数:

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

    如何遍历?

    地址参数

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

  5. 请求示例:

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

    {
       "status": 0,
       "data": {
           "total": 2,
           "items": [
               {
                   "name": "customer_0",
                   "groupName": "group_test"
               },
               {
                   "name": "customer_1",
                   "groupName": "group_test"
               }
           ]
       }
    }

    响应体说明

添加客户到客户组

  1. 请求地址:POST /customer_groups/{name}/customers

  2. 接口概述:

    将客户添加到指定客户组。

  3. 请求参数:

    地址参数

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

    参数名 参数类型 参数说明 必需 备注
    name string 客户名
    groupName string 原客户组

    请求体以数组形式输入。

    参数说明

  5. 请求示例:

    POST /bitanswer/api/customer_groups/{name}/customers HTTP/1.1
    Host: back-office-api.bitanswer.cn
    Content-Type: application/json
    bitkey: ••••••
    
    [
       {
           "name": "customer_0",
           "groupName": "客户组名"
       },
       {
           "name": "customer_1",
           "groupName": "客户组名"
       }
    ]
  6. 响应示例:

    {
       "status": 0,
       "data": {
           "items": [
               {
                   "name": "customer_0",
                   "groupName": "group_test"
               },
               {
                   "name": "customer_1",
                   "groupName": "group_test"
               }
           ]
       }
    }

    响应体说明

从客户组移除客户

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

  2. 接口概述:

    将客户从指定客户组移除。

  3. 请求参数:

    地址参数

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

    参数名 参数类型 参数说明 必需 备注
    name string 客户名
    groupName string 客户组名

    请求体以数组形式输入。

    参数说明

  5. 请求示例:

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

    {
       "status": 0,
       "data": {
           "items": [
               {
                   "name": "customer_0"
               },
               {
                   "name": "customer_1"
               }
           ]
       }
    }

    响应体说明