PHP code example of mifiel / api-client

1. Go to this page and download the library: Download mifiel/api-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mifiel / api-client example snippets


  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/');

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

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

    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 

  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');

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

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

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

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

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

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

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

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

    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;
  

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

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'
]);

$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'
  ]]
]);