-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?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\Atom\Document\FeedDocument; | ||
use Mekras\OData\Client\OData; | ||
use Mekras\OData\Client\URI\Uri; | ||
use Mekras\OData\Client\URI\Filter as F; | ||
|
||
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'); | ||
$uri->options() | ||
->filter(F::gte('Price', 15.5)) | ||
->top(5); | ||
|
||
$document = $service->sendRequest(OData::GET, $uri); | ||
|
||
if (!$document instanceof FeedDocument) { | ||
die("Not a feed!\n"); | ||
} | ||
|
||
$entries = $document->getFeed()->getEntries(); | ||
foreach ($entries as $entry) { | ||
printf("Id: %s\nRelease: %s\n", $entry['ID'], $entry['Price']); | ||
} |