Skip to content

Commit

Permalink
#1: Examples: get_entry.php
Browse files Browse the repository at this point in the history
  • Loading branch information
mekras committed Sep 1, 2016
1 parent 7b29c19 commit 7f835dc
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions docs/examples/get_entry.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* This example should be executed in console
*
* Requires dev dependencies!
*/
namespace Comindware\Tracker\API\Examples;

use Http\Discovery\HttpClientDiscovery;
use Http\Discovery\MessageFactoryDiscovery;
use Mekras\OData\Client\Document\EntryDocument;
use Mekras\OData\Client\OData;
use Mekras\OData\Client\URI\Uri;

require __DIR__ . '/../../vendor/autoload.php';

use Mekras\OData\Client\Service;

$service = new Service(
'http://services.odata.org/OData/OData.svc/',
HttpClientDiscovery::find(),
MessageFactoryDiscovery::find()
);

$uri = new Uri();
$uri
->collection('Products')
->item(1);

$document = $service->sendRequest(OData::GET, $uri);

if (!$document instanceof EntryDocument) {
die("Not an entry!\n");
}

$entry = $document->getEntry();
printf("Id: %s\nRelease: %s\n", $entry['ID'], $entry['Price']);

0 comments on commit 7f835dc

Please sign in to comment.