***** Full App Test
";
echo "*** Section 1 - Get account information/balance ". date("m-d-Y H:i:s") . "
";
$docsmit = new DocsmitAPI($email, $hashedPW, $softwareID, SECUREURL . "/api/v1");
$docsmit->get("/account/info");
echo "OUTPUT /account/info = " . print_r($docsmit->responseJSON(), true) . "
";
$acctBalMin = 20;
if ($docsmit->responseJSON()->creditBalance < $acctBalMin) {
echo "Account Balance of " . $docsmit->responseJSON()->creditBalance. " is less than required amount of $acctBalMin.
Not enough to continue.
";
break;
}
ob_flush();
////// SECTION 2
$docsmit = new DocsmitAPI($email, $hashedPW, $softwareID, SECUREURL . "/api/v1");
echo "
*** Section 2 - Login ". date("m-d-Y H:i:s") . "
";
echo "OUTPUT new DocsmitAPI = " . print_r($docsmit->responseJSON(), true) . "
";
ob_flush();
echo "
*** Section 3 - Create new message with /messages/new " . date("m-d-Y H:i:s") . "
";
$body = array(
"title" => "Test message from 'full_app_test' - " . date("m-d-Y H:i:s"),
"physicalParties" => array(
array(
"firstName" => "Mike",
"lastName" => "Knight",
"organization" => "Docsmit.com, Inc.",
"address1" => "74 S Livingston Ave",
"city" => "Livingston",
"state" => "NJ",
"postalCode" => "07039",
"sendType" => DocsmitAPI::ST_CERTERR,
"envelope" => DocsmitAPI::ENV_10,
"mailClass"=>"certified"
),
array(
"firstName" => "Kevin",
"lastName" => "Jensen",
"organization" => "SIG Management, LLC",
"address1" => "808 Bergen Ave, Suite 101",
"city" => "Jersey City",
"state" => "NJ",
"postalCode" => "07305",
"sendType" => DocsmitAPI::ST_CERTERR,
"envelope" => DocsmitAPI::ENV_10,
"mailClass"=>"certified"
)
),
"rtnName"=> "John Paul",
"rtnOrganization"=> "ABC & Co",
"rtnAddress1"=> "26 Journal Square, 8th Floor",
"rtnCity"=> "Jersey City",
"rtnState"=> "NJ",
"rtnZip"=> "07306",
"billTo" => "Testing",
);
$docsmit->post('/messages/new', $body);
echo "INPUT body for /messages/new = " . print_r($body, true) . "
";
echo " " . print_r($docsmit->responseJSON(),true) . "
";
if(isset($docsmit->responseJSON()->code) && $docsmit->responseJSON()->code != 201)
{
die("Error occurred while creating new message.");
}
$newMessageID = $docsmit->responseJSON()->messageID;
echo "
OUTPUT New message's messageID = " . $newMessageID . "
";
ob_flush();
echo "
*** Section 4 - Create upload file to the new message with /messages/{msgID}/upload " . date("m-d-Y H:i:s") . "
";
$docsmit = new DocsmitAPI($email, $hashedPW, $softwareID, SECUREURL . "/api/v1");
$params['filePath'] = TESTPDF;
echo "INPUT params for /upload = " . print_r($params, true) . "
";
$docsmit->post("/messages/$newMessageID/upload", $params, 1);
echo "OUTPUT /upload status = ". $docsmit->status() . "
";
echo "OUTPUT /upload response = " . print_r($docsmit->responseJSON(), true) . "
";
ob_flush();
echo "
*** Section 5 - get price to send " . date("m-d-Y H:i:s") . "
";
$docsmit = new DocsmitAPI($email, $hashedPW, $softwareID, SECUREURL . "/api/v1");
$params = array();
echo "INPUT params for /priceCheck = " . print_r($params, true) . "
";
$docsmit->get("/messages/$newMessageID/priceCheck", $params);
echo "OUTPUT /send status = ". $docsmit->status() . "
";
echo "/priceCheck response = " . print_r($docsmit->responseJSON(), true) . "
";
ob_flush();
echo "
*** Section 6 - Send the message " . date("m-d-Y H:i:s") . "
";
$docsmit = new DocsmitAPI($email, $hashedPW, $softwareID, SECUREURL . "/api/v1");
$body = array();
$docsmit->post("/messages/$newMessageID/send", $body);
echo "OUTPUT /send status = ". $docsmit->status() . "
";
echo "/send response = " . print_r($docsmit->responseJSON(), true) . "
";
ob_flush();
echo "
*** Section 7 - Get the message's status " . date("m-d-Y H:i:s") . "
";
$docsmit = new DocsmitAPI($email, $hashedPW, $softwareID, SECUREURL . "/api/v1");
$arr["messageIDList"] = $newMessageID;
$docsmit->get('/messages/sent', $arr);
echo "OUTPUT /sent status = ". $docsmit->status() . "
";
echo "/send response = " . print_r($docsmit->responseJSON(), true) . "
";
$testCase = null; // so we don't see a dump of $docsmit again
echo "
***** COMPLETION " . date("m-d-Y H:i:s") . "
";
ob_end_flush();
break;
case "sent_folder":
$docsmit = new DocsmitAPI($email, $hashedPW, $softwareID, SECUREURL . "/api/v1");
$arr = array();
//$arr["debug"] = true;
$docsmit->get('/messages/sent', $arr);
break;
case null:
echo "Click a test case below for a result.
";
break;
default:
echo "Test Case Not Found. Click one of the test cases.";
break;
}
if ($testCase != null) {
echo "HTTP response code = " . $docsmit->status() . "
";
echo "responseBody = " . $docsmit->responseBody() . "
";
}
echo "Available Test Cases:
";
foreach ($cases as $index => $case) {
echo ++$index . ". " . mylink($case);
}
?>