设备控制 / laravel-oathello
一个用于 Oathello API 的 Laravel 封装
v1.0.9
2022-04-28 09:41 UTC
Requires
- guzzlehttp/guzzle: ^7.4
Requires (Dev)
README
laravel-oathello
Oathello API Laravel 包。
Oathello 是为金融行业构建的签名 API。
安装
composer require equipmentc/laravel-oathello
发布配置
php artisan vendor:publish --tag=oathello
添加到 .env
OATHELLO_ENDPOINT=https://sign.oathello.com/api/ (可选)
OATHELLO_API_KEY=xyz
OATHELLO_CALLBACK_URL=https://xyz.tld
如何使用
使用此包有两种方式。
第一种是使用 Oathello 基础类直接查询 Oathello RESTful API。
1. 使用 Oathello 基础类直接查询 Oathello RESTful API。
您可以在以下位置找到 API 端点 https://sign.oathello.com/swagger
use Equipmentc\Oathello\Oathello;
$oathello = new Oathello;
$oathello->get('Session/xyz');
$oathello->post('Session', $array);
或使用外观
Oathello::get('Session/xyz');
Oathello::post('Session', $array);
2. 对于嵌入式集成,您可能只关心文档。
在这种情况下,您可以使用 OathelloSession 和 Document 辅助类简化过程。
创建一个或多个(信封)文档的会话
use Equipmentc\Oathello\Session as OathelloSession;
$documents = [...]; (See a document array example below)
$oathelloSession = new OathelloSession;
$oathelloSession->create($documents [, $metadata = null ]);
or the facade
$documents = [...]; (See a document array example below)
OathelloSession::create($documents [, $metadata = null ]);
检索会话
$oathelloSession->get($sessionId);
or the facade
OathelloSession::get($sessionId);
取消会话
$oathelloSession->cancel($sessionId);
or the facade
OathelloSession::cancel($sessionId);
文档示例使用
use Equipmentc\Oathello\Document;
$document = new Document;
$file = $document->get($documentID);
$document->download($file);
or the facade
$file = Document::get($documentID);
Document::download($file);
如何嵌入文档
@document(SESSION_ID, DOCUMENT_ID, SIGNER_ID (optional))
@onDocumentSigned
// add your javascript without script tags
@endonDocumentSigned
@onSessionFinished
// add your javascript without script tags
@endonSessionFinished
测试
将您自己的 API 密钥和回调 URL 添加到 phpunit.xml 文件中。
示例文档
$documents = [[
'title' => 'Example',
'fileName' => 'example.pdf',
'mode' => 'Signing',
'content' => '{{YOUR_BASE64_ENCODED_DOCUMENT}}',
"instructions" => [[
"userInputFields" => [[
"title" => "Add signature",
"type" => "signature",
"for" => "signer",
"region" => [
"pageNumber" => 1,
"x" => 260,
"y" => 395,
"width" => 120,
"height" => 20,
"isVisible" => true,
],
"declarations" => []
]],
]],
"textFields" => [[
"content" => "[DATE]",
"region" => [
"pageNumber" => 1,
"x" => 280,
"y" => 735,
"width" => 60,
"height" => 10,
"isVisible" => true
],
"fontSize" => 8,
]],
]];