-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add template get all and get by id examples
- Loading branch information
Jeff Shillitto
committed
Apr 16, 2023
1 parent
137ce82
commit eb68f39
Showing
4 changed files
with
72 additions
and
4 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
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,32 @@ | ||
const Shotstack = require('shotstack-sdk'); | ||
|
||
const defaultClient = Shotstack.ApiClient.instance; | ||
const DeveloperKey = defaultClient.authentications['DeveloperKey']; | ||
const api = new Shotstack.EditApi(); | ||
const id = process.argv[2]; | ||
|
||
let apiUrl = 'https://api.shotstack.io/stage'; | ||
|
||
if (!id) { | ||
console.log(">> Please provide the UUID of the template (i.e. node examples/templates/template.js 7feabb0e-b5eb-8c5e-847d-82297dd4802a)\n"); | ||
process.exit(1); | ||
} | ||
|
||
if (!process.env.SHOTSTACK_KEY) { | ||
console.log('API Key is required. Set using: export SHOTSTACK_KEY=your_key_here'); | ||
process.exit(1); | ||
} | ||
|
||
if (process.env.SHOTSTACK_HOST) { | ||
apiUrl = process.env.SHOTSTACK_HOST; | ||
} | ||
|
||
defaultClient.basePath = apiUrl; | ||
DeveloperKey.apiKey = process.env.SHOTSTACK_KEY; | ||
|
||
api.getTemplate(id).then((data) => { | ||
console.log(JSON.stringify(data.response, null, 2)); | ||
}, (error) => { | ||
console.error('Request failed: ', error); | ||
process.exit(1); | ||
}); |
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,30 @@ | ||
const Shotstack = require('shotstack-sdk'); | ||
|
||
const defaultClient = Shotstack.ApiClient.instance; | ||
const DeveloperKey = defaultClient.authentications['DeveloperKey']; | ||
const api = new Shotstack.EditApi(); | ||
|
||
let apiUrl = 'https://api.shotstack.io/stage'; | ||
|
||
if (!process.env.SHOTSTACK_KEY) { | ||
console.log('API Key is required. Set using: export SHOTSTACK_KEY=your_key_here'); | ||
process.exit(1); | ||
} | ||
|
||
if (process.env.SHOTSTACK_HOST) { | ||
apiUrl = process.env.SHOTSTACK_HOST; | ||
} | ||
|
||
defaultClient.basePath = apiUrl; | ||
DeveloperKey.apiKey = process.env.SHOTSTACK_KEY; | ||
|
||
api.getTemplates().then((data) => { | ||
const { templates } = data.response; | ||
|
||
if (templates.length) { | ||
console.log(templates); | ||
} | ||
}, (error) => { | ||
console.error('Request failed: ', error); | ||
process.exit(1); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.