ब्रैंड मैनेज करें

सभी एजेंट किसी ब्रैंड (कारोबार, संगठन या ग्रुप) से जुड़े होते हैं. एजेंट बनाने से पहले, मालिकाना हक वाला ब्रैंड बनाना ज़रूरी है. ब्रैंड पूरी तरह से संगठन के हिसाब से होते हैं. इनकी मदद से, मिलते-जुलते एजेंट को एक साथ ग्रुप किया जा सकता है.

इस पेज पर दिए गए कोड स्निपेट, 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'
}