-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-lead.php
More file actions
29 lines (24 loc) · 898 Bytes
/
Copy pathcreate-lead.php
File metadata and controls
29 lines (24 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
use PHPinnacle\Langcat\Client;
use PHPinnacle\Langcat\Enum\StudentType;
use PHPinnacle\Langcat\Request\Students\CreateStudentRequest;
if ($argc !== 4 || ($schoolId = filter_var($argv[1], FILTER_VALIDATE_INT, ['options' => [
'min_range' => 1,
]])) === false) {
fwrite(STDERR, "Usage: php examples/create-lead.php <positive-school-id> <first-name> <last-name>\n");
exit(1);
}
/** @var Client $client */
$client = require __DIR__ . '/bootstrap.php';
// Each run creates a new lead without parent accounts in the selected school.
$result = $client
->students()
->create(
CreateStudentRequest::make()
->schoolId($schoolId)
->firstName($argv[2])
->lastName($argv[3])
->type(StudentType::Lead)
->hasParentAccounts(false),
);
echo json_encode(['student_id' => $result->id], JSON_THROW_ON_ERROR) . "\n";