ينتمي جميع الوكلاء إلى علامة تجارية (مؤسسة أو منظمة أو مجموعة). قبل إنشاء وكيل، من الضروري إنشاء علامة تجارية مالكة. العلامات التجارية هي علامات تنظيمية بحتة لمساعدتك في تجميع الوكلاء ذوي الصلة معًا.
تم أخذ مقتطفات التعليمات البرمجية في هذه الصفحة من عيّنات Java و عيّنات Node.js.
إنشاء علامة تجارية
يمكنك إنشاء علامة تجارية جديدة. لمزيد من التفاصيل،
يُرجى الاطّلاع على brands
و brands.create.
cURL
curl -v -X POST "https://businesscommunications.googleapis.com/v1/brands" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-messaging" \ -H "`oauth2l header --json rbm-developer-service-account-credentials.json businesscommunications`" \ -d "{ 'name': 'Test Brand', 'displayName': 'Test Brand' }"
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); });
جافا
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.
cURL
curl -v "https://businesscommunications.googleapis.com/v1/$BRAND_ID" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-messaging" \ -H "`oauth2l header --json rbm-developer-service-account-credentials.json businesscommunications`"
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); });
جافا
Brand brand = api.getBrand(brandId); logger.info("Brand: " + brand);
تعرض هذه التعليمات البرمجية معلومات العلامة التجارية:
{
name: 'brands/17456b6b-65dc-4e35-b128-fd3047664ddf',
displayName: 'My new brand'
}
إدراج العلامات التجارية
يمكنك استرداد قائمة بجميع العلامات التجارية التي أنشأتها. لمزيد من التفاصيل،
يُرجى الاطّلاع على brands.list.
cURL
curl -v "https://businesscommunications.googleapis.com/v1/brands" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-messaging" \ -H "`oauth2l header --json rbm-developer-service-account-credentials.json businesscommunications`"
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); });
جافا
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'
}