olsgreen / adobe-sign-api
Adobe Sign 客户端,适用于 PHP
0.1
2021-02-05 07:50 UTC
Requires
- ext-json: *
- guzzlehttp/guzzle: ^6.0 || ^7.2
- symfony/options-resolver: ^5.0
Requires (Dev)
- mockery/mockery: ^1.3
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2024-09-05 15:42:17 UTC
README
此包提供了一种简单易行的方式与 Adobe Sign API v6 进行交互。
安装
使用 composer 将客户端添加到您的项目中。
composer require olsgreen/adobe-sign-api
使用方法
客户端假设您已从 Adobe Sign oAuth 流程中获取并访问了访问令牌,我已编写了一个单独的包来处理此问题,请参阅 olsgreen/oauth2-adobe-sign。
创建新的 API 客户端实例并进行认证
// Create an instance of the client. $api = new \Olsgreen\AdobeSign\Client($your_access_token, ['data_center' => 'us2']);
上传文件
// Upload a document from a path $transientDocumentId = $api->documents()->uploadFile('/path/to/my/file.pdf'); // Upload a stream, resource or binary data. $data = fopen('/path/to/my/file.pdf', 'r'); $transientDocumentId = $api->documents()->upload('file.pdf', 'application/pdf', $data);
使用构建器构建、创建并发送协议
use \Olsgreen\AdobeSign\Api\Builders\Factory; use \Olsgreen\AdobeSign\Api\Enums\SignatureTypes; use \Olsgreen\AdobeSign\Api\Enums\AgreementStates; use \Olsgreen\AdobeSign\Api\Enums\ParticipantRoles; ... // Create the base agreement object. $agreement = Factory::createAgreementInfoBuilder() ->setName('Test Agreement') ->setSignatureType(SignatureTypes::TYPE_ESIGN) ->setState(AgreementStates::IN_PROCESS); // Add the PDF file for signing to the agreement using the // $transientDocumentId from the document upload example above. $agreement->fileInfos()->add( Factory::createFileInfoBuilder() ->setLabel('Test File') ->setTransientDocumentId($transientDocumentId) ); // Create a participant set for the signer. $participantSetsInfo = Factory::createParticipantSetInfoBuilder() ->setOrder(1) ->setRole(ParticipantRoles::SIGNER); // Add a participant to the set. $participantSetsInfo->memberInfos()->add( Factory::createParticipantInfoBuilder() ->setEmail('signer@domain.com') ); // Add the participant set to the agreement. $agreement->participantSetsInfo()->add($participantSetsInfo); // Create the agreement via the API. $agreementId = $api->agreements()->create($agreement);
获取协议签名 URL
// Gets the signing URLs from the API. $urls = $api->agreements()->getSigningUrls($agreementId); // Will output similar to: // [ // ['email' => 'signer1@domain.com', 'esignUrl' => 'https://secure.adobesign.com/sign1'], // ['email' => 'signer2@domain.com', 'esignUrl' => 'https://secure.adobesign.com/sign2'] // ]
创建 Webhook
use \Olsgreen\AdobeSign\Api\Builders\WebhookInfoBuilder; use \Olsgreen\AdobeSign\Api\Enums\WebhookScopes; use \Olsgreen\AdobeSign\Api\Enums\WebhookEventNames; ... $webhook = WebhookInfoBuilder::create() ->setName('Test Webhook') ->setScope(WebhookScopes::USER) ->setUrl('https://mydomain.com/hooks/adobe-sign') ->setWebhookSubscriptionEvents([ WebhookEventNames::AGREEMENT_ALL ]); $webhookId = $api->webhooks()->create($webhook);