Beispiel #1
0
 /**
  *
  */
 public function testInitialization()
 {
     $resultT1 = new OnTime($this->getConfigOk());
     $this->assertInstanceOf('OTT\\Api\\Connection\\ConnectionAbstract', $resultT1->getConnection());
     $this->assertInstanceOf('GuzzleHttp\\Client', $resultT1->getConnection()->getHttpClient());
     $this->assertNotNull($resultT1->getToken());
     //
     $request = $this->getConfigOk();
     $request->setSavedToken($this->getTokenOk());
     $resultT2 = new OnTime($request);
     $this->assertEquals($this->getTokenOk(), $resultT2->getToken());
     //
     $this->setExpectedException('OTT\\Api\\Exception\\ConnectionException');
     new OnTime(new ConnectionRequest());
     //
     $this->setExpectedException('OTT\\Api\\Exception\\ConnectionException');
     new OnTime($this->getConfigKo());
 }
Beispiel #2
0
 /**
  * @param  null $data
  * @return Message
  */
 public function users($data = null)
 {
     $message = new Message();
     $result = $this->ontime->users($data);
     if (!isset($result['error'])) {
         $result = User::fromApiToEntity($result);
         $message->setSuccess(true);
         $message->setResult($result);
     } else {
         $message->setErrors($result['error']);
     }
     return $message;
 }
Beispiel #3
0
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);
//$contacts = $ontime->contacts($contactFilter);
//var_dump($contacts);