-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_model.php
More file actions
35 lines (27 loc) · 974 Bytes
/
create_model.php
File metadata and controls
35 lines (27 loc) · 974 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
30
31
32
33
34
35
<?php
require_once __DIR__ . '/../vendor/autoload.php';
use GlobalMoo\Client;
use GlobalMoo\Exception\ExceptionInterface;
use GlobalMoo\Exception\InvalidRequestException;
use GlobalMoo\Request\CreateModel;
use Symfony\Component\Dotenv\Dotenv;
// Load .env file
new Dotenv()->load(__DIR__ . '/../.env');
try {
$gmooClient = new Client();
$createModelRequest = new CreateModel(...[
'name' => 'Linear Example - v1.0.0',
'description' => 'Created using the globalMOO PHP SDK',
]);
$model = $gmooClient->createModel(...[
'request' => $createModelRequest,
]);
echo(sprintf("Successfully created a model with ID %d.\n", $model->id));
} catch (InvalidRequestException $e) {
echo(sprintf("%s\n", $e->getMessage()));
foreach ($e->error->errors as $error) {
echo(sprintf(" %s: %s\n", $error['property'], $error['message']));
}
} catch (ExceptionInterface $e) {
echo(sprintf("%s\n", $e->getMessage()));
}