@adobe/spacecat-shared-brand-client
v1.1.34
Published
Shared modules of the Spacecat Services - Brand Client
Maintainers
Keywords
Readme
Spacecat Shared - Brand Client
A JavaScript client for the Brand API, part of the SpaceCat Shared library. It allows you to query brand information and guidelines with in the given IMS Org.
Installation
Install the package using npm:
npm install @adobe/spacecat-shared-brand-clientUsage
Constructor
import BrandClient from '@adobe/spacecat-shared-brand-client';
const config = {
apiKey: '<API_KEY>',
apiBaseUrl: '<API_BASE_URL>',
};
const client = new BrandClient(config, log);Creating an instance from Helix UniversalContext
const context = {
env: {
BRAND_API_BASE_URL: '<API_BASE_URL>',
BRAND_API_KEY: '<API_KEY>',
}
}; // Your Helix Universal context object
const client = BrandClient.createFrom(context);Methods
getBrandsForOrganization(imsOrgId, imsAccessToken)
Retrieves brands associated with an IMS organization.
const brands = await client.getBrandsForOrganization('org123', 'ims-access-token');
// Returns array of Brand objects:
// [{
// id: 'brand-id',
// name: 'Brand Name',
// imsOrgId: 'org123',
// createdAt: '2024-03-01T00:00:00.000Z',
// updatedAt: '2024-03-01T00:00:00.000Z'
// }]
#### getBrandGuidelines(brandConfig, imsOrgId, imsConfig)
Retrieves brand guidelines for the given brand and IMS Org.
```js
const imsConfig = {
host: 'ims-host',
clientId: 'client-id',
clientCode: 'client-code',
clientSecret: 'client-secret'
};
const brandConfig = {
brandId: 'brand123',
userId: 'user123'
};
const guidelines = await client.getBrandGuidelines(brandConfig, 'org123', imsConfig);
// Returns BrandGuidelines object:
// {
// id: 'brand123',
// name: 'Brand Name',
// imsOrgId: 'org123',
// createdAt: '2024-03-01T00:00:00.000Z',
// updatedAt: '2024-03-01T00:00:00.000Z',
// toneOfVoice: ['friendly', 'professional'],
// coreValues: ['innovation', 'trust'],
// guidelines: ['Use active voice', 'Be concise'],
// restrictions: ['Avoid jargon'],
// additionalGuidelines: ['Additional guidelines here']
// }Testing
To run tests:
npm run testLinting
Lint your code:
npm run lintCleaning
To remove node_modules and package-lock.json:
npm run cleanAdditional Information
- Repository: GitHub
- Issue Tracking: GitHub Issues
- License: Apache-2.0
