1. Go to this page and download the library: Download astermd/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/ */
astermd / sdk example snippets
use AsterMD\Sdk\AsterMDClient;
use AsterMD\Sdk\Enum\Event;
$client = new AsterMDClient(
clientId: 'your-client-id',
clientSecret: 'your-client-secret',
);
// 1. Start a session (implicit `visit_page` event server-side)
$session = $client->sessions()->create()->data()['session'];
// 2. Pre-qualifying form
$client->intakeSubmissions()->create(
session: $session,
event: Event::PreQualifyingInitiated,
teleformId: 'your-teleform-id',
// `data` is a list of field objects: id / name / label / type / value
data: [
['id' => 'name-1', 'name' => 'name', 'label' => 'Full name', 'type' => 'text', 'value' => [['value' => 'Jane']]],
],
);
// 3. Create the opportunity, attaching the session
$opportunity = $client->opportunities()->create([
'first_name' => 'Jane',
'email' => '[email protected]',
'sessions' => [$session],
])->data();
// 4. Intake
$client->intakeSubmissions()->update(
session: $session,
event: Event::IntakeCompleted,
teleformId: 'your-teleform-id',
data: [
['id' => 'name-1', 'name' => 'name', 'label' => 'Full name', 'type' => 'text', 'value' => [['value' => 'Jane']]],
['id' => 'dob-1', 'name' => 'dob', 'label' => 'Date of birth', 'type' => 'date', 'value' => [['value' => '1990-01-15']]],
],
);
// 5. After external payment settles, create the treatment (= order)
$client->treatments()->create([
'external_order_id' => 'EXT-123',
'patient' => ['id' => '...'],
'product' => ['id' => '...'],
]);