legito / api-wrapper
Legito REST API包装器
2.2.0
2020-12-16 09:24 UTC
Requires
- php: >= 7.1
- ext-curl: *
- ext-json: *
- firebase/php-jwt: ^5.2
- tcdent/php-restclient: ^0.1.7
This package is auto-updated.
Last update: 2024-09-17 20:09:48 UTC
README
Legito REST API请求的PHP包装器。
包装器目前支持
- Legito API v1
- Legito API v2
- Legito API v3
旧版API不再支持。
API的英文文档https://app.swaggerhub.com/apis-docs/Legito/legito-api/3
安装
安装此包的首选方式是通过composer。
composer require legito/api-wrapper
基本用法
<?php use Legito\Api\Legito; // Configure API wrapper $apiKey = 'ad2e37c9-ee63-4479-9295-36cf21674343'; $privateKey = '37c2f78b02'; //$url = 'https://example.legito.com'; // use only if you run Legito on custom server // Create instance $legitoApi = (new Legito($apiKey, $privateKey, $url))->getWrapper(); // Call some API methods // ------------------------------------------------------------------------ // Creates document version from template suite ID 2255. Inserts some data to input // element 'first_party_name1' and downloads it. $templateSuiteId = 2255; $smartDocument = $legitoApi->postDocumentVersionData( $templateSuiteId, [ [ 'name' => 'first_party_name1', 'value' => 'John Doe' ] ] ); $documentsData = $legitoApi->getDocumentVersionDownload($smartDocument->code, 'pdf'); foreach($documentsData as $documentData) { file_put_contents( $documentData->filename, base64_decode($documentData->data) ); } // Prints all users form your workspace. $users = $legitoApi->getUser(); print_r($users); // Creates two users in your workspace. $legitoApi->postUser( [ [ 'email' => 'johndoe@legito.com', 'name' => 'John Doe' ], [ 'email' => 'janedee@legito.com', 'name' => 'Jane Dee', 'caption' => 'CEO' ] ] ); // Deletes user form your workspace. $legitoApi->deleteUser('johndoe@legito.com');