0.0.1 • Published 6 years ago
mifiel v0.0.1
Mifiel
NodeJS SDK for Mifiel API. Please read our documentation for instructions on how to start using the API.
Installation
NPM
npm install mifiel --save
Yarn
yarn add mifiel
Usage
For your convenience Mifiel offers a Sandbox environment where you can confidently test your code.
To start using the API in the Sandbox environment you need to first create an account at sandbox.mifiel.com.
Once you have an account you will need an APP_ID and an APP_SECRET which you can generate in sandbox.mifiel.com/access_tokens.
Then you can configure the library with:
import Mifiel from 'mifiel' // for ES6 and Typescript
// for ES5
var Mifiel = require('mifiel').default
Mifiel.Config.setTokens('<APP_ID>', '<APP_SECRET>')
// for sandbox use
Mifiel.Config.url = 'https://sandbox.mifiel.com/api/v1'
All methods return promises
Document methods
- Find:
Mifiel.Models.Document.find('id').then(doc => {
console.log(doc)
doc.original_hash
doc.file
doc.file_signed
// ...
})
- Find all:
Mifiel.Models.Document.all().then(docs => {
console.log(docs)
})
- Create:
Use only hash if you dont want us to have the file. Either file or hash must be provided.
const document = new Mifiel.Models.Document({
file: 'path/to/my-file.pdf',
signatories: [
{ name: 'Signer 1', email: 'signer1@email.com', tax_id: 'AAA010101AAA' },
{ name: 'Signer 2', email: 'signer2@email.com', tax_id: 'AAA010102AAA' }
]
})
document.save().then(doc => {
console.log(doc)
doc.original_hash
doc.file
doc.file_signed
})
// if you dont want us to have the PDF, you can just send us
// the original_hash and the name of the document. Both are required
const document = new Mifiel.Models.Document({
hash: Digest::SHA256.hexdigest(File.read('path/to/my-file.pdf')),
name: 'my-file.pdf',
signatories: [...]
})
- Save Document related files
// save the original file
document.saveFile('path/to/save/file.pdf').then(resp => {
resp === true
})
// save the signed file (original file + signatures page)
document.saveFileSigned('path/to/save/file-signed.pdf').then(resp => {
resp === true
})
// save the signed xml file
document.saveXml('path/to/save/xml.xml').then(resp => {
resp === true
})
Delete
Mifiel.Models.Document.delete('id')
Certificate methods
Sat Certificates
Mifiel.Modesl.Certificate.sat().then(satCertificates => { console.log(satCertificates) })
Find:
Mifiel.Models.Certificate.find('id').then(certificate => {
certificate.cer_hex
certificate.type_of
// ...
})
- Find all:
Mifiel.Models.Document.all().then(certs => {
console.log(certs)
})
Create
const certificate = new Mifiel.Models.Certificate({ file: "path/to/my-certificate.cer" }) certificate.save().then(cer => { cer.cer_hex cer.type_of // ... })
Delete
Mifiel.Models.Certificate.delete('id')
User methods
Setup Widget
const args = { email: 'some@email.com', tax_id: 'AAA010101AAA', callback_url: 'http://some-callback.url' } Mifiel.Models.User.setupWidget(args).then(useer => { user.widget_id })
Contributing
- Fork it ( https://github.com/[my-github-username]/mifiel/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request