class ProgressTrackerApi in TMGMT Translator Smartling 8.4
Same name and namespace in other branches
- 8.3 vendor/smartling/api-sdk-php/src/ProgressTracker/ProgressTrackerApi.php \Smartling\ProgressTracker\ProgressTrackerApi
Class ProgressTrackerApi
@package Smartling\ProgressTracker
Hierarchy
- class \Smartling\BaseApiAbstract
- class \Smartling\ProgressTracker\ProgressTrackerApi
Expanded class hierarchy of ProgressTrackerApi
3 files declare their use of ProgressTrackerApi
- ProgressTrackerApiFunctionalTest.php in vendor/
smartling/ api-sdk-php/ tests/ functional/ ProgressTrackerApiFunctionalTest.php - ProgressTrackerApiTest.php in vendor/
smartling/ api-sdk-php/ tests/ unit/ ProgressTrackerApiTest.php - SmartlingApiFactory.php in src/
Smartling/ SmartlingApiFactory.php - SmartlingApiFactory.php.
File
- vendor/
smartling/ api-sdk-php/ src/ ProgressTracker/ ProgressTrackerApi.php, line 16
Namespace
Smartling\ProgressTrackerView source
class ProgressTrackerApi extends BaseApiAbstract {
const ENDPOINT_URL = 'https://api.smartling.com/progress-tracker-api/v2';
/**
* {@inheritdoc}
*/
public function __construct($projectId, ClientInterface $client, $logger = null, $service_url = null) {
parent::__construct($projectId, $client, $logger, $service_url);
// Do not include project_id into base url since
// progress tracker service has /accounts/{account}/token
// endpoint without project id.
$this
->setBaseUrl(rtrim($service_url, '/'));
}
/**
* @param AuthApiInterface $authProvider
* @param string $projectId
* @param LoggerInterface $logger
*
* @return ProgressTrackerApi
*/
public static function create(AuthApiInterface $authProvider, $projectId, $logger = null) {
$client = static::initializeHttpClient(self::ENDPOINT_URL);
$instance = new self($projectId, $client, $logger, self::ENDPOINT_URL);
$instance
->setAuth($authProvider);
return $instance;
}
/**
* @param string $accountUid
*
* @return array
* @throws \Smartling\Exceptions\SmartlingApiException
*/
public function getToken($accountUid) {
$requestData = $this
->getDefaultRequestData('query', []);
$endpoint = vsprintf('accounts/%s/token', [
$accountUid,
]);
return $this
->sendRequest($endpoint, $requestData, static::HTTP_METHOD_GET);
}
/**
* Creates a new record.
*
* @param $spaceId
* @param $objectId
* @param RecordParameters $parameters
*
* @return array
* @throws \Smartling\Exceptions\SmartlingApiException
*/
public function createRecord($spaceId, $objectId, RecordParameters $parameters) {
$requestData = $this
->getDefaultRequestData('json', $parameters
->exportToArray());
$endpoint = vsprintf('projects/%s/spaces/%s/objects/%s/records', [
$this
->getProjectId(),
$spaceId,
$objectId,
]);
return $this
->sendRequest($endpoint, $requestData, static::HTTP_METHOD_POST);
}
/**
* Deletes record.
*
* @param $spaceId
* @param $objectId
* @param $recordId
*
* @return array
* @throws \Smartling\Exceptions\SmartlingApiException
*/
public function deleteRecord($spaceId, $objectId, $recordId) {
$requestData = $this
->getDefaultRequestData('query', []);
$endpoint = vsprintf('projects/%s/spaces/%s/objects/%s/records/%s', [
$this
->getProjectId(),
$spaceId,
$objectId,
$recordId,
]);
return $this
->sendRequest($endpoint, $requestData, static::HTTP_METHOD_DELETE);
}
/**
* Updates record
* @param $spaceId
* @param $objectId
* @param $recordId
* @param RecordParameters $parameters
* @return mixed
* @throws \Smartling\Exceptions\SmartlingApiException
*/
public function updateRecord($spaceId, $objectId, $recordId, RecordParameters $parameters) {
$requestData = $this
->getDefaultRequestData('json', $parameters
->exportToArray());
$endpoint = vsprintf('projects/%s/spaces/%s/objects/%s/records/%s', [
$this
->getProjectId(),
$spaceId,
$objectId,
$recordId,
]);
return $this
->sendRequest($endpoint, $requestData, static::HTTP_METHOD_PUT);
}
}