/** * Test that building the client works */ public function testBuildClient() { $api = new API(); $api->buildClient('test.com', 'username', 'password'); //Create our expected item, get our class to build our item, then compare $expected = new ExchangeWebServices('test.com', 'username', 'password', ['version' => ExchangeWebServices::VERSION_2010]); $actual = $api->getClient(); $this->assertEquals($expected, $actual); }
public function getClient() { $mode = getenv('HttpPlayback'); if ($mode == false) { $mode = 'playback'; } $auth = ['server' => 'server', 'user' => 'user', 'password' => 'password']; if (is_file(getcwd() . '/Resources/auth.json')) { $auth = json_decode(file_get_contents(getcwd() . '/Resources/auth.json'), true); } $client = new API(); $client->buildClient($auth['server'], $auth['user'], $auth['password'], ['httpPlayback' => ['mode' => $mode, 'recordFileName' => self::class . '::' . $this->getName() . '.json']]); return $client->getClient()->getClient(); }
<?php /** * Building Requests * * This file is an example on how to build requests manually and execute them directly instead of relying on the * simple use section of the library. Essentially, you can create your requests in arrays, pass them through * Type::buildFromArray($array) and then post them straight to the API Client. */ //Include the API use jamesiarmes\PEWS\API; use jamesiarmes\PEWS\API\Enumeration; use jamesiarmes\PEWS\API\Type; //Create and build the client $api = new API(); $api->buildClient('server', 'username', 'password'); //Build the request as an array $request = array('FolderShape' => array('BaseShape' => array('_' => 'Default')), 'FolderIds' => array('DistinguishedFolderId' => array('Id' => 'calendar'))); //Turn the array in to an object to pass to the API $request = Type::buildFromArray($request); //Send the request and get the response $response = $api->getClient()->GetFolder($request);