mifiel
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

Mifiel

npm version Build Status Coverage Status

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

  1. Fork it ( https://github.com/[my-github-username]/mifiel/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.1
    129
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.1
    129
  • 0.0.0
    0

Package Sidebar

Install

npm i mifiel

Weekly Downloads

113

Version

0.0.1

License

MIT

Last publish

Collaborators

  • genaromadrid