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
0 parents
commit 8361f3f
Showing
37 changed files
with
5,006 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,11 @@ | ||
composer.phar | ||
composer.lock | ||
/sdk-generator/ | ||
/vendor/ | ||
/coverage | ||
.idea/ | ||
/storage | ||
.env | ||
.DS_Store | ||
Thumbs.db | ||
/tests/testConfig.json |
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,18 @@ | ||
language: php | ||
|
||
php: | ||
# - '5.3' | ||
# - '5.4' | ||
# - '5.5' | ||
- '5.6' | ||
- '7.0' | ||
- '7.1' | ||
|
||
before_install: | ||
- composer self-update | ||
|
||
install: | ||
- composer install --prefer-source --no-interaction --dev | ||
|
||
script: | ||
- vendor/bin/phpunit |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) Saint Systems, LLC | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,64 @@ | ||
# Get started with the Saint Systems OData Client for PHP | ||
|
||
*This library is currently in preview. Please continue to provide [feedback](https://github.com/saintsystems/odata-client-php/issues/new) as we iterate towards a production-supported library.* | ||
|
||
[![Build Status](https://travis-ci.org/saintsystems/odata-client-php.svg?branch=master)](https://travis-ci.org/saintsystems/odata-client-php) | ||
|
||
|
||
## Install the SDK | ||
You can install the PHP SDK with Composer. | ||
``` | ||
{ | ||
"require": { | ||
"SaintSystems/OData": "0.1.*" | ||
} | ||
} | ||
``` | ||
### Call an OData Service | ||
|
||
The following is an example that shows how to call an OData service. | ||
|
||
```php | ||
use SaintSystems\OData; | ||
|
||
class UsageExample | ||
{ | ||
$odataServiceUrl = 'http://services.odata.org/V4/TripPinService'; | ||
|
||
$odataClient = new ODataClient($odataServiceUrl); | ||
|
||
// Retrieve all entities from an Entity Set | ||
$people = $odataClient->from('People')->get(); | ||
|
||
// Or retrieve a specific entity by ID | ||
$person = $odataClient->from('People')->entityKey('russellwhyte')->get(); | ||
echo "Hello, I am $person->FirstName "; | ||
} | ||
``` | ||
|
||
## Develop | ||
|
||
### Run Tests | ||
|
||
Run ```vendor/bin/phpunit``` from the base directory. | ||
|
||
|
||
## Documentation and resources | ||
|
||
* [Documentation](https://github.com/saintsystems/dynamics-sdk-php/blob/master/docs/index.html) | ||
|
||
* [Wiki](https://github.com/saintsystems/dynamics-sdk-php/wiki) | ||
|
||
* [Examples](https://github.com/saintsystems/dynamics-sdk-php/wiki/Example-calls) | ||
|
||
* [OData website](http://www.odata.org) | ||
|
||
* [OASIS OData Version 4.0 Documentation](http://docs.oasis-open.org/odata/odata/v4.0/odata-v4.0-part1-protocol.html) | ||
|
||
## Issues | ||
|
||
View or log issues on the [Issues](https://github.com/saintsystems/odata-client-php/issues) tab in the repo. | ||
|
||
## Copyright and license | ||
|
||
Copyright (c) Saint Systems, LLC. All Rights Reserved. Licensed under the MIT [license](LICENSE). |
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,37 @@ | ||
{ | ||
"name": "saintsystems/odata-client-php", | ||
"version": "0.1.0", | ||
"description": "Saint Systems OData Client for PHP", | ||
"keywords": ["odata", "rest", "php"], | ||
"homepage": "https://github.com/saintsystems/odata-client-php", | ||
"license": "MIT", | ||
"type": "library", | ||
"authors": [ | ||
{ | ||
"name": "Saint Systems", | ||
"email": "contact@saintsystems.com" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.3.0", | ||
"guzzlehttp/guzzle": "^6.2", | ||
"monolog/monolog": "^1.22", | ||
"nesbot/carbon": "^1.22", | ||
"illuminate/support": "^5.4" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "5.5.*", | ||
"phpdocumentor/phpdocumentor": "^2.9" | ||
}, | ||
"autoload": { | ||
"files": [ | ||
"src/Core/helpers.php" | ||
], | ||
"psr-4": { | ||
"SaintSystems\\OData\\": "src" | ||
} | ||
}, | ||
"config": { | ||
"preferred-install": "dist" | ||
} | ||
} |
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,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit colors="true" bootstrap="vendor/autoload.php"> | ||
<testsuites> | ||
<testsuite name="Microsoft Dynamics SDK Test Suite"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist addUncoveredFilesFromWhitelist="true"> | ||
<directory suffix=".php">src</directory> | ||
<exclude><directory suffix=".php">src/Model</directory></exclude> | ||
</whitelist> | ||
</filter> | ||
<!-- <logging> | ||
<log type="coverage-html" target="coverage/report" charset="UTF-8" yui="true" highlight="true" lowUpperBound="50" highLowerBound="80"/> | ||
</logging> --> | ||
</phpunit> |
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,50 @@ | ||
<?php | ||
/** | ||
* Copyright (c) Saint Systems, LLC. All Rights Reserved. | ||
* Licensed under the MIT License. See License in the project root | ||
* for license information. | ||
* | ||
* OData Constants File | ||
* PHP version 7 | ||
* | ||
* @category Library | ||
* @package SaintSystems.OData | ||
* @copyright 2017 Saint Systems, LLC | ||
* @license https://opensource.org/licenses/MIT MIT License | ||
* @version GIT: 0.1.0 | ||
* @link https://www.microsoft.com/en-us/dynamics365/ | ||
*/ | ||
|
||
namespace SaintSystems\OData; | ||
|
||
class Constants | ||
{ | ||
const SDK_VERSION = '0.1.0'; | ||
|
||
// ODATA Versions to be used when accessing the Web API (see: https://msdn.microsoft.com/en-us/library/gg334391.aspx) | ||
const MAX_ODATA_VERSION = '4.0'; | ||
const ODATA_VERSION = '4.0'; | ||
|
||
// Values/Keys in OData Responses | ||
const ODATA_ID = '@odata.id'; | ||
const ODATA_NEXT_LINK = '@odata.id'; | ||
const ODATA_VALUE = 'value'; | ||
|
||
// Default ODATA Paging | ||
const ODATA_MAX_PAGE_SIZE = 'odata.maxpagesize'; | ||
const ODATA_MAX_PAGE_SIZE_DEFAULT = 25; | ||
|
||
// Define error constants | ||
const MAX_PAGE_SIZE = 999; | ||
const MAX_PAGE_SIZE_ERROR = 'Page size must be less than ' . self::MAX_PAGE_SIZE; | ||
const TIMEOUT = 'Timeout error'; | ||
|
||
// Define error message constants | ||
const BASE_URL_MISSING = 'Base URL cannot be null or empty.'; | ||
const REQUEST_URL_MISSING = 'Request URL cannot be null or empty.'; | ||
const REQUEST_TIMED_OUT = 'The request timed out.'; | ||
const UNABLE_TO_CREATE_INSTANCE_OF_TYPE = 'Unable to create instance of type.'; | ||
|
||
// Define server error constants | ||
const UNABLE_TO_PARSE_RESPONSE = 'The HTTP client sent back an invalid response'; | ||
} |
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,101 @@ | ||
<?php | ||
/** | ||
* Copyright (c) Saint Systems, LLC. All Rights Reserved. | ||
* Licensed under the MIT License. See License in the project root | ||
* for license information. | ||
* | ||
* Enum File | ||
* PHP version 7 | ||
* | ||
* @category Library | ||
* @package SaintSystems.OData | ||
* @copyright 2017 Saint Systems, LLC | ||
* @license https://opensource.org/licenses/MIT MIT License | ||
* @version GIT: 0.1.0 | ||
*/ | ||
namespace SaintSystems\OData\Core; | ||
|
||
use SaintSystems\OData\Exception\ApplicationException; | ||
|
||
/** | ||
* Class Enum | ||
* | ||
* @category Library | ||
* @package SaintSystems.OData | ||
* @license https://opensource.org/licenses/MIT MIT License | ||
*/ | ||
abstract class Enum | ||
{ | ||
private static $constants = []; | ||
/** | ||
* The value of the enum | ||
* | ||
* @var string | ||
*/ | ||
private $_value; | ||
|
||
/** | ||
* Create a new enum | ||
* | ||
* @param string $value The value of the enum | ||
* | ||
* @throws DynamicsException if enum value is invalid | ||
*/ | ||
public function __construct($value) | ||
{ | ||
if (!self::has($value)) { | ||
throw new ApplicationException("Invalid enum value $value"); | ||
} | ||
$this->_value = $value; | ||
} | ||
|
||
/** | ||
* Check if the enum has the given value | ||
* | ||
* @param string $value | ||
* @return bool the enum has the value | ||
*/ | ||
public function has($value) | ||
{ | ||
return in_array($value, self::toArray(), true); | ||
} | ||
|
||
/** | ||
* Check if the enum is defined | ||
* | ||
* @param string $value the value of the enum | ||
* | ||
* @return bool True if the value is defined | ||
*/ | ||
public function is($value) | ||
{ | ||
return $this->_value === $value; | ||
} | ||
|
||
/** | ||
* Create a new class for the enum in question | ||
* | ||
* @return mixed | ||
*/ | ||
public function toArray() | ||
{ | ||
$class = get_called_class(); | ||
|
||
if (!(array_key_exists($class, self::$constants))) | ||
{ | ||
$reflectionObj = new \ReflectionClass($class); | ||
self::$constants[$class] = $reflectionObj->getConstants(); | ||
} | ||
return self::$constants[$class]; | ||
} | ||
|
||
/** | ||
* Get the value of the enum | ||
* | ||
* @return string value of the enum | ||
*/ | ||
public function value() | ||
{ | ||
return $this->_value; | ||
} | ||
} |
Oops, something went wrong.