Giter Site home page Giter Site logo

yousign-bundle's Introduction

Yousign Bundle for Symfony2

Latest Stable Version Total Downloads Latest Unstable Version License

This bundle provides integration for Yousign in your Symfony2 Project.

License: MIT

Installation

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

    $ composer require picoss/yousign-bundle

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

2: Enable the Bundle

When using Flex, this step is handled automatically.

Then, enable the bundle by adding the following line in the app/AppKernel.php file of your project:

    // app/AppKernel.php

    class AppKernel extends Kernel
    {
        public function registerBundles()
        {
            $bundles = array(
                // ...

                new Picoss\YousignBundle\PicossYousignBundle(),
            );

            // ...
        }

        // ...
    }

3: Configure the bundle

# config/packages/picoss_yousign.yml
picoss_yousign:
    env: demo #demo or prod
    api_key: yousign_api_key
    username: yousign_username
    password: yousign_password

Note: If you need to pass some options to the saop client, add soap_options config:

# config/packages/picoss_yousign.yml
picoss_yousign:
    env: demo #demo or prod
    api_key: yousign_api_key
    username: yousign_username
    password: yousign_password
    soap_options:
        trace: 1

Check $options argument of the soap client to see available options : http://php.net/manual/en/soapclient.soapclient.php

4: Usage

4.1: Test API connection

The following example shows how to test the connection to the Yousign API in your controller

<?php

namespace App\Controller;

use Picoss\YousignBundle\Yousign\YousignApi;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;

class TestController extends Controller
{
    /**
     * @Route("/test", name="test")
     */
    public function index(YousignApi $api)
    {
        $auth = $api->authentication;
        
        $result = $auth->connect() ? 'Connected' : 'Enable to connect';

        $response = new Response();
        $response->setContent(sprintf('<html><body>%s</body></html>', $result));

        return $response;
    }
}

4.2: Create a signature demand

<?php

namespace App\Controller;

use Picoss\YousignBundle\Model\Cosigner;
use Picoss\YousignBundle\Model\Demand;
use Picoss\YousignBundle\Model\File;
use Picoss\YousignBundle\Yousign\YousignApi;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;

class TestController extends Controller
{
    /**
     * @Route("/test", name="test")
     */
    public function index(YousignApi $api)
    {
        $signatureApi = $api->signature;

        $file = new File();
        $file
            ->setName('My PDF Filename')
            ->setContent(file_get_contents('/path/to/the/file.pdf'))
        ;

        $cosigner = new Cosigner();
        $cosigner
            ->setFirstName('John')
            ->setLastName('Doe')
            ->setMail('[email protected]')
            ->setAuthenticationMode('mail');

        $visibleOptions = array(
            'visibleSignaturePage' => '5',
            'isVisibleSignature' => true,
            'visibleRectangleSignature' => '10,10,10,10',
        );

        $demand = new Demand();
        $demand
            ->addFile($file, $visibleOptions)
            ->addCosigner($cosigner)
        ;

        $signature = $signatureApi->initCosign($demand);

        $response = new Response();
        $response->setContent(sprintf('<html><body>Signature demand id: %s</body></html>', $signature->getIdDemand()));

        return $response;
    }
}

4.3: Available methods

4.3.1: Authentication API

Methods Description Return
connect() Check API connection boolean

4.3.2: Signature API

Methods Description Return
initCosign() Initialize a signature demand Picoss\YousignBundle\Model\Signature
getCosignedFilesFromDemand() Get files from demand id Picoss\YousignBundle\Model\File[]
getInfosFromCosignatureDemand() Get signature informations Picoss\YousignBundle\Model\Signature
getListCosign() Search for signatures demand Picoss\YousignBundle\Model\Signature[]
cancelCosignatureDemand() Cancel a signature process boolean
alertCosigners() Alter cosigners boolean
isPDFSignable() Check if the given PDF is signable boolean
updateCosigner() Update a cosigner informations boolean

For more informations, please visite Yousign API documentation

yousign-bundle's People

Contributors

picoss avatar

Stargazers

 avatar  avatar

Watchers

 avatar

yousign-bundle's Issues

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.