Skip to content

Instantly share code, notes, and snippets.

@birinder-lobana
Created May 3, 2022 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save birinder-lobana/780ac506604df6fb013a2f6942f8d564 to your computer and use it in GitHub Desktop.
Save birinder-lobana/780ac506604df6fb013a2f6942f8d564 to your computer and use it in GitHub Desktop.
Create a batch of dynamic QR codes
// Initiate the Openscreen node SDK and include the project ID that you recieved using the Openscreen dashboard
const { Openscreen } = require("@openscreen/sdk");
require('dotenv').config();
const os = new Openscreen().config({key: process.env.OS_API_KEY, secret: process.env.OS_API_SECRET});
const projectId = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';
async function main(){
// Create multiple assets that each represent a different billboard. Each of these billboards will direct a user to the same listing at 123 Cherry Street.
const bulkAssets = await os.project(projectId).assetsBatch().create([{
name: 'Billboard 1',
description: 'Billboard at Yonge and Eglington for 123 Cherry Street Listing',
qrCodes: [
{
intent: 'https://jaydeenrealty.com/123cherry/',
intentType: 'DYNAMIC_REDIRECT'
},
]
},{
name: 'Billboard 2',
description: 'Billboard at Yonge and Lawrence for 123 Cherry Street Listing',
qrCodes: [
{
intent: 'https://jaydeenrealty.com/123cherry/',
intentType: 'DYNAMIC_REDIRECT'
},
]
},{
name: 'Billboard 3',
description: 'Billboard at Mt. Pleasant and Eglington for 123 Cherry Street Listing',
qrCodes: [
{
intent: 'https://jaydeenrealty.com/123cherry/',
intentType: 'DYNAMIC_REDIRECT'
},
]
}]);
console.log('Bulk Assets:', JSON.stringify(bulkAssets, '',2));
}
main().catch((err) => {
console.error(err);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment