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
) 和指派給品牌的專屬 ID (name
):
{
name: 'brands/17456b6b-65dc-4e35-b128-fd3047664ddf',
displayName: 'My new brand'
}
擷取品牌
您可以使用品牌的專屬 ID (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'
}
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-01-16 (世界標準時間)。
[null,null,["上次更新時間: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 }"]]