Ejemplo n.º 1
0
 /**
  * @param  ConnectionRequest       $request
  * @return null|ConnectionAbstract
  * @throws ConnectionException
  */
 public static function getConnection(ConnectionRequest $request)
 {
     $result = null;
     if (null === $request->getOntimeUrl()) {
         throw new ConnectionException('No OnTime URL specified');
     }
     $connectionType = null;
     if (null !== $request->getClientId() && null !== $request->getRedirectUri()) {
         $connectionType = self::CT_APP;
     } elseif (null !== $request->getUsername() && null !== $request->getPassword() && null !== $request->getClientId() && null !== $request->getClientSecret()) {
         $connectionType = self::CT_USR;
     }
     if (null !== $connectionType) {
         $result = self::getInstance($connectionType, $request);
     } else {
         throw new ConnectionException('Connection type not found because of wrong parameters');
     }
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * @param  ConnectionRequest $request
  * @throws ConnectionException
  */
 public function __construct(ConnectionRequest $request)
 {
     if (null !== $request->getOntimeUrl()) {
         $this->setOntimeUrl($request->getOntimeUrl());
     } else {
         throw new ConnectionException('OnTime URL undefined');
     }
     if (null !== $request->getApiVersion()) {
         $this->setApiVersion($request->getApiVersion());
     } else {
         throw new ConnectionException('API version undefined');
     }
     $this->setOntimeApiUrl($this->getOntimeUrl() . 'api/' . $this->getApiVersion() . '/');
     if (null !== $request->getClientId()) {
         $this->setClientId($request->getClientId());
     } else {
         throw new ConnectionException('Client ID undefined');
     }
     $this->setScope($request->getScope());
     $this->setHttpClient(new Client(['base_url' => $this->getOntimeApiUrl()]));
 }
Ejemplo n.º 3
0
<?php

use OTT\Api\OnTime;
use OTT\Api\Connection\ConnectionRequest;
use OTT\Api\Filter\Projects;
use OTT\Api\Filter\Contacts;
if (file_exists($path = '../vendor/autoload.php')) {
    require $path;
}
ini_set('display_errors', 1);
session_start();
$request = new ConnectionRequest();
$request->setOntimeUrl('https://ottas.axosoft.com/');
$request->setClientId('cfa06ce5-c761-4b78-82a8-b4df13cc98ae');
$request->setClientSecret('w3RwSX9BBxYys3LUVqlSWxXxyfyCuaUXWAsSOZ2vMxAM8eCY1dV41r1CGNkvoJN58ynQWwQOtF4mIUZ7lsulHyvJsFSYXyzVIFgA');
$request->setUsername('*****@*****.**');
$request->setPassword('ottas33');
if (isset($_SESSION['access_token'])) {
    $request->setSavedToken($_SESSION['access_token']);
}
$ontime = new OnTime($request);
if (null !== $ontime->getToken()) {
    $_SESSION['access_token'] = $ontime->getToken();
}
var_dump($ontime->releases());
//$projectFilter = new Projects();
//$projectFilter->setId(123);
//$projects = $ontime->projects($projectFilter);
//var_dump($projects);
//$contactFilter = new Contacts();
//$contactFilter->setCustomerId(2);
Ejemplo n.º 4
0
 /**
  * @return ConnectionRequest
  */
 private function getConfigOk()
 {
     $request = new ConnectionRequest();
     $request->setOntimeUrl('https://ottas.axosoft.com/');
     $request->setClientId('cfa06ce5-c761-4b78-82a8-b4df13cc98ae');
     $request->setClientSecret('w3RwSX9BBxYys3LUVqlSWxXxyfyCuaUXWAsSOZ2vMxAM8eCY1dV41r1CGNkvoJN58ynQWwQOtF4mIUZ7lsulHyvJsFSYXyzVIFgA');
     $request->setUsername('*****@*****.**');
     $request->setPassword('ottas33');
     return $request;
 }