1. Go to this page and download the library: Download smartwaiver/smartwaiver-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
smartwaiver / smartwaiver-sdk example snippets
// The API Key for your account
$apiKey = '[INSERT API KEY]';
// Set up your Smartwaiver connection using your API Key
$sw = new Smartwaiver($apiKey);
// Now request a list of all the waiver templates
$templates = $sw->getWaiverTemplates();
// The API Key for your account
$apiKey = '[INSERT API KEY]';
// Set up your Smartwaiver connection using your API Key
$sw = new Smartwaiver($apiKey);
// The unique ID of the template to be retrieved
$templateId = '[INSERT TEMPLATE ID]';
// Retrieve a specific template (SmartwaiverTemplate object)
$template = $sw->getWaiverTemplate($templateId);
// Access properties of the template
echo PHP_EOL . 'List single template:' . PHP_EOL;
echo $template->templateId . ': ' . $template->title . PHP_EOL;
// The API Key for your account
$apiKey = '[INSERT API KEY]';
// Set up your Smartwaiver connection using your API Key
$sw = new Smartwaiver($apiKey);
// Get a list of summaries of waivers
$waiverSummaries = $sw->getWaiverSummaries();
// Loop through the waivers and access their properties
echo 'List all waivers:' . PHP_EOL;
foreach ($waiverSummaries as $waiverSummary) {
echo $waiverSummary->waiverId . ': ' . $waiverSummary->title . PHP_EOL;
}
// Set the limit
$limit = 5;
// Get a list of summaries of waivers
$waiverSummaries = $sw->getWaiverSummaries($limit);
// Set the limit
$limit = 5;
// Set the verified parameter
$verified = false;
// Get a list of summaries of waivers
$waiverSummaries = $sw->getWaiverSummaries($limit, $verified);
// An example limiting the parameters
$limit = 5; // Limit number returned to 5
$verified = true; // Limit only to waivers that were signed at a kiosk or verified over email
$templateId = '[INSERT TEMPLATE ID]'; // Limit query to waivers of this template ID
$fromDts = date('c', strtotime('2016-11-01')); // Limit to waivers signed in November of 2016
$toDts = date('c', strtotime('2016-12-01'));
$firstName = 'Kyle'; // Limit to waivers with a participant named Kyle Smith
$lastName = 'Smith';
// Get a list of summaries of waivers
$waiverSummaries = $sw->getWaiverSummaries($limit, $verified, $templateId, $fromDts, $toDts);
// The API Key for your account
$apiKey = '[INSERT API KEY]';
// Set up your Smartwaiver connection using your API Key
$sw = new Smartwaiver($apiKey);
// The unique ID of the signed waiver to be retrieved
$waiverId = '[INSERT WAIVER ID]';
// Get a specific waiver
$waiver = $sw->getWaiver($waiverId);
// The unique ID of the signed waiver to be retrieved
$waiverId = '[INSERT WAIVER ID]';
$pdf = true;
// Get the waiver object
$waiver = $sw->getWaiver($waiverId, $pdf);
// The API Key for your account
$apiKey = '[INSERT API KEY]';
// Set up your Smartwaiver connection using your API Key
$sw = new Smartwaiver($apiKey);
// TThe unique ID of the signed waiver to retrieve the photos for
$waiverId = '[INSERT WAIVER ID]';
// Get the photos for a specific waiver
$photos = $sw->getWaiverPhotos($waiverId);
// Loop through photos and print out some meta-data
foreach ($photos->photos as $photo) {
echo $photo->photoId . ': ' . $photo->date;
// Other fields
// echo $photo->type;
// echo $photo->tag;
// echo $photo->fileType;
// echo $photo->photo; // Base 64 encoded photo
}
// The API Key for your account
$apiKey = '[INSERT API KEY]';
// Set up your Smartwaiver connection using your API Key
$sw = new Smartwaiver($apiKey);
// Request all waivers signed in 2017
$search = $sw->search('', '2017-01-01 00:00:00');
// Print out some information about the result of the search
echo 'Search Complete:' . PHP_EOL;
echo "\t" . 'Search ID: ' . $search->guid . PHP_EOL;
echo "\t" . 'Waiver Count: ' . $search->count . PHP_EOL;
echo "\t" . $search->pages . ' pages of size ' . $search->pageSize . PHP_EOL . PHP_EOL;
// First we set up our list
$nameList = [];
// Loop through all the pages in the search result
for($i = 0; $i < $search->pages; $i++) {
echo 'Requesting page: ' . $i . '/' . $search->pages . '...' . PHP_EOL;
// Request each page from the server
$waivers = $sw->searchResult($search, $i);
echo 'Processing page: ' . $i . '/' . $search->pages . '...' . PHP_EOL;
// Loop through the waivers and create a comma separated list of first names
foreach ($waivers as $waiver) {
array_push($nameList, $waiver->firstName);
// View all accessible properties of a waiver object in:
// examples/waivers/WaiverProperties.php
}
}
// The unique ID of the template to search for
$templateId = '[INSERT TEMPLATE ID]';
// Request all waivers signed for this template
$search = $sw->search($templateId);
// Request all waivers signed that not have been email verified
$search = $sw->search('', '', '', '', '', false);
// Request all waivers signed for this template after the given date
$search = $sw->search($templateId, '2017-01-01 00:00:00');
// Request all waivers signed for this template before the given date
$search = $sw->search($templateId, '', '2017-01-01 00:00:00');
// Request all waivers signed for this template with a participant name Kyle
$search = $sw->search($templateId, '', '', 'Kyle');
// Request all waivers signed for this template with a participant name Kyle Smith
$search = $sw->search($templateId, '', '', 'Kyle', 'Smith');
// Request all waivers signed with a participant name Kyle that have been email verified
$search = $sw->search('', '', '', 'Kyle', '', true);
// Request all waivers signed in ascending sorted order
//$search = $sw->search($templateId, '', '', '', '', null, false);
// The API Key for your account
$apiKey = '[INSERT API KEY]';
// Set up your Smartwaiver connection using your API Key
$sw = new Smartwaiver($apiKey);
// Get the current webhook settings
$webhooks = $sw->getWebhookConfig();
// The new values to set
$endpoint = 'http://endpoint.example.org';
$emailValidationRequired = SmartwaiverWebhook::WEBHOOK_AFTER_EMAIL_ONLY;
// Set the webhook to new values
$webhook = $sw->setWebhookConfig($endpoint, $emailValidationRequired);
// Access the new webhook config
echo 'Successfully set new configuration.' . PHP_EOL;
echo 'Endpoint: ' . $newWebhook->endpoint . PHP_EOL;
echo 'EmailValidationRequired: ' . $newWebhook->emailValidationRequired . PHP_EOL;
$sw->deleteWebhookConfig();
// The API Key for your account
$apiKey = '[INSERT API KEY]';
// Set up your Smartwaiver connection using your API Key
$sw = new Smartwaiver($apiKey);
// Get the current webhook queue information
$queues = $sw->getWebhookQueues();
// Retrieve a message from the account queue
$message = $sw->getWebhookQueueAccountMessage();
// The Unique ID of the waiver template
$templateId = '[INSERT TEMPLATE ID]';
// Retrieve a message from the template queue
$message = $sw->getWebhookQueueAccountMessage($templateId);
// Check for empty queue
if (is_null($message)) {
echo 'No messages in account queue.' . PHP_EOL;
exit;
}
// Print out message info
echo 'Message in Account Queue' . PHP_EOL;
echo "\tMessage ID: " . $message->messageId . PHP_EOL;
echo "\tMessage Payload: " . PHP_EOL;
echo "\t\tWaiver ID: " . $message->body->uniqueId . PHP_EOL;
echo "\t\tEvent: " . $message->body->event . PHP_EOL;
// Optionally we can delete the message when we retrieve it, by passing a delete flag
$message = $sw->getWebhookQueueAccountMessage(true);
// The API Key for your account
$apiKey = '[INSERT API KEY]';
// Set up your Smartwaiver connection using your API Key
$sw = new Smartwaiver($apiKey);
// The Waiver ID to access
$waiverId = 'InvalidWaiverId';
// Try to get the waiver object
$waiver = $sw->getWaiver($waiverId);
try
{
// Try to get the waiver object
$waiver = $sw->getWaiver($waiverId);
}
catch (SmartwaiverHTTPException $se)
{
// Print out that we encountered an error
echo 'Error retrieving waiver from API server...' . PHP_EOL . PHP_EOL;
}
// The code will be the HTTP Status Code returned
echo 'Error Code: ' . $se->getCode() . PHP_EOL;
// The message will be informative about what was wrong with the request
echo 'Error Message: ' . $se->getMessage() . PHP_EOL . PHP_EOL;
// Also
try
{
// Try to get the waiver object
$waiver = $sw->getWaiver($waiverId);
}
catch (SmartwaiverRateLimitException $se)
{
// The number of requests that have taken place in the current window
echo 'Number of requests: ' . $se->requests . PHP_EOL;
// The max number of requests for routes of this type in the current window
echo 'Max requests: ' . $se->max . PHP_EOL;
// The number of seconds to wait until trying again
echo 'Retry after: ' . $se->retryAfter . PHP_EOL;
}
// The API Key for your account
$apiKey = '[INSERT API KEY]';
// Set up your Smartwaiver connection using your API Key
$sw = new Smartwaiver($apiKey);
// Get a list of all signed waivers for this account
$response = $sw->getWaiverSummariesRaw();
// The response object has two variables, status code and response body
echo 'Status Code: ' . $response->statusCode . PHP_EOL;
echo 'Body: ' . $response->body . PHP_EOL;