定制 tucker-eric/docusign-rest-client 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tucker-eric/docusign-rest-client

Composer 安装命令:

composer require tucker-eric/docusign-rest-client

包简介

A PHP Wrapper For The Official Docusign Esign Library Implementing The Docusign REST Api

关键字:

README 文档

README

Wrapper for the official Docusign PHP Client Library.

This library handles all the object instantiation for the endpoints in the DocuSign Api Explorer.

Install Through Composer

composer require tucker-eric/docusign-rest-client

Usage

The DocuSign\Rest\Client accesses all models and api endpoints and returns the respective obect. It also handles all authentication as well as passing the $account_id to any method that requires it.

Api Endpoints

All classes in the DocuSign\eSign\Api namesapace are accessible as properties of DocuSign\Rest\Client.

Each property is a the orignal class name camel cased without the Api suffix.

Example:

<?php

require 'vendor/autoload.php';

$client = new DocuSign\Rest\Client([
	'impersonated_user_id' => $impersonated_user_id,
	'integrator_key'       => $integrator_key,
	'host'                 => $host,
	'private_key'          => $private_key,
	'auth_server'          => $auth_server
]);

$client->accounts // Returns DocuSign\eSign\Api\AccountsApi

$client->customTabs // Returns DocuSign\eSign\Api\CustomTabsApi

$client->folders // Returns DocuSign\eSign\Api\FoldersApi

The client handles injecting the $account_id to any method that requires it.

So calling a method like the DocuSign\eSign\Api\FoldersApi list() method is as easy as:

$client->folders->list();  // Returns \DocuSign\eSign\Model\FoldersResponse

Models

All classes in the DocuSign\eSign\Model namespace are accessible as a camel cased method of DocuSign\Rest\Client and accept an array of snake cased parameters that will be set on the model. Calling the method returns that model object.

Example:

<?php

require 'vendor/autoload.php';

$client = new DocuSign\Rest\Client([
            'impersonated_user_id' => $impersonated_user_id,
            'private_key'          => $private_key,
            'integrator_key'       => $integrator_key,
            'host'                 => $host,
            'auth_server'          => $auth_server
]);

$templateRole = $client->templateRole([
	'email' 	=> '[SIGNER_EMAIL]',
	'name'  	=> '[SIGNER_NAME]',
	'role_name' => '[ROLE_NAME]'
]); // Returns DocuSign\eSign\Model\TemplateRole

$templateRole->getRoleName() // returns '[ROLE_NAME]' as set in the above method.

$envelopeDefinition = $client->envelopeDefinition([
	'status'         => 'sent'
	'email_subject'  => '[DocuSign PHP SDK] - Signature Request Sample',
	'template_id'    => '[TEMPLATE_ID]',
	'template_roles' => [
		$templateRole
	],
]); // Returns DocuSign\eSign\Model\EnvelopeDefinition

Api Options

Some classes in the DocuSign\eSign\Api namespace have options objects that can be created and passed to methods of that class. Those objects are accessible by calling it as a method from that Api class. The options methods accept an array of snake cased parameters to set. You can also call this method without any parameters and it will return the options object and you can use that object's setter methods to set its properties

The ->search() method in the DocuSign\eSign\Api\FoldersApi class accepts DocuSign\eSign\Api\FoldersApi\SearchOptions to set the options. These options are set as in the example below

Example:

$foldersApi = $this->client->folders;
$searchOptions = $foldersApi->searchOptions([
	'count'     => 20,
	'order_by'  => 'sent',
	'from_date' => '2010-01-01'
]);
$foldersApi->search($searchOptions);

You can retrieve any previously set options on an Api class with the getOptions method. Passing the name of the method used to set the options returns that options object or not passing any parameters will return an array of all options objects for that Api class keyed by method name.

Example:

$envelopesApi = $this->client->envelopes;
$envelopesApi->createEnvelopeOptions([
	'merge_roles_on_draft' => 'true'
]);
$envelopesApi->updateOptions([
	'resend_envelope' => 'true'
]);

$envelopesApi->getOptions(); // returns ['updateOptions' => DocuSign\eSign\Api\EnvelopesApi\UpdateOptions, 'createEnvelopeOptions' => DocuSign\eSign\Api\EnvelopesApi\CreateEnvelopeOptions]

$envelopesApi->getOptions('updateOptions') // returns DocuSign\eSign\Api\EnvelopesApi\UpdateOptions

Examples

To login and send a signature request from a template:

This will produce the same result as this example from official Docusign Client

<?php

require 'vendor/autoload.php';

class DocuSignSample
{
	public function signatureRequestFromTemplate()
	{

	    $impersonated_user_id = "[IMPERSONATED_USER_ID]";
        $private_key = "[PRIVATE_KEY]";
        $integrator_key = "[INTEGRATOR_KEY]";

		// change these to production before going live
        $host = "https://demo.docusign.net/restapi";
        $auth_server = "account-d.docusign.com";
		// Once instantiated, authentication is handled automatically
        $client = new DocuSign\Rest\Client([
            'impersonated_user_id' => $impersonated_user_id,
            'private_key'          => $private_key,
            'integrator_key'       => $integrator_key,
            'host'                 => $host,
            'auth_server'          => $auth_server
        ]);

    	$templateRole = $client->templateRole([
			'email' 	=> '[SIGNER_EMAIL]',
			'name'  	=> '[SIGNER_NAME]',
			'role_name' => '[ROLE_NAME]'
    	]);

    	$envelopeDefinition = $client->envelopeDefinition([
    		'status'         => 'sent',
    		'email_subject'  => '[DocuSign PHP SDK] - Signature Request Sample',
    		'template_id'    => '[TEMPLATE_ID]',
    		'template_roles' => [
    			$templateRole
    		],
    	]);
		
    	$envelopeOptions = $client->envelopes->createEnvelopeOptions([			
			'merge_roles_on_draft' => false
    	]);
		
    	$envelopeSummary = $client->envelopes->createEnvelope($envelopeDefinition, $envelopeOptions);
	}
}

That same example refactored in it's own class:

<?php

require 'vendor/autoload.php';

class DocuSignSample
{

	protected $impersonated_user_id = "[IMPERSONATED_USER_ID]";
    protected $private_key = "[PRIVATE_KEY]";
    protected $integrator_key = "[INTEGRATOR_KEY]";

	// change these to production before going live
    protected $host = "https://demo.docusign.net/restapi";
    protected $auth_server = "account-d.docusign.com";

    protected $client;

	public function __construct()
	{
		// Once instantiated, authentication is handled automatically
        $this->client = new DocuSign\Rest\Client([
            'impersonated_user_id' => $impersonated_user_id,
            'private_key'          => $private_key,
            'integrator_key'       => $integrator_key,
            'host'                 => $host,
            'auth_server'          => $auth_server
        ]);
	}
	
	/**     
     * @return DocuSign\eSign\Model\EnvelopeSummary
     */
	public function signatureRequestFromTemplate()
	{
    	return $this->client->envelopes->createEnvelope($this->client->envelopeDefinition([
	    		'status'         => 'sent',
	    		'email_subject'  => '[DocuSign PHP SDK] - Signature Request Sample',
	    		'template_id'    => '[TEMPLATE_ID]',
	    		'template_roles' => [
	    			$this->client->templateRole([
						'email' 	=> '[SIGNER_EMAIL]',
						'name'  	=> '[SIGNER_NAME]',
						'role_name' => '[ROLE_NAME]'
			    	])
	    		]
	    	])
    	);
	}
}

tucker-eric/docusign-rest-client 适用场景与选型建议

tucker-eric/docusign-rest-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 685.11k 次下载、GitHub Stars 达 30, 最近一次更新时间为 2016 年 05 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「rest」 「docusign」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 tucker-eric/docusign-rest-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 tucker-eric/docusign-rest-client 我们能提供哪些服务?
定制开发 / 二次开发

基于 tucker-eric/docusign-rest-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 685.11k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 30
  • 点击次数: 28
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 30
  • Watchers: 3
  • Forks: 16
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-05-26