Git Product home page Git Product logo

php-api-client's Introduction

Mifiel PHP API Client

Latest Stable Version Build Status Coverage Status

PHP SDK for Mifiel API. Please read our documentation for instructions on how to start using the API.

Installation

Just run composer require mifiel/api-client in the root your project or add mifiel/api-client to your composer.json.

  "require": {
    "mifiel/api-client": "^1.0"
  }

And then execute composer install.

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:

  use Mifiel\ApiClient as Mifiel;
  Mifiel::setTokens('APP_ID', 'APP_SECRET');
  // if you want to use our sandbox environment use:
  Mifiel::url('https://sandbox.mifiel.com/api/v1/');

Document methods:

  • Find:

      use Mifiel\Document;
      $document = Document::find('id');
      $document->original_hash;
      $document->file;
      $document->file_signed;
      # ...
  • Find all:

      use Mifiel\Document;
      $documents = Document::all();
  • Create:

Use only original_hash if you dont want us to have the file.
Only file or original_hash must be provided.

  use Mifiel\Document;
  $document = new Document([
    'file_path' => 'path/to/my-file.pdf',
    'signatories' => [
      [ 
        'name' => 'Signer 1', 
        'email' => '[email protected]', 
        'tax_id' =>  'AAA010101AAA' 
      ],
      [ 
        'name' => 'Signer 2', 
        'email' => '[email protected]', 
        'tax_id' =>  'AAA010102AAA'
      ]
    ]
  ]);
  // 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
  $document = new Document([
    'original_hash' => hash('sha256', file_get_contents('path/to/my-file.pdf')),
    'name' => 'my-file.pdf',
    'signatories' => ...
  ]);

  $document->save();
  • Save Document related files
  use Mifiel\Document;
  $document = Document::find('id');

  # save the original file
  $document->saveFile('path/to/save/file.pdf');
  # save the signed file (original file + signatures page)
  $document->saveFileSigned('path/to/save/file-signed.pdf');
  # save the signed xml file
  $document->saveXML('path/to/save/xml.xml');
  • Delete

      use Mifiel\Document;
      Document::delete('id');

Certificate methods:

  • Sat Certificates

      use Mifiel\Certificate;
      $sat_certificates = Certificate::sat();
  • Find:

      use Mifiel\Certificate;
      $certificate = Certificate::find('id');
      $certificate->cer_hex;
      $certificate->type_of;
      # ...
  • Find all:

      use Mifiel\Certificate;
      $certificates = Certificate::all();
  • Create

      use Mifiel\Certificate;
      $certificate = new Certificate([
        'file_path' => 'path/to/my-certificate.cer'
      ])
      $certificate->save();
  • Delete

      use Mifiel\Certificate;
      Certificate::delete('id');

Template methods:

  • Find:

      use Mifiel\Template;
      $template = Template::find('id');
      $template->name;
      $template->header;
      $template->content;
      # ...
  • Find all:

      use Mifiel\Template;
      $templates = Template::all();
  • Create:

      use Mifiel\Template;
      $template = new Template([
        'name' => 'My template name',
        'header' => 'Some header text',
        'content' => '<div>The signer <field name="signer">SIGNER</field></div>',
        'footer' => 'Some footer text'
      ]);
      
      $template->save();
      $template->id;
  • Delete

      use Mifiel\Template;
      Template::delete('id');
  • Generate a document from a template

use Mifiel\Document;

$document = Document::createFromTemplate([
  'template_id' => 'some-id',
  'name' => 'Some-name.pdf',
  'fields' => [
    'name' => 'Signer 1',
    'type' => 'Lawyer'
  ],
  'signatories' => [[
    'email' => '[email protected]'
  ]],
  'external_id' => 'some-external-id'
]);
  • Generate several documents from a template
$document = Document::createManyFromTemplate([
  'template_id' => 'some-id',
  'identifier' => 'name',
  'callback_url' => 'https://some-url.com',
  'documents' => [[
    'fields' => [
      'name' => 'Signer 1',
      'type' => 'Lawyer 1'
    ],
    'signatories' => [[
      'email' => '[email protected]'
    ]],
    'external_id' => 'some-external-id'
  ], [
    'fields' => [
      'name' => 'Signer 2',
      'type' => 'Lawyer 2'
    ],
    'signatories' => [[
      'email' => '[email protected]'
    ]],
    'external_id' => 'some-other-external-id'
  ]]
]);

Development

Install grunt and run grunt in the terminal. This will run all tests whenever a change is detected to any file in the project.

Contributing

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

php-api-client's People

Contributors

genaromadrid avatar gogl92 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.