1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Sausin\Signere\Http\Controllers\Admin; |
4
|
|
|
|
5
|
|
|
use Illuminate\Http\Request; |
6
|
|
|
use Sausin\Signere\ExternalSign; |
7
|
|
|
use Illuminate\Support\Facades\Config; |
8
|
|
|
use Sausin\Signere\Http\Controllers\Controller; |
9
|
|
|
|
10
|
|
|
class ExternalSignController extends Controller |
11
|
|
|
{ |
12
|
|
|
/** @var \Sausin\Signere\ExternalSign */ |
13
|
|
|
protected $extSign; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Create a new controller instance. |
17
|
|
|
* |
18
|
|
|
* @param \Sausin\Signere\ExternalSign $extSign |
19
|
|
|
*/ |
20
|
3 |
|
public function __construct(ExternalSign $extSign) |
21
|
|
|
{ |
22
|
3 |
|
parent::__construct(); |
23
|
|
|
|
24
|
3 |
|
$this->extSign = $extSign; |
25
|
3 |
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Get the URLs to sign the Document. |
29
|
|
|
* |
30
|
|
|
* @param string $documentId |
31
|
|
|
* @return \Illuminate\Http\Response |
32
|
|
|
*/ |
33
|
1 |
|
public function index(string $documentId) |
34
|
|
|
{ |
35
|
1 |
|
return $this->extSign->getUrlForSign($documentId) |
36
|
1 |
|
->getBody() |
37
|
1 |
|
->getContents(); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Get the URLs to view a viewerapplet in a iFrame on your site. |
42
|
|
|
* |
43
|
|
|
* @param string $documentId |
44
|
|
|
* @param string $domain |
45
|
|
|
* @param string $language |
46
|
|
|
* @return \Illuminate\Http\Response |
47
|
|
|
*/ |
48
|
1 |
|
public function show(string $documentId, string $domain, string $language) |
49
|
|
|
{ |
50
|
1 |
|
return $this->extSign->getUrlForApplet($documentId, ['Domain' => $domain, 'Language' => $language]) |
51
|
1 |
|
->getBody() |
52
|
1 |
|
->getContents(); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Creates an externalsign request. |
57
|
|
|
* |
58
|
|
|
* @param Request $request |
59
|
|
|
* @return \Illuminate\Http\Response |
60
|
|
|
*/ |
61
|
1 |
|
public function store(Request $request) |
62
|
|
|
{ |
63
|
1 |
|
$this->validate($request, [ |
64
|
1 |
|
'description' => 'required|string|min:1|max:255', |
65
|
|
|
'ext_doc_id' => 'required|string|min:1|max:255', |
66
|
|
|
'file_content' => 'required|string', |
67
|
|
|
'filename' => 'required|string|min:1|max:255', |
68
|
|
|
// unique ref is nothing but the signee ref returned |
69
|
|
|
// by signere when a receiver is created |
70
|
|
|
'signee_refs.*.unique_ref' => 'required|string|size:36', |
71
|
|
|
'signee_refs.*.first_name' => 'required|string|min:1|max:255', |
72
|
|
|
'signee_refs.*.last_name' => 'required|string|min:1|max:255', |
73
|
|
|
'signee_refs.*.email' => 'required|email|min:1|max:255', |
74
|
|
|
'title' => 'required|string|min:1|max:255', |
75
|
|
|
]); |
76
|
|
|
|
77
|
1 |
|
$body = []; |
78
|
|
|
|
79
|
|
|
// this is used to only set the keys which have been sent in |
80
|
1 |
|
$body['Description'] = $request->description; |
81
|
1 |
|
$body['ExternalDocumentId'] = $request->ext_doc_id; |
82
|
1 |
|
$body['FileContent'] = $request->file_content; |
|
|
|
|
83
|
1 |
|
$body['Filename'] = $request->filename; |
84
|
1 |
|
$body['Title'] = $request->title; |
85
|
|
|
|
86
|
1 |
|
$body['SigneeRefs'] = []; |
87
|
|
|
|
88
|
|
|
// populate the signee references |
89
|
1 |
View Code Duplication |
foreach ($request->signee_refs as $signee) { |
|
|
|
|
90
|
|
|
// append this to the body |
91
|
1 |
|
$body['SigneeRefs'][] = [ |
92
|
1 |
|
'UniqueRef' => $signee['unique_ref'], |
93
|
1 |
|
'FirstName' => $signee['first_name'], |
94
|
1 |
|
'LastName' => $signee['last_name'], |
95
|
1 |
|
'Email' => $signee['email'], |
96
|
|
|
]; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
// populate the callback URLs |
100
|
1 |
|
$body['ReturnUrlError'] = Config::get('signere.sign_error_url'); |
101
|
1 |
|
$body['ReturnUrlSuccess'] = Config::get('signere.sign_success_url'); |
102
|
1 |
|
$body['ReturnUrlUserAbort'] = Config::get('signere.sign_cancel_url'); |
103
|
|
|
|
104
|
1 |
|
return $this->extSign->createRequest($body) |
105
|
1 |
|
->getBody() |
106
|
1 |
|
->getContents(); |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.