You are here

function createJobDemo in TMGMT Translator Smartling 8.4

Same name and namespace in other branches
  1. 8.3 vendor/smartling/api-sdk-php/examples/jobs-example.php \createJobDemo()

Parameters

\Smartling\AuthApi\AuthApiInterface $authProvider:

string $projectId:

Return value

string

1 call to createJobDemo()
jobs-example.php in vendor/smartling/api-sdk-php/examples/jobs-example.php

File

vendor/smartling/api-sdk-php/examples/jobs-example.php, line 87

Code

function createJobDemo($authProvider, $projectId) {
  echo "--- Create job ---\n";
  $result = FALSE;
  $jobs = \Smartling\Jobs\JobsApi::create($authProvider, $projectId);
  $params = new \Smartling\Jobs\Params\CreateJobParameters();
  $params
    ->setName("Test Job Name " . time());
  $params
    ->setDescription("Test Job Description " . time());
  $params
    ->setDueDate(DateTime::createFromFormat('Y-m-d H:i:s', '2020-01-01 19:19:17', new DateTimeZone('UTC')));
  $params
    ->setTargetLocales([
    'es',
    'fr',
  ]);
  $st = microtime(true);
  try {
    $response = $jobs
      ->createJob($params);
  } catch (\Smartling\Exceptions\SmartlingApiException $e) {
    var_dump($e
      ->getErrors());
  }
  $et = microtime(true);
  $time = $et - $st;
  echo vsprintf('Request took %s seconds.%s', [
    round($time, 3),
    "\n\r",
  ]);
  if (!empty($response)) {
    $result = $response['translationJobUid'];
    var_dump($response);
  }
  return $result;
}