-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sample/ usage_client_credentials.js (#135)
- Loading branch information
1 parent
312c0b0
commit 6d08197
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const Bynder = require('../dist/bynder-js-sdk.js'); | ||
const configs = require('../secret.json'); | ||
|
||
const usageSample = async () => { | ||
const bynder = new Bynder(configs); | ||
try { | ||
const token = await bynder.getTokenClientCredentials(); | ||
|
||
const ASSET_ID = 'B3A6E924-E6F4-47AD-96D68F4C32B745D0'; | ||
|
||
await bynder.saveNewAssetUsage({ | ||
id: ASSET_ID, | ||
integration_id: 'b242c16d-70f4-4101-8df5-87b35bbe56f0', | ||
timestamp: "2017-04-19T11:36:36.799508+00:00", | ||
uri: '/test', | ||
additional: 'Testing 123', | ||
}); | ||
console.log('Successfully saved asset usage'); | ||
|
||
const assetUsage = await bynder.getAssetUsage({ id: ASSET_ID }); | ||
console.log(assetUsage); | ||
|
||
await bynder.deleteAssetUsage({ | ||
id: ASSET_ID, | ||
integration_id: 'b242c16d-70f4-4101-8df5-87b35bbe56f0', | ||
uri: '/test', | ||
}); | ||
console.log('Successfully deleted asset usage'); | ||
} catch (error) { | ||
console.error('Error:', error); | ||
} | ||
}; | ||
|
||
usageSample(); |