Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
zugarzeeker committed Oct 12, 2018
1 parent 7956b60 commit 80f3021
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
19 changes: 8 additions & 11 deletions examples/execute-sdk.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
<?php
header('Content-Type: application/json;charset=utf-8');

require_once dirname(__FILE__).'/vendor/autoload.php';
require_once '../lib/Acrosure.php';
// require_once dirname(__FILE__).'/vendor/autoload.php';

$acrosureClient = new AcrosureClient([
"token" => $_ENV["TEST_SECRET_TOKEN"],
"endpointBase" => $_ENV["TEST_API_URL"] // as optional
]);

function jsonRemoveUnicodeSequences($struct) {
return preg_replace("/\\\\u([a-f0-9]{4})/e", "iconv('UCS-4LE','UTF-8',pack('V', hexdec('U$1')))", json_encode($struct, JSON_PRETTY_PRINT));
}
$applicationId = '';
$NEWLINE = "\n";
$APP_DATA = json_decode(file_get_contents("data.json"), false);
Expand All @@ -26,13 +23,13 @@ function jsonRemoveUnicodeSequences($struct) {

echo $NEWLINE;
echo '[create]'.$NEWLINE;
echo jsonRemoveUnicodeSequences($resp).$NEWLINE;
echo jsonRemoveUnicodeSequences($resp, true).$NEWLINE;
echo '-------------------------------'.$NEWLINE;
$applicationId = $resp->data->id;
$resp = $acrosureClient->getApplicationManager()->getPackages($applicationId);
echo $NEWLINE;
echo '[get-packages]'.$NEWLINE;
echo jsonRemoveUnicodeSequences($resp).$NEWLINE;
echo jsonRemoveUnicodeSequences($resp, true).$NEWLINE;
echo '-------------------------------'.$NEWLINE;
$packageCode = $resp->data[0]->package_code;
$resp = $acrosureClient->getApplicationManager()->selectPackage([
Expand All @@ -41,7 +38,7 @@ function jsonRemoveUnicodeSequences($struct) {
]);
echo $NEWLINE;
echo '[select-package]'.$NEWLINE;
echo jsonRemoveUnicodeSequences($resp).$NEWLINE;
echo jsonRemoveUnicodeSequences($resp, true).$NEWLINE;
echo '-------------------------------'.$NEWLINE;
$resp = $acrosureClient->getApplicationManager()->update([
"application_id" => $applicationId,
Expand All @@ -51,13 +48,13 @@ function jsonRemoveUnicodeSequences($struct) {
]);
echo $NEWLINE;
echo "[update]".$NEWLINE;
echo jsonRemoveUnicodeSequences($resp).$NEWLINE;
echo jsonRemoveUnicodeSequences($resp, true).$NEWLINE;
echo '-------------------------------'.$NEWLINE;
$resp = $acrosureClient->getApplicationManager()->confirm($applicationId);
echo $NEWLINE;
echo '[confirm]'.$NEWLINE;
echo jsonRemoveUnicodeSequences($resp).$NEWLINE;
echo jsonRemoveUnicodeSequences($resp, true).$NEWLINE;
echo '==============================='.$NEWLINE;
echo jsonRemoveUnicodeSequences($resp).$NEWLINE;
echo jsonRemoveUnicodeSequences($resp, true).$NEWLINE;
echo '=============== DONE ==================='.$NEWLINE;
?>
2 changes: 1 addition & 1 deletion examples/index.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<a href="/execute-sdk.php">TEST SDK</a>
<a href="/execute-sdk.php">TEST SDK</a>

0 comments on commit 80f3021

Please sign in to comment.