new_releases 更新:查看
版本说明,了解新功能和产品动态。
管理品牌
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
所有代理都属于某个品牌(企业、组织或群组)。在创建代理之前,您必须先创建拥有品牌。品牌只是一种组织方式,可帮助您将相关代理归为一组。
本页中的代码段摘自 Java 示例和 Node.js 示例。
创建品牌
您可以创建一个新品牌。如需了解详情,请参阅 brands
和 brands.create
。
Node.js
const businessCommunicationsApiHelper =
require('@google/rbm-businesscommunications');
const privateKey =
require('../../resources/businesscommunications-service-account-credentials.json');
businessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey);
businessCommunicationsApiHelper.createBrand('My new brand').then((response) => {
console.log('The new brand is:');
console.log(response.data);
}).catch((err) => {
console.log(err);
});
Java.js
String displayName = flags.getOrDefault("brand_name", "Test brand: " + now.getSecond());
Brand brand = api.createBrand(displayName);
logger.info("New brand id: " + brand.getName());
此代码会返回新的品牌名称 (displayName
) 和分配给品牌的唯一标识符 (name
):
{
name: 'brands/17456b6b-65dc-4e35-b128-fd3047664ddf',
displayName: 'My new brand'
}
检索品牌
您可以使用品牌的唯一标识符 (name
) 检索品牌的相关信息。如需了解详情,请参阅 brands.get
。
Node.js
const businessCommunicationsApiHelper =
require('@google/rbm-businesscommunications');
const privateKey =
require('../../resources/businesscommunications-service-account-credentials.json');
businessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey);
businessCommunicationsApiHelper.getBrand(brandId).then((response) => {
console.log('Brand details are:');
console.log(response.data);
}).catch((err) => {
console.log(err);
});
Java
Brand brand = api.getBrand(brandId);
logger.info("Brand: " + brand);
以下代码会返回品牌信息:
{
name: 'brands/17456b6b-65dc-4e35-b128-fd3047664ddf',
displayName: 'My new brand'
}
列出标识符
您可以检索您创建的所有品牌的列表。如需了解详情,请参阅 brands.list
。
Node.js
const businessCommunicationsApiHelper =
require('@google/rbm-businesscommunications');
const privateKey =
require('../../resources/businesscommunications-service-account-credentials.json');
businessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey);
businessCommunicationsApiHelper.listBrands().then((response) => {
console.log('Current brands available are:');
console.log(response.data);
}).catch((err) => {
console.log(err);
});
Java
List<Brand> brands = api.listBrands().stream().sorted(Comparator.comparing(Brand::getName))
.collect(Collectors.toList());
logger.info(String.format("Found %d brands", brands.size()));
for (Brand brand : brands) {
logger.info(String.format("Brand [%s]: '%s'", brand.getName(), brand.getDisplayName()));
}
以下代码会返回您的所有品牌的列表:
{
brands: [
{
name: 'brands/1deb6297-8a57-474a-a02c-48529a3de0a0',
displayName: 'My brand'
},
{
name: 'brands/3b607982-8c06-467a-96b8-020ddc26ac83',
displayName: 'My second brand'
},
{
name: 'brands/40bd963f-ff92-425c-b273-8f0892d2d017',
displayName: 'My thrd brand'
}
]
}
重命名品牌
您可以更改品牌的显示名称。如需了解详情,请参阅 brands.patch
。
您可以使用 patch
操作更改品牌的显示名称:
Node.js
const businessCommunicationsApiHelper =
require('@google/rbm-businesscommunications');
const privateKey =
require('../../resources/businesscommunications-service-account-credentials.json');
businessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey);
businessCommunicationsApiHelper
.patchBrand(brand.name, 'My brand new name').then((response) => {
console.log(response.data);
});
以下代码会返回更新后的品牌信息:
{
name: 'brands/40bd963f-ff92-425c-b273-8f0892d2d017',
displayName: 'My brands new name'
}
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-01-16。
[null,null,["最后更新时间 (UTC):2025-01-16。"],[[["\u003cp\u003eBrands serve as organizational structures for grouping related agents within the system.\u003c/p\u003e\n"],["\u003cp\u003eNew brands can be created using the provided Node.js and Java code examples, which return a unique identifier and the brand's display name.\u003c/p\u003e\n"],["\u003cp\u003eInformation about a specific brand can be retrieved using its unique identifier through the provided code snippets.\u003c/p\u003e\n"],["\u003cp\u003eA list of all created brands can be obtained using the \u003ccode\u003elistBrands\u003c/code\u003e function, with examples provided in both Node.js and Java.\u003c/p\u003e\n"],["\u003cp\u003eThe display name of an existing brand can be modified using the \u003ccode\u003epatchBrand\u003c/code\u003e function, demonstrated with a Node.js example.\u003c/p\u003e\n"]]],[],null,["# Manage brands\n\nAll agents belong to a brand (business, organization, or group). Before an agent\ncan be created, it's necessary to create an owning brand. Brands are purely\norganizational to help you group related agents together.\n\nCode snippets on this page are taken from the [Java samples](https://github.com/rcs-business-messaging/rbm-api-examples/tree/master/java/rbm-mgmt-api)\nand [Node.js samples](https://github.com/rcs-business-messaging/rbm-api-examples/tree/master/nodejs/rbm-mgmt-api).\n\nCreate a brand\n--------------\n\nYou can create a new brand. For more details,\nsee [`brands`](/business-communications/rcs-business-messaging/reference/business-communications/rest/v1/brands)\nand [`brands.create`](/business-communications/rcs-business-messaging/reference/business-communications/rest/v1/brands/create). \n\n### Node.js\n\n```javascript\nconst businessCommunicationsApiHelper =\n require('@google/rbm-businesscommunications');\n\nconst privateKey =\n require('../../resources/businesscommunications-service-account-credentials.json');\n\nbusinessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey);\n\nbusinessCommunicationsApiHelper.createBrand('My new brand').then((response) =\u003e {\n\tconsole.log('The new brand is:');\n\tconsole.log(response.data);\n}).catch((err) =\u003e {\n\tconsole.log(err);\n});\n```\n\n### Java.js\n\n```javascript\nString displayName = flags.getOrDefault(\"brand_name\", \"Test brand: \" + now.getSecond());\nBrand brand = api.createBrand(displayName);\nlogger.info(\"New brand id: \" + brand.getName());\n```\n\nThis code returns the new brand name (`displayName`) and a unique identifier\n(`name`) assigned to the brand: \n\n {\n name: 'brands/17456b6b-65dc-4e35-b128-fd3047664ddf',\n displayName: 'My new brand'\n }\n\nRetrieve a brand\n----------------\n\nYou can retrieve information about a brand using its unique identifier (`name`).\nFor more details, see [`brands.get`](/business-communications/rcs-business-messaging/reference/business-communications/rest/v1/brands/get). \n\n### Node.js\n\n```javascript\nconst businessCommunicationsApiHelper =\n require('@google/rbm-businesscommunications');\n\nconst privateKey =\n require('../../resources/businesscommunications-service-account-credentials.json');\n\nbusinessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey);\n\nbusinessCommunicationsApiHelper.getBrand(brandId).then((response) =\u003e {\n console.log('Brand details are:');\n console.log(response.data);\n}).catch((err) =\u003e {\n console.log(err);\n});\n```\n\n### Java\n\n```java\nBrand brand = api.getBrand(brandId);\nlogger.info(\"Brand: \" + brand);\n```\n\nThis code returns the brand information: \n\n {\n name: 'brands/17456b6b-65dc-4e35-b128-fd3047664ddf',\n displayName: 'My new brand'\n }\n\nList brands\n-----------\n\nYou can retrieve a list of all the brands you have created. For more details,\nsee [`brands.list`](/business-communications/rcs-business-messaging/reference/business-communications/rest/v1/brands/list). \n\n### Node.js\n\n```javascript\nconst businessCommunicationsApiHelper =\n require('@google/rbm-businesscommunications');\n\nconst privateKey =\n require('../../resources/businesscommunications-service-account-credentials.json');\n\nbusinessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey);\n\nbusinessCommunicationsApiHelper.listBrands().then((response) =\u003e {\n console.log('Current brands available are:');\n console.log(response.data);\n}).catch((err) =\u003e {\n console.log(err);\n});\n```\n\n### Java\n\n```java\nList\u003cBrand\u003e brands = api.listBrands().stream().sorted(Comparator.comparing(Brand::getName))\n .collect(Collectors.toList());\nlogger.info(String.format(\"Found %d brands\", brands.size()));\nfor (Brand brand : brands) {\n logger.info(String.format(\"Brand [%s]: '%s'\", brand.getName(), brand.getDisplayName()));\n}\n```\n\nThis code returns a list of all your brands: \n\n {\n brands: [\n {\n name: 'brands/1deb6297-8a57-474a-a02c-48529a3de0a0',\n displayName: 'My brand'\n },\n {\n name: 'brands/3b607982-8c06-467a-96b8-020ddc26ac83',\n displayName: 'My second brand'\n },\n {\n name: 'brands/40bd963f-ff92-425c-b273-8f0892d2d017',\n displayName: 'My thrd brand'\n }\n ]\n }\n\nRename a brand\n--------------\n\nYou can change the brand's display name. For more details, see [`brands.patch`](/business-communications/rcs-business-messaging/reference/business-communications/rest/v1/brands/patch).\n\nThe brand's display name can be changed using the `patch` operation: \n\n### Node.js\n\n```javascript\nconst businessCommunicationsApiHelper =\n require('@google/rbm-businesscommunications');\n\nconst privateKey =\n require('../../resources/businesscommunications-service-account-credentials.json');\n\nbusinessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey);\n\nbusinessCommunicationsApiHelper\n .patchBrand(brand.name, 'My brand new name').then((response) =\u003e {\n console.log(response.data);\n});\n```\n\nThis code returns the updated brand information: \n\n {\n name: 'brands/40bd963f-ff92-425c-b273-8f0892d2d017',\n displayName: 'My brands new name'\n }"]]