Marken verwalten

Alle Agents gehören zu einer Marke (Unternehmen, Organisation oder Gruppe). Bevor ein Agent erstellt werden kann, muss eine Inhabermarke erstellt werden. Marken sind rein organisatorisch und helfen Ihnen, verwandte Agents zu gruppieren.

Die Code-Snippets auf dieser Seite stammen aus den Java- und Node.js-Beispielen.

Marke erstellen

Sie können eine neue Marke erstellen. Weitere Informationen finden Sie unter siehe brands und 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'
  }"
Dieser Code ist ein Auszug aus unserem RBM Management API-Beispiel.

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

String displayName = flags.getOrDefault("brand_name", "Test brand: " + now.getSecond());
Brand brand = api.createBrand(displayName);
logger.info("New brand id: " + brand.getName());

Dieser Code gibt den neuen Markennamen (displayName) und eine eindeutige ID (name) zurück, die der Marke zugewiesen wurde:

{
  name: 'brands/17456b6b-65dc-4e35-b128-fd3047664ddf',
  displayName: 'My new brand'
}

Marke abrufen

Sie können Informationen zu einer Marke mit ihrer eindeutigen ID (name) abrufen. Weitere Informationen finden Sie unter 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`"
Dieser Code ist ein Auszug aus unserem RBM Management API-Beispiel.

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);

Dieser Code gibt die Markeninformationen zurück:

{
  name: 'brands/17456b6b-65dc-4e35-b128-fd3047664ddf',
  displayName: 'My new brand'
}

Marken auflisten

Sie können eine Liste aller von Ihnen erstellten Marken abrufen. Weitere Informationen finden Sie unter 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`"
Dieser Code ist ein Auszug aus unserem RBM Management API-Beispiel.

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()));
}

Dieser Code gibt eine Liste aller Ihrer Marken zurück:

{
  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'
    }
  ]
}

Marke umbenennen

Sie können den Anzeigenamen der Marke ändern. Weitere Informationen finden Sie unter brands.patch.

Der Anzeigename der Marke kann mit dem Vorgang patch geändert werden:

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);
});

Dieser Code gibt die aktualisierten Markeninformationen zurück:

{
  name: 'brands/40bd963f-ff92-425c-b273-8f0892d2d017',
  displayName: 'My brands new name'
}