0.0.16 • Published 5 years ago
pedial-sdk v0.0.16
pedial-sdk
installation
yarn add pedial-sdk
or
npm install --save pedial-sdk
init project
const pedial = require('pedial-sdk');
const config = {
url: 'http://SDK_URL',
apiKey: 'YOUR_API_KEY',
projectId: YOUR_PROJECT_ID,
};
pedial.init(config);
Note: you need to call pedial.init(config)
before calling any of the commands below.
Note: all the examples below use async / await, but they will also work with promises.
get project informations
try {
const projectInfo = pedial.getProject();
console.log(projectInfo);
} catch(e) {
console.error(e.message);
}
upload a file for certification
try {
const result = await pedial.uploadFileForCertification({
description: 'Sample Yarn File, to see if it can be certified ?',
tags: ['yarn', 'dummy example'],
path: './yarn.lock'
});
console.log(`Done. Remaining storage : ${result.remainingStorage} bytes`);
} catch(e) {
console.error(e.message);
}
upload content for certification
try {
const result = await pedial.uploadContentForCertification({
name: 'My First Poem',
description: 'This is my first poem, I hope you will enjoy it.',
tags: ['poetry'],
content: `
Roses are red,
Violets are blue,
This is my first poem,
from me, through Pedial, to you
`
});
console.log(`Done. Remaining storage : ${result.remainingStorage} bytes`);
} catch(e) {
console.error(e.message);
}
give a link (hash) to a file for certification, without uploading
Your file won't be copied to Pedial's server.
You will need to provide a hash for the file.
try {
await pedial.linkFileForCertification({
description: 'Some file I want to certify but certainly not upload.',
tags: ['personal file', 'family'],
filename: 'MyWeddingMovie.mp4',
url: 'SOME_URL_IF_ANY',
hash: 'FILE_HASH',
});
console.log('Done.');
} catch(e) {
console.error(e.message);
}