You are here

class ProgressTrackerApi in TMGMT Translator Smartling 8.4

Same name and namespace in other branches
  1. 8.3 vendor/smartling/api-sdk-php/src/ProgressTracker/ProgressTrackerApi.php \Smartling\ProgressTracker\ProgressTrackerApi

Class ProgressTrackerApi

@package Smartling\ProgressTracker

Hierarchy

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\ProgressTracker
View 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);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BaseApiAbstract::$auth private property
BaseApiAbstract::$baseUrl private property Smartling API base url.
BaseApiAbstract::$currentClientId private static property
BaseApiAbstract::$currentClientUserAgentExtension private static property
BaseApiAbstract::$currentClientVersion private static property
BaseApiAbstract::$httpClient private property Http Client abstraction.
BaseApiAbstract::$logger private property Logger.
BaseApiAbstract::$projectId private property Project Id in Smartling dashboard
BaseApiAbstract::checkAuthenticationError private function
BaseApiAbstract::CLIENT_LIB_ID_SDK constant
BaseApiAbstract::CLIENT_LIB_ID_VERSION constant
BaseApiAbstract::CLIENT_USER_AGENT_EXTENSION constant
BaseApiAbstract::getAuth protected function
BaseApiAbstract::getBaseUrl protected function
BaseApiAbstract::getCurrentClientId public static function
BaseApiAbstract::getCurrentClientUserAgentExtension public static function
BaseApiAbstract::getCurrentClientVersion public static function
BaseApiAbstract::getDefaultRequestData protected function 1
BaseApiAbstract::getHttpClient protected function
BaseApiAbstract::getLogger protected function
BaseApiAbstract::getProjectId protected function
BaseApiAbstract::HTTP_METHOD_DELETE constant
BaseApiAbstract::HTTP_METHOD_GET constant
BaseApiAbstract::HTTP_METHOD_POST constant
BaseApiAbstract::HTTP_METHOD_PUT constant
BaseApiAbstract::initializeHttpClient protected static function
BaseApiAbstract::normalizeUri private function
BaseApiAbstract::PATTERN_DATE_TIME_ISO_8601 constant PHP equivalent to 'YYYY-MM-DDThh:mm:ssZ'
BaseApiAbstract::processBodyOptions protected function 3
BaseApiAbstract::processError private function
BaseApiAbstract::processErrors private function
BaseApiAbstract::readFile protected function OOP wrapper for fopen() function.
BaseApiAbstract::sendRequest protected function
BaseApiAbstract::setAuth protected function
BaseApiAbstract::setBaseUrl protected function
BaseApiAbstract::setCurrentClientId public static function
BaseApiAbstract::setCurrentClientUserAgentExtension public static function
BaseApiAbstract::setCurrentClientVersion public static function
BaseApiAbstract::setHttpClient protected function
BaseApiAbstract::setLogger protected function
BaseApiAbstract::setProjectId protected function
ProgressTrackerApi::create public static function
ProgressTrackerApi::createRecord public function Creates a new record.
ProgressTrackerApi::deleteRecord public function Deletes record.
ProgressTrackerApi::ENDPOINT_URL constant
ProgressTrackerApi::getToken public function
ProgressTrackerApi::updateRecord public function Updates record
ProgressTrackerApi::__construct public function BaseApiAbstract constructor. Overrides BaseApiAbstract::__construct