1.5.9 • Published 1 year ago
whiz-sdk-node v1.5.9
whiz-sdk-node
Setup
Install in your project using npm
npm install whiz-sdk-node
Require in your file as
import WhizSDK from 'whiz-sdk-node';
const whizSDK = WhizSDK({
apiUrl: 'https://api.example.com',
clientId: 1,
clientSecret: 'client_secret_hash'
});
Identity Methods
Validate Document Number (DNI)
const documentNumber = '71747124';
const person = await whizSDK.identity.validate({documentNumber});
console.log(person);
Person Methods
Create Person
const person = await whizSDK.person.create
({
name: "Luis",
lastName: "Torres",
birthdate: "1994-04-04",
documentType: "DNI",
documentNumber: "71747125",
phone: "983241622"
});
console.log(person);
Show Person
const personUuid = 'uuid-example';
const person = await whizSDK.person.get(personUuid);
console.log(person);
List Person
const people = await whizSDK.person.all({
page: "1",
limit: "10"
});
console.log(people);
User Methods
List Users
const users = await whizSDK.user.all();
console.log(users);
Get User
const user = await whizSDK.user.get('userUuid');
console.log(user);
Get User by Email
const user = await whizSDK.user.getByEmail({
email: 'email@email.com', role: 'roleUuid'
});
console.log(user);
Login User
const login = await whizSDK.user.login({
email: 'email@email.com', password: 'passwordStrONG', role: 'roleUuid'
});
console.log(login);
Create User with Person
const created_user = await whizSDK.user.createWithPerson({
person: {
name: "name",
lastName: "lastName",
birthDate: "birthdate",
phone: "phone",
documentType: "documentType",
documentNumber: "documentNumber"
},
user: {
email: "email@email.com",
role: "roleUuid",
password: "passwordStrONG"
}
});
console.log(created_user);
Update User with Person
const user = await whizSDK.user.updateUserWithPerson({
user: "userUuid",
person: "personUuid",
body: {
person: {
name: "userName",
lastName: "lastName",
birthDate: "birthdate",
phone: "phone",
documentType: "documentType",
documentNumber: "documentNumber"
},
user: {
password: "passwordStrONG"
}
}
});
console.log(user);
Mail Methods
Send Mail
const mail = await whizSDK.mail.send({
cc: [{email: "cc@example.com", name: "name"}],
sender: {email: 'sender@example.com', name: 'Sender'},
addressee: {email: 'Receiver@example.com', name: 'Receiver'},
template: '<h1>Hi!</h1>',
subject: 'Greetings'
});
console.log(mail);
Create Mail List
const mailList = await whizSDK.mail.list.create({
name: 'name',
description: 'description',
category: 'category'
});
console.log(mailList);
Update Mail List
const mailList = await whizSDK.mail.list.update({
list: 'mailListUuid',
body: {
name: 'name',
description: 'description',
category: 'category'
}
});
console.log(mailList);
Delete Mail List
await whizSDK.mail.list.delete('mailListUuid');
Show Mail List
const mailList = await whizSDK.mail.list.get('uuid');
console.log(mailList);
Mail List Add People
await whizSDK.mail.list.addPeople({
list: 'mailListUuid',
body: {
people: [{email: 'email1@email.com', name: 'name'}]
}
});
Mail List Send mail
await whizSDK.mail.list.send({
list: 'mailListUuid',
body: {
sender: {email: 'sender@example.com', name: 'Sender'},
template: '<h1>Hi!</h1>',
subject: 'Greetings'
}
});
Image Methods
Upload Image
await whizSDK.image.upload({
imageBuffer,
mimeType: "image/png"
image: {
tableName: "images",
tableKey: "1",
fileName: "name-from-image.png"
}
});
Load Image by Url
await whizSDK.image.loadByUrl({
images: [{
tableName: "images",
tableKey: "1",
url: "https://url-from-image"
}]
});
Delete Image
await whizSDK.image.delete('imageUuid');
Role Methods
List Role
const roles = await whizSDK.role.all();
console.log(roles);
Create Role
const role = await whizSDK.role.create({
title: "admin",
abilities: ["abilityUuid"]
});
console.log(role);
Update Role
const role = await whizSDK.role.update({
uuid: "roleUuid",
title: "admin",
abilities: ["abilityUuid"]
});
console.log(role);
Ability Methods
Create Ability
const ability = await whizSDK.ability.create({
title: 'manageCommercial'
});
console.log(ability);
Update Ability
const ability = await whizSDK.ability.update({
ability: 'abilityUuid',
body: {
title: 'admin'
}
});
console.log(ability);
Get Ability
const ability = await whizSDK.ability.get(abilityUuid);
console.log(ability);
List Ability
const abilities = await whizSDK.ability.all();
console.log(abilities);
Sheets (CSV and Excel)
List sheets
const sheets = await whizSDK.sheet.all({
page: "1",
limit: "10"
});
console.log(sheets);
Find sheet
const sheet = await whizSDK.sheet.find("uuid");
console.log(sheet);
Create sheet
const sheet = await whizSDK.sheet.initSheet
({
headers: ["name", "email", "phone"];
format: "csv";
});
console.log(sheet);
Update sheet with payload
const sheet = await whizSDK.sheet.addPayload
({
sheet: "uuid",
body: {
data: [
{
name: "Paolo",
email: "paolo@whiz.one",
phone: "123456789"
},
{
name: "Eduardo",
email: "eduardo@whiz.one",
phone: "123456788"
}
]
}
});
console.log(sheet);
Generate sheet
const sheet = await whizSDK.sheet.generateSheet("uuid");
console.log(sheet);
1.5.9
1 year ago
1.5.8
1 year ago
1.5.5
1 year ago
1.5.4
1 year ago
1.5.3
1 year ago
1.5.2
1 year ago
1.5.1
1 year ago
1.5.0
2 years ago
1.5.7
1 year ago
1.5.6
1 year ago
1.3.2
2 years ago
1.4.0
2 years ago
1.3.1
2 years ago
1.3.0
2 years ago
1.2.9
2 years ago
1.2.8
2 years ago
1.2.7
2 years ago
1.2.6
2 years ago
1.2.5
2 years ago
1.2.4
2 years ago
1.2.3
2 years ago
1.2.2
2 years ago
1.2.1
2 years ago
1.2.0
2 years ago
1.1.2
2 years ago
1.1.1
2 years ago
1.1.0
2 years ago
1.0.2
2 years ago
1.0.1
2 years ago
1.0.0
2 years ago