PHP code example of esign / laravel-plytix

1. Go to this page and download the library: Download esign/laravel-plytix 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/ */

    

esign / laravel-plytix example snippets




use Esign\Plytix\Enums\RateLimitingPlan;

return [
    /**
     * The API key to be used for authenticating with the Plytix API.
     */
    'api_key' => env('PLYTIX_API_KEY'),

    /**
     * The API password to be used for authenticating with the Plytix API.
     */
    'api_password' => env('PLYTIX_API_PASSWORD'),

    'authenticator_cache' => [
        /**
         * The key that will be used to cache the Plytix access token.
         */
        'key' => 'esign.plytix.authenticator',

        /**
         * The cache store to be used for the Plytix access token.
         * Use null to utilize the default cache store from the cache.php config file.
         * To disable caching, you can use the 'array' store.
         */
        'store' => null,
    ],

    'rate_limiting' => [
        /**
         * The rate limits to be used for the Plytix API.
         */
        'plan' => RateLimitingPlan::FREE,

        /**
         * The cache store to be used for the Plytix rate limits.
         * Use null to utilize the default cache store from the cache.php config file.
         * To disable caching, you can use the 'array' store.
         */
        'cache_store' => null,
    ],
];


use Esign\Plytix\Plytix;
use Esign\Plytix\Requests\ProductRequest;

class MyCommand
{
    public function handle(): int
    {
        $plytix = Plytix::make();
        $response = $plytix->send(new ProductRequest('583bef16-2197-46dd-90ce-9f4210bef5ef'));

        return self::SUCCESS;
    }
}

$plytix = Plytix::make();
$response = $plytix->send(new ProductRequest('583bef16-2197-46dd-90ce-9f4210bef5ef'));
$product = $response->dtoOrFail();

$plytix = Plytix::make();
$response = $plytix->send(new ProductRequest('583bef16-2197-46dd-90ce-9f4210bef5ef'));
$data = $response->body();

$plytix = Plytix::make();
$paginator = $plytix->paginate(new ProductSearchRequest());

foreach ($paginator as $response) {
    $products = $response->dtoOrFail();
}

$plytix = Plytix::make();
$paginator = $plytix->paginate(new ProductSearchRequest());

foreach ($paginator->items() as $product) {
    // Do something with the product
}

$paginator->collect()->each(function ($product) {
    // Do something with the product
});

use Esign\Plytix\Requests\ProductRequest;

class MyCustomProductRequest extends ProductRequest
{
    protected function defaultQuery(): array
    {
        return [
            'customer-query-param' => 'value',
        ];
    }

}

use Saloon\Enums\Method;
use Saloon\Http\Request;

class MyCustomRequest extends Request
{
    protected Method $method = Method::GET;

    public function resolveEndpoint(): string
    {
        return '/example';
    }
}
bash
php artisan vendor:publish --provider="Esign\Plytix\PlytixServiceProvider" --tag="config"
bash
php artisan saloon:request Plytix MyCustomRequest