Skip to content

Commit de0722f

Browse files
Pull request #11: Fix repeat request on phoneId
Merge in SDK/php_telesign from feature/repeat-request to developer * commit '082106b195d3700a95f74a6043df4c7d2b157351': Fix repeat request on phoneId
2 parents 58c0dfe + 082106b commit de0722f

File tree

4 files changed

+11
-38
lines changed

4 files changed

+11
-38
lines changed

src/phoneid/PhoneIdClient.php

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,33 +22,7 @@ class PhoneIdClient extends RestClient {
2222
* See https://developer.telesign.com/docs/phoneid-api for detailed API documentation.
2323
*/
2424
function phoneid ($phone_number, array $fields = []) {
25-
return $this->post(sprintf(self::PHONEID_RESOURCE, $phone_number), $fields);
26-
}
27-
28-
protected function execute ($method_name, $resource, $fields = [], $date = null, $nonce = null) {
29-
$json_fields = json_encode($fields, JSON_FORCE_OBJECT);
30-
31-
$content_type = in_array($method_name, ["POST", "PUT"]) ? "application/json" : "";
32-
33-
$headers = $this->generateTelesignHeaders(
34-
$this->customer_id,
35-
$this->api_key,
36-
$method_name,
37-
$resource,
38-
$json_fields,
39-
$date,
40-
$nonce,
41-
$this->user_agent,
42-
$content_type
43-
);
44-
45-
$option = in_array($method_name, [ "POST", "PUT" ]) ? "body" : "query";
46-
47-
return new Response($this->client->request($method_name, $resource, [
48-
"headers" => $headers,
49-
$option => in_array($method_name, [ "POST", "PUT"]) ? $json_fields : $fields,
50-
"http_errors" => false
51-
]));
25+
return $this->post(sprintf(self::PHONEID_RESOURCE, $phone_number), $fields, null, null, "application/json", "Basic");
5226
}
5327

5428
}

src/rest/RestClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ protected function execute ($method_name, $resource, $fields = [], $date = null,
225225
$content_is_json = $content_type === "application/json";
226226

227227
if ($content_is_json) {
228-
$form_body = json_encode($fields);
228+
$form_body = json_encode($fields, count($fields) === 0 ? JSON_FORCE_OBJECT : 0);
229229
} else {
230230
$url_encoded_fields = http_build_query($fields, "", "&");
231231
}

src/version/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
namespace telesign\sdk\version;
44

5-
const VERSION = "v3.0.2";
5+
const VERSION = "v3.0.4";

test/Example.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@ class Example {
1313
const ACCOUNT_LIFECYCLE_EVENT = "create";
1414

1515
static function objExampleVerification() {
16-
$obj = new \stdClass();
17-
18-
$info_number = new \stdClass();
19-
$info_number->phone_number = self::PHONE_NUMBER;
20-
21-
$obj->recipient = $info_number;
22-
$info_policy = new \stdClass();
23-
$info_policy->method = "sms";
24-
$obj->verification_policy[] = $info_policy;
16+
$obj = [
17+
"verification_policy" => [
18+
[ "method" => "sms" ]
19+
],
20+
"recipient" => [
21+
"phone_number" => self::PHONE_NUMBER
22+
]
23+
];
2524

2625
return $obj;
2726
}

0 commit comments

Comments
 (0)