Skip to content

Fix interfaces and add missing IODataResponse #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion src/IODataClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,52 @@ public function query();
* @param $requestUri
* @param array $bindings
*
* @return IODataRequest
* @return IODataResponse
*/
public function get($requestUri, $bindings = []);

/**
* Run a POST request against the service.
*
* @param string $requestUri
* @param mixed $postData
*
* @return IODataResponse
*/
public function post($requestUri, $postData);

/**
* Run a PATCH request against the service.
*
* @param string $requestUri
* @param mixed $body
*
* @return IODataResponse
*/
public function patch($requestUri, $body);

/**
* Run a DELETE request against the service.
*
* @param string $requestUri
*
* @return IODataResponse
*/
public function delete($requestUri);

/**
* Return an ODataRequest
*
* @param string $method
* @param string $requestUri
* @param mixed $body
*
* @return IODataResponse
*
* @throws ODataException
*/
public function request($method, $requestUri, $body = null);

/**
* Get the query grammar used by the connection.
*
Expand Down
57 changes: 57 additions & 0 deletions src/IODataResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace SaintSystems\OData;

interface IODataResponse
{
/**
* Get the decoded body of the HTTP response
*
* @var array The decoded body
*/
public function getBody();

/**
* Get the undecoded body of the HTTP response
*
* @var string The undecoded body
*/
public function getRawBody();

/**
* Get the status of the HTTP response
*
* @var string The HTTP status
*/
public function getStatus();

/**
* Get the headers of the response
*
* @var array The response headers
*/
public function getHeaders();

/**
* Converts the response JSON object to a OData SDK object
*
* @param mixed $returnType The type to convert the object(s) to
*
* @return mixed object or array of objects of type $returnType
*/
public function getResponseAsObject($returnType);

/**
* Gets the skip token of a response object from OData
*
* @return string skip token, if provided
*/
public function getSkipToken();

/**
* Gets the Id of response object (if set) from OData
*
* @return mixed id if this was an insert, if provided
*/
public function getId();
}
10 changes: 5 additions & 5 deletions src/ODataClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public function query()
* @param string $requestUri
* @param array $bindings
*
* @return IODataRequest
* @return IODataResponse
*/
public function get($requestUri, $bindings = [])
{
Expand All @@ -217,7 +217,7 @@ public function get($requestUri, $bindings = [])
* @param string $requestUri
* @param mixed $postData
*
* @return IODataRequest
* @return IODataResponse
*/
public function post($requestUri, $postData)
{
Expand All @@ -230,7 +230,7 @@ public function post($requestUri, $postData)
* @param string $requestUri
* @param mixed $body
*
* @return IODataRequest
* @return IODataResponse
*/
public function patch($requestUri, $body)
{
Expand All @@ -242,7 +242,7 @@ public function patch($requestUri, $body)
*
* @param string $requestUri
*
* @return IODataRequest
* @return IODataResponse
*/
public function delete($requestUri)
{
Expand All @@ -256,7 +256,7 @@ public function delete($requestUri)
* @param string $requestUri
* @param mixed $body
*
* @return IODataRequest
* @return IODataResponse
*
* @throws ODataException
*/
Expand Down
11 changes: 5 additions & 6 deletions src/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use SaintSystems\OData\Constants;
use SaintSystems\OData\Exception\ODataQueryException;
use SaintSystems\OData\IODataClient;
use SaintSystems\OData\IODataRequest;
use SaintSystems\OData\QueryOptions;

class Builder
Expand Down Expand Up @@ -1018,7 +1017,7 @@ public function patch($body, $properties = [], $options = null)
/**
* Run the query as a "GET" request against the client.
*
* @return IODataRequest
* @return IODataReponse
*/
protected function runGet()
{
Expand All @@ -1030,7 +1029,7 @@ protected function runGet()
/**
* Run the query as a "GET" request against the client.
*
* @return IODataRequest
* @return IODataResponse
*/
protected function runPatch($body)
{
Expand All @@ -1042,7 +1041,7 @@ protected function runPatch($body)
/**
* Run the query as a "GET" request against the client.
*
* @return IODataRequest
* @return IODataResponse
*/
protected function runPost($body)
{
Expand All @@ -1054,7 +1053,7 @@ protected function runPost($body)
/**
* Run the query as a "GET" request against the client.
*
* @return IODataRequest
* @return IODataResponse
*/
protected function runDelete()
{
Expand Down Expand Up @@ -1084,7 +1083,7 @@ public function count()
*
* @param array $values
*
* @return bool
* @return IODataResponse
*/
public function insert(array $values)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Query/IProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

namespace SaintSystems\OData\Query;

use SaintSystems\OData\IODataRequest;
use SaintSystems\OData\IODataResponse;

interface IProcessor
{
/**
* Process the results of a "select" query.
*
* @param Builder $query
* @param IODataRequest $results
* @param IODataResponse $results
*
* @return IODataRequest
* @return IODataResponse
*/
public function processSelect(Builder $query, $results);
}