|
6 | 6 | use DocuSign\eSign\Client\ApiException; |
7 | 7 | use DocuSign\eSign\Model\Document; |
8 | 8 | use DocuSign\eSign\Model\EnvelopeDefinition; |
| 9 | +use DocuSign\eSign\Model\RecipientIdentityInputOption; |
| 10 | +use DocuSign\eSign\Model\RecipientIdentityPhoneNumber; |
| 11 | +use DocuSign\eSign\Model\RecipientIdentityVerification; |
9 | 12 | use DocuSign\eSign\Model\Recipients; |
10 | 13 | use DocuSign\eSign\Model\Signer; |
11 | | -use DocuSign\eSign\Model\SignHere; |
12 | | -use DocuSign\eSign\Model\Tabs; |
13 | 14 | use DocuSign\Services\SignatureClientService; |
14 | 15 |
|
15 | 16 | class FocusedViewService |
16 | 17 | { |
17 | 18 | public static function worker(array $args, SignatureClientService $client_service, string $demo_path, string $pdf_file): array |
18 | 19 | { |
| 20 | + if (!empty($args['envelope_args']['phone_number'])) { |
| 21 | + try { |
| 22 | + $accounts_api = $client_service->getAccountsApi(); |
| 23 | + $accounts_response = $accounts_api->getAccountIdentityVerificationWithHttpInfo($args['account_id']); |
| 24 | + |
| 25 | + $remaining = $accounts_response[2]['X-RateLimit-Remaining'] ?? null; |
| 26 | + $reset = $accounts_response[2]['X-RateLimit-Reset'] ?? null; |
| 27 | + |
| 28 | + if ($remaining !== null && $reset !== null) { |
| 29 | + $reset_instant = (new DateTime())->setTimestamp((int)$reset); |
| 30 | + error_log("API calls remaining: $remaining"); |
| 31 | + error_log("Next Reset: " . $reset_instant->format(\DateTime::ATOM)); |
| 32 | + } |
| 33 | + |
| 34 | + $workflow_id = ''; |
| 35 | + $workflows_data = $accounts_response[0]->getIdentityVerification(); |
| 36 | + foreach ($workflows_data as $workflow) { |
| 37 | + if ($workflow['default_name'] === 'Phone Authentication') { |
| 38 | + $workflow_id = $workflow['workflow_id']; |
| 39 | + } |
| 40 | + } |
| 41 | + |
| 42 | + if ($workflow_id === '') { |
| 43 | + throw new ApiException('IDENTITY_WORKFLOW_INVALID_ID'); |
| 44 | + } |
| 45 | + |
| 46 | + $args['envelope_args']['workflow_id'] = $workflow_id; |
| 47 | + } catch (ApiException $e) { |
| 48 | + $client_service->showErrorTemplate($e); |
| 49 | + exit; |
| 50 | + } |
| 51 | + } |
| 52 | + |
19 | 53 | #ds-snippet-start:eSign44Step3 |
20 | 54 | $envelope_definition = FocusedViewService::makeEnvelope($args['envelope_args'], $demo_path, $pdf_file); |
21 | 55 | $envelope_api = $client_service->getEnvelopeApi(); |
@@ -80,16 +114,22 @@ public static function makeEnvelope(array $args, string $demo_path, string $pdf_ |
80 | 114 | ] |
81 | 115 | ); |
82 | 116 |
|
83 | | - $sign_here = new SignHere( |
84 | | - [ |
85 | | - 'anchor_string' => '/sn1/', |
86 | | - 'anchor_units' => 'pixels', |
87 | | - 'anchor_y_offset' => '10', |
88 | | - 'anchor_x_offset' => '20' |
89 | | - ] |
90 | | - ); |
| 117 | + if (!empty($args['phone_number'])) { |
| 118 | + $phone_number = new RecipientIdentityPhoneNumber(); |
| 119 | + $phone_number->setCountryCode($args['country_code'] ?? ''); |
| 120 | + $phone_number->setNumber($args['phone_number']); |
91 | 121 |
|
92 | | - $signer->settabs(new Tabs(['sign_here_tabs' => [$sign_here]])); |
| 122 | + $input_option = new RecipientIdentityInputOption(); |
| 123 | + $input_option->setName('phone_number_list'); |
| 124 | + $input_option->setValueType('PhoneNumberList'); |
| 125 | + $input_option->setPhoneNumberList([$phone_number]); |
| 126 | + |
| 127 | + $identity_verification = new RecipientIdentityVerification(); |
| 128 | + $identity_verification->setWorkflowId($args['workflow_id']); |
| 129 | + $identity_verification->setInputOptions([$input_option]); |
| 130 | + |
| 131 | + $signer->setIdentityVerification($identity_verification); |
| 132 | + } |
93 | 133 |
|
94 | 134 | return new EnvelopeDefinition( |
95 | 135 | [ |
|
0 commit comments