From c5e34397d4ce5936839c21c24b98d51cd6f56017 Mon Sep 17 00:00:00 2001 From: "David T. Sadler" Date: Wed, 27 Jun 2018 21:55:14 +0100 Subject: [PATCH 1/4] api: support compliance api version v1.1.0 --- CHANGELOG.md | 6 ++ Makefile | 5 + src/Compliance/Enums/ComplianceTypeEnum.php | 18 ++++ src/Compliance/Enums/MarketplaceIdEnum.php | 56 ++++++++++ .../Services/ComplianceBaseService.php | 79 ++++++++++++++ src/Compliance/Services/ComplianceService.php | 95 ++++++++++++++++ src/Compliance/Types/ComplianceDetail.php | 74 +++++++++++++ src/Compliance/Types/ComplianceSummary.php | 46 ++++++++ .../Types/ComplianceSummaryInfo.php | 60 +++++++++++ src/Compliance/Types/ComplianceViolation.php | 74 +++++++++++++ .../Types/CorrectiveRecommendations.php | 46 ++++++++ src/Compliance/Types/ErrorDetailV3.php | 102 ++++++++++++++++++ src/Compliance/Types/ErrorParameterV3.php | 53 +++++++++ .../Types/GetListingViolationsRestRequest.php | 67 ++++++++++++ .../GetListingViolationsRestResponse.php | 65 +++++++++++ ...GetListingViolationsSummaryRestRequest.php | 46 ++++++++ ...etListingViolationsSummaryRestResponse.php | 65 +++++++++++ src/Compliance/Types/NameValueList.php | 53 +++++++++ .../PagedComplianceViolationCollection.php | 88 +++++++++++++++ .../Types/ProductRecommendation.php | 46 ++++++++ src/Compliance/Types/VariationDetails.php | 53 +++++++++ .../Enums/ComplianceTypeEnumTest.php | 28 +++++ .../Enums/MarketplaceIdEnumTest.php | 28 +++++ test/Compliance/Mocks/Service.php | 27 +++++ test/Compliance/Services/ServiceTest.php | 68 ++++++++++++ .../Compliance/Types/ComplianceDetailTest.php | 33 ++++++ .../Types/ComplianceSummaryInfoTest.php | 33 ++++++ .../Types/ComplianceSummaryTest.php | 33 ++++++ .../Types/ComplianceViolationTest.php | 33 ++++++ .../Types/CorrectiveRecommendationsTest.php | 33 ++++++ test/Compliance/Types/ErrorDetailV3Test.php | 33 ++++++ .../Compliance/Types/ErrorParameterV3Test.php | 33 ++++++ .../GetListingViolationsRestRequestTest.php | 33 ++++++ .../GetListingViolationsRestResponseTest.php | 33 ++++++ ...istingViolationsSummaryRestRequestTest.php | 33 ++++++ ...stingViolationsSummaryRestResponseTest.php | 33 ++++++ test/Compliance/Types/NameValueListTest.php | 33 ++++++ ...PagedComplianceViolationCollectionTest.php | 33 ++++++ .../Types/ProductRecommendationTest.php | 33 ++++++ .../Compliance/Types/VariationDetailsTest.php | 33 ++++++ 40 files changed, 1843 insertions(+) create mode 100644 src/Compliance/Enums/ComplianceTypeEnum.php create mode 100644 src/Compliance/Enums/MarketplaceIdEnum.php create mode 100644 src/Compliance/Services/ComplianceBaseService.php create mode 100644 src/Compliance/Services/ComplianceService.php create mode 100644 src/Compliance/Types/ComplianceDetail.php create mode 100644 src/Compliance/Types/ComplianceSummary.php create mode 100644 src/Compliance/Types/ComplianceSummaryInfo.php create mode 100644 src/Compliance/Types/ComplianceViolation.php create mode 100644 src/Compliance/Types/CorrectiveRecommendations.php create mode 100644 src/Compliance/Types/ErrorDetailV3.php create mode 100644 src/Compliance/Types/ErrorParameterV3.php create mode 100644 src/Compliance/Types/GetListingViolationsRestRequest.php create mode 100644 src/Compliance/Types/GetListingViolationsRestResponse.php create mode 100644 src/Compliance/Types/GetListingViolationsSummaryRestRequest.php create mode 100644 src/Compliance/Types/GetListingViolationsSummaryRestResponse.php create mode 100644 src/Compliance/Types/NameValueList.php create mode 100644 src/Compliance/Types/PagedComplianceViolationCollection.php create mode 100644 src/Compliance/Types/ProductRecommendation.php create mode 100644 src/Compliance/Types/VariationDetails.php create mode 100644 test/Compliance/Enums/ComplianceTypeEnumTest.php create mode 100644 test/Compliance/Enums/MarketplaceIdEnumTest.php create mode 100644 test/Compliance/Mocks/Service.php create mode 100644 test/Compliance/Services/ServiceTest.php create mode 100644 test/Compliance/Types/ComplianceDetailTest.php create mode 100644 test/Compliance/Types/ComplianceSummaryInfoTest.php create mode 100644 test/Compliance/Types/ComplianceSummaryTest.php create mode 100644 test/Compliance/Types/ComplianceViolationTest.php create mode 100644 test/Compliance/Types/CorrectiveRecommendationsTest.php create mode 100644 test/Compliance/Types/ErrorDetailV3Test.php create mode 100644 test/Compliance/Types/ErrorParameterV3Test.php create mode 100644 test/Compliance/Types/GetListingViolationsRestRequestTest.php create mode 100644 test/Compliance/Types/GetListingViolationsRestResponseTest.php create mode 100644 test/Compliance/Types/GetListingViolationsSummaryRestRequestTest.php create mode 100644 test/Compliance/Types/GetListingViolationsSummaryRestResponseTest.php create mode 100644 test/Compliance/Types/NameValueListTest.php create mode 100644 test/Compliance/Types/PagedComplianceViolationCollectionTest.php create mode 100644 test/Compliance/Types/ProductRecommendationTest.php create mode 100644 test/Compliance/Types/VariationDetailsTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index e31174354..276723ad7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # CHANGELOG +## Unreleased + +### Features + +* Support Compliance API version v1.1.0 + ## 17.0.0 - 2018-06-12 ### Features diff --git a/Makefile b/Makefile index 98b1e445f..bec9ea7d3 100644 --- a/Makefile +++ b/Makefile @@ -103,6 +103,10 @@ sync_catalog: rsync -rtvu --delete --exclude *BaseService.php ../ebay-api-sdk-php/dist/Catalog/src/Catalog/ src/Catalog/ rsync -rtvu --delete --exclude /Mocks/ --exclude /Services/ ../ebay-api-sdk-php/dist/Catalog/test/Catalog/ test/Catalog/ +sync_compliance: + rsync -rtvu --delete --exclude *BaseService.php ../ebay-api-sdk-php/dist/Compliance/src/Compliance/ src/Compliance/ + rsync -rtvu --delete --exclude /Mocks/ --exclude /Services/ ../ebay-api-sdk-php/dist/Compliance/test/Compliance/ test/Compliance/ + sync_feed: rsync -rtvu --delete --exclude *BaseService.php ../ebay-api-sdk-php/dist/Feed/src/Feed/ src/Feed/ rsync -rtvu --delete --exclude /Mocks/ --exclude /Services/ ../ebay-api-sdk-php/dist/Feed/test/Feed/ test/Feed/ @@ -195,6 +199,7 @@ sync_all: sync_account \ sync_bulk \ sync_bus \ sync_catalog \ + sync_compliance \ sync_feedback \ sync_file \ sync_finding \ diff --git a/src/Compliance/Enums/ComplianceTypeEnum.php b/src/Compliance/Enums/ComplianceTypeEnum.php new file mode 100644 index 000000000..eb7d5188c --- /dev/null +++ b/src/Compliance/Enums/ComplianceTypeEnum.php @@ -0,0 +1,18 @@ + 'https://api.sandbox.ebay.com/sell/compliance', + 'production' => 'https://api.ebay.com/sell/compliance' + ]; + + /** + * HTTP header constant. The Authentication Token that is used to validate the caller has permission to access the eBay servers. + */ + const HDR_AUTHORIZATION = 'Authorization'; + + /** + * HTTP header constant. The global ID of the eBay site on which the transaction took place. + */ + const HDR_MARKETPLACE_ID = 'X-EBAY-C-MARKETPLACE-ID'; + + /** + * @param array $config Configuration option values. + */ + public function __construct(array $config) + { + parent::__construct($config); + } + + /** + * Returns definitions for each configuration option that is supported. + * + * @return array An associative array of configuration definitions. + */ + public static function getConfigDefinitions() + { + $definitions = parent::getConfigDefinitions(); + + return $definitions + [ + 'apiVersion' => [ + 'valid' => ['string'], + 'default' => \DTS\eBaySDK\Compliance\Services\ComplianceService::API_VERSION, + 'required' => true + ], + 'authorization' => [ + 'valid' => ['string'], + 'required' => true + ], + 'marketplaceId' => [ + 'valid' => ['string'] + ] + ]; + } + + /** + * Builds the needed eBay HTTP headers. + * + * @return array An associative array of eBay HTTP headers. + */ + protected function getEbayHeaders() + { + $headers = []; + + // Add required headers first. + $headers[self::HDR_AUTHORIZATION] = 'Bearer '.$this->getConfig('authorization'); + + // Add optional headers. + if ($this->getConfig('marketplaceId')) { + $headers[self::HDR_MARKETPLACE_ID] = $this->getConfig('marketplaceId'); + } + + return $headers; + } +} diff --git a/src/Compliance/Services/ComplianceService.php b/src/Compliance/Services/ComplianceService.php new file mode 100644 index 000000000..1bd396595 --- /dev/null +++ b/src/Compliance/Services/ComplianceService.php @@ -0,0 +1,95 @@ + [ + 'method' => 'GET', + 'resource' => 'listing_violation_summary', + 'responseClass' => '\DTS\eBaySDK\Compliance\Types\GetListingViolationsSummaryRestResponse', + 'params' => [ + 'compliance_type' => [ + 'valid' => ['string'] + ] + ] + ], + 'GetListingViolations' => [ + 'method' => 'GET', + 'resource' => 'listing_violation', + 'responseClass' => '\DTS\eBaySDK\Compliance\Types\GetListingViolationsRestResponse', + 'params' => [ + 'limit' => [ + 'valid' => ['integer'] + ], + 'listing_id' => [ + 'valid' => ['string'] + ], + 'offset' => [ + 'valid' => ['integer'] + ], + 'compliance_type' => [ + 'valid' => ['string'] + ] + ] + ] + ]; + + /** + * @param array $config Configuration option values. + */ + public function __construct(array $config = []) + { + parent::__construct($config); + } + + /** + * @param \DTS\eBaySDK\Compliance\Types\GetListingViolationsSummaryRestRequest $request + * @return \DTS\eBaySDK\Compliance\Types\GetListingViolationsSummaryRestResponse + */ + public function getListingViolationsSummary(\DTS\eBaySDK\Compliance\Types\GetListingViolationsSummaryRestRequest $request) + { + return $this->getListingViolationsSummaryAsync($request)->wait(); + } + + /** + * @param \DTS\eBaySDK\Compliance\Types\GetListingViolationsSummaryRestRequest $request + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getListingViolationsSummaryAsync(\DTS\eBaySDK\Compliance\Types\GetListingViolationsSummaryRestRequest $request) + { + return $this->callOperationAsync('GetListingViolationsSummary', $request); + } + + /** + * @param \DTS\eBaySDK\Compliance\Types\GetListingViolationsRestRequest $request + * @return \DTS\eBaySDK\Compliance\Types\GetListingViolationsRestResponse + */ + public function getListingViolations(\DTS\eBaySDK\Compliance\Types\GetListingViolationsRestRequest $request) + { + return $this->getListingViolationsAsync($request)->wait(); + } + + /** + * @param \DTS\eBaySDK\Compliance\Types\GetListingViolationsRestRequest $request + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getListingViolationsAsync(\DTS\eBaySDK\Compliance\Types\GetListingViolationsRestRequest $request) + { + return $this->callOperationAsync('GetListingViolations', $request); + } +} diff --git a/src/Compliance/Types/ComplianceDetail.php b/src/Compliance/Types/ComplianceDetail.php new file mode 100644 index 000000000..4354dcb0e --- /dev/null +++ b/src/Compliance/Types/ComplianceDetail.php @@ -0,0 +1,74 @@ + [ + 'type' => 'string', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'reasonCode' + ], + 'message' => [ + 'type' => 'string', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'message' + ], + 'variation' => [ + 'type' => 'DTS\eBaySDK\Compliance\Types\VariationDetails', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'variation' + ], + 'violationData' => [ + 'type' => 'DTS\eBaySDK\Compliance\Types\NameValueList', + 'repeatable' => true, + 'attribute' => false, + 'elementName' => 'violationData' + ], + 'correctiveRecommendations' => [ + 'type' => 'DTS\eBaySDK\Compliance\Types\CorrectiveRecommendations', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'correctiveRecommendations' + ] + ]; + + /** + * @param array $values Optional properties and values to assign to the object. + */ + public function __construct(array $values = []) + { + list($parentValues, $childValues) = self::getParentValues(self::$propertyTypes, $values); + + parent::__construct($parentValues); + + if (!array_key_exists(__CLASS__, self::$properties)) { + self::$properties[__CLASS__] = array_merge(self::$properties[get_parent_class()], self::$propertyTypes); + } + + $this->setValues(__CLASS__, $childValues); + } +} diff --git a/src/Compliance/Types/ComplianceSummary.php b/src/Compliance/Types/ComplianceSummary.php new file mode 100644 index 000000000..235a5ab0f --- /dev/null +++ b/src/Compliance/Types/ComplianceSummary.php @@ -0,0 +1,46 @@ + [ + 'type' => 'DTS\eBaySDK\Compliance\Types\ComplianceSummaryInfo', + 'repeatable' => true, + 'attribute' => false, + 'elementName' => 'violationSummaries' + ] + ]; + + /** + * @param array $values Optional properties and values to assign to the object. + */ + public function __construct(array $values = []) + { + list($parentValues, $childValues) = self::getParentValues(self::$propertyTypes, $values); + + parent::__construct($parentValues); + + if (!array_key_exists(__CLASS__, self::$properties)) { + self::$properties[__CLASS__] = array_merge(self::$properties[get_parent_class()], self::$propertyTypes); + } + + $this->setValues(__CLASS__, $childValues); + } +} diff --git a/src/Compliance/Types/ComplianceSummaryInfo.php b/src/Compliance/Types/ComplianceSummaryInfo.php new file mode 100644 index 000000000..b30003ddc --- /dev/null +++ b/src/Compliance/Types/ComplianceSummaryInfo.php @@ -0,0 +1,60 @@ + [ + 'type' => 'string', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'complianceType' + ], + 'marketplaceId' => [ + 'type' => 'string', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'marketplaceId' + ], + 'listingCount' => [ + 'type' => 'integer', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'listingCount' + ] + ]; + + /** + * @param array $values Optional properties and values to assign to the object. + */ + public function __construct(array $values = []) + { + list($parentValues, $childValues) = self::getParentValues(self::$propertyTypes, $values); + + parent::__construct($parentValues); + + if (!array_key_exists(__CLASS__, self::$properties)) { + self::$properties[__CLASS__] = array_merge(self::$properties[get_parent_class()], self::$propertyTypes); + } + + $this->setValues(__CLASS__, $childValues); + } +} diff --git a/src/Compliance/Types/ComplianceViolation.php b/src/Compliance/Types/ComplianceViolation.php new file mode 100644 index 000000000..c5ce929c2 --- /dev/null +++ b/src/Compliance/Types/ComplianceViolation.php @@ -0,0 +1,74 @@ + [ + 'type' => 'string', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'complianceType' + ], + 'listingId' => [ + 'type' => 'string', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'listingId' + ], + 'sku' => [ + 'type' => 'string', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'sku' + ], + 'offerId' => [ + 'type' => 'string', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'offerId' + ], + 'violations' => [ + 'type' => 'DTS\eBaySDK\Compliance\Types\ComplianceDetail', + 'repeatable' => true, + 'attribute' => false, + 'elementName' => 'violations' + ] + ]; + + /** + * @param array $values Optional properties and values to assign to the object. + */ + public function __construct(array $values = []) + { + list($parentValues, $childValues) = self::getParentValues(self::$propertyTypes, $values); + + parent::__construct($parentValues); + + if (!array_key_exists(__CLASS__, self::$properties)) { + self::$properties[__CLASS__] = array_merge(self::$properties[get_parent_class()], self::$propertyTypes); + } + + $this->setValues(__CLASS__, $childValues); + } +} diff --git a/src/Compliance/Types/CorrectiveRecommendations.php b/src/Compliance/Types/CorrectiveRecommendations.php new file mode 100644 index 000000000..f21ece916 --- /dev/null +++ b/src/Compliance/Types/CorrectiveRecommendations.php @@ -0,0 +1,46 @@ + [ + 'type' => 'DTS\eBaySDK\Compliance\Types\ProductRecommendation', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'productRecommendation' + ] + ]; + + /** + * @param array $values Optional properties and values to assign to the object. + */ + public function __construct(array $values = []) + { + list($parentValues, $childValues) = self::getParentValues(self::$propertyTypes, $values); + + parent::__construct($parentValues); + + if (!array_key_exists(__CLASS__, self::$properties)) { + self::$properties[__CLASS__] = array_merge(self::$properties[get_parent_class()], self::$propertyTypes); + } + + $this->setValues(__CLASS__, $childValues); + } +} diff --git a/src/Compliance/Types/ErrorDetailV3.php b/src/Compliance/Types/ErrorDetailV3.php new file mode 100644 index 000000000..b9bf73633 --- /dev/null +++ b/src/Compliance/Types/ErrorDetailV3.php @@ -0,0 +1,102 @@ + [ + 'type' => 'string', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'category' + ], + 'domain' => [ + 'type' => 'string', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'domain' + ], + 'errorId' => [ + 'type' => 'integer', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'errorId' + ], + 'inputRefIds' => [ + 'type' => 'string', + 'repeatable' => true, + 'attribute' => false, + 'elementName' => 'inputRefIds' + ], + 'longMessage' => [ + 'type' => 'string', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'longMessage' + ], + 'message' => [ + 'type' => 'string', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'message' + ], + 'outputRefIds' => [ + 'type' => 'string', + 'repeatable' => true, + 'attribute' => false, + 'elementName' => 'outputRefIds' + ], + 'parameters' => [ + 'type' => 'DTS\eBaySDK\Compliance\Types\ErrorParameterV3', + 'repeatable' => true, + 'attribute' => false, + 'elementName' => 'parameters' + ], + 'subdomain' => [ + 'type' => 'string', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'subdomain' + ] + ]; + + /** + * @param array $values Optional properties and values to assign to the object. + */ + public function __construct(array $values = []) + { + list($parentValues, $childValues) = self::getParentValues(self::$propertyTypes, $values); + + parent::__construct($parentValues); + + if (!array_key_exists(__CLASS__, self::$properties)) { + self::$properties[__CLASS__] = array_merge(self::$properties[get_parent_class()], self::$propertyTypes); + } + + $this->setValues(__CLASS__, $childValues); + } +} diff --git a/src/Compliance/Types/ErrorParameterV3.php b/src/Compliance/Types/ErrorParameterV3.php new file mode 100644 index 000000000..f1a561cdb --- /dev/null +++ b/src/Compliance/Types/ErrorParameterV3.php @@ -0,0 +1,53 @@ + [ + 'type' => 'string', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'name' + ], + 'value' => [ + 'type' => 'string', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'value' + ] + ]; + + /** + * @param array $values Optional properties and values to assign to the object. + */ + public function __construct(array $values = []) + { + list($parentValues, $childValues) = self::getParentValues(self::$propertyTypes, $values); + + parent::__construct($parentValues); + + if (!array_key_exists(__CLASS__, self::$properties)) { + self::$properties[__CLASS__] = array_merge(self::$properties[get_parent_class()], self::$propertyTypes); + } + + $this->setValues(__CLASS__, $childValues); + } +} diff --git a/src/Compliance/Types/GetListingViolationsRestRequest.php b/src/Compliance/Types/GetListingViolationsRestRequest.php new file mode 100644 index 000000000..470a68742 --- /dev/null +++ b/src/Compliance/Types/GetListingViolationsRestRequest.php @@ -0,0 +1,67 @@ + [ + 'type' => 'integer', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'limit' + ], + 'listing_id' => [ + 'type' => 'string', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'listing_id' + ], + 'offset' => [ + 'type' => 'integer', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'offset' + ], + 'compliance_type' => [ + 'type' => 'string', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'compliance_type' + ] + ]; + + /** + * @param array $values Optional properties and values to assign to the object. + */ + public function __construct(array $values = []) + { + list($parentValues, $childValues) = self::getParentValues(self::$propertyTypes, $values); + + parent::__construct($parentValues); + + if (!array_key_exists(__CLASS__, self::$properties)) { + self::$properties[__CLASS__] = array_merge(self::$properties[get_parent_class()], self::$propertyTypes); + } + + $this->setValues(__CLASS__, $childValues); + } +} diff --git a/src/Compliance/Types/GetListingViolationsRestResponse.php b/src/Compliance/Types/GetListingViolationsRestResponse.php new file mode 100644 index 000000000..cd63f2635 --- /dev/null +++ b/src/Compliance/Types/GetListingViolationsRestResponse.php @@ -0,0 +1,65 @@ + [ + 'type' => 'DTS\eBaySDK\Compliance\Types\ErrorDetailV3', + 'repeatable' => true, + 'attribute' => false, + 'elementName' => 'errors' + ], + 'warnings' => [ + 'type' => 'DTS\eBaySDK\Compliance\Types\ErrorDetailV3', + 'repeatable' => true, + 'attribute' => false, + 'elementName' => 'warnings' + ] + ]; + + /** + * @param array $values Optional properties and values to assign to the object. + * @param int $statusCode Status code + * @param array $headers HTTP Response headers. + */ + public function __construct(array $values = [], $statusCode = 200, array $headers = []) + { + list($parentValues, $childValues) = self::getParentValues(self::$propertyTypes, $values); + + parent::__construct($parentValues); + + if (!array_key_exists(__CLASS__, self::$properties)) { + self::$properties[__CLASS__] = array_merge(self::$properties[get_parent_class()], self::$propertyTypes); + } + + $this->setValues(__CLASS__, $childValues); + + $this->statusCode = (int)$statusCode; + + $this->setHeaders($headers); + } +} diff --git a/src/Compliance/Types/GetListingViolationsSummaryRestRequest.php b/src/Compliance/Types/GetListingViolationsSummaryRestRequest.php new file mode 100644 index 000000000..461d0a605 --- /dev/null +++ b/src/Compliance/Types/GetListingViolationsSummaryRestRequest.php @@ -0,0 +1,46 @@ + [ + 'type' => 'string', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'compliance_type' + ] + ]; + + /** + * @param array $values Optional properties and values to assign to the object. + */ + public function __construct(array $values = []) + { + list($parentValues, $childValues) = self::getParentValues(self::$propertyTypes, $values); + + parent::__construct($parentValues); + + if (!array_key_exists(__CLASS__, self::$properties)) { + self::$properties[__CLASS__] = array_merge(self::$properties[get_parent_class()], self::$propertyTypes); + } + + $this->setValues(__CLASS__, $childValues); + } +} diff --git a/src/Compliance/Types/GetListingViolationsSummaryRestResponse.php b/src/Compliance/Types/GetListingViolationsSummaryRestResponse.php new file mode 100644 index 000000000..f90cc7a7d --- /dev/null +++ b/src/Compliance/Types/GetListingViolationsSummaryRestResponse.php @@ -0,0 +1,65 @@ + [ + 'type' => 'DTS\eBaySDK\Compliance\Types\ErrorDetailV3', + 'repeatable' => true, + 'attribute' => false, + 'elementName' => 'errors' + ], + 'warnings' => [ + 'type' => 'DTS\eBaySDK\Compliance\Types\ErrorDetailV3', + 'repeatable' => true, + 'attribute' => false, + 'elementName' => 'warnings' + ] + ]; + + /** + * @param array $values Optional properties and values to assign to the object. + * @param int $statusCode Status code + * @param array $headers HTTP Response headers. + */ + public function __construct(array $values = [], $statusCode = 200, array $headers = []) + { + list($parentValues, $childValues) = self::getParentValues(self::$propertyTypes, $values); + + parent::__construct($parentValues); + + if (!array_key_exists(__CLASS__, self::$properties)) { + self::$properties[__CLASS__] = array_merge(self::$properties[get_parent_class()], self::$propertyTypes); + } + + $this->setValues(__CLASS__, $childValues); + + $this->statusCode = (int)$statusCode; + + $this->setHeaders($headers); + } +} diff --git a/src/Compliance/Types/NameValueList.php b/src/Compliance/Types/NameValueList.php new file mode 100644 index 000000000..b74149763 --- /dev/null +++ b/src/Compliance/Types/NameValueList.php @@ -0,0 +1,53 @@ + [ + 'type' => 'string', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'name' + ], + 'value' => [ + 'type' => 'string', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'value' + ] + ]; + + /** + * @param array $values Optional properties and values to assign to the object. + */ + public function __construct(array $values = []) + { + list($parentValues, $childValues) = self::getParentValues(self::$propertyTypes, $values); + + parent::__construct($parentValues); + + if (!array_key_exists(__CLASS__, self::$properties)) { + self::$properties[__CLASS__] = array_merge(self::$properties[get_parent_class()], self::$propertyTypes); + } + + $this->setValues(__CLASS__, $childValues); + } +} diff --git a/src/Compliance/Types/PagedComplianceViolationCollection.php b/src/Compliance/Types/PagedComplianceViolationCollection.php new file mode 100644 index 000000000..83e2db899 --- /dev/null +++ b/src/Compliance/Types/PagedComplianceViolationCollection.php @@ -0,0 +1,88 @@ + [ + 'type' => 'integer', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'offset' + ], + 'href' => [ + 'type' => 'string', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'href' + ], + 'total' => [ + 'type' => 'integer', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'total' + ], + 'next' => [ + 'type' => 'string', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'next' + ], + 'prev' => [ + 'type' => 'string', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'prev' + ], + 'limit' => [ + 'type' => 'integer', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'limit' + ], + 'listingViolations' => [ + 'type' => 'DTS\eBaySDK\Compliance\Types\ComplianceViolation', + 'repeatable' => true, + 'attribute' => false, + 'elementName' => 'listingViolations' + ] + ]; + + /** + * @param array $values Optional properties and values to assign to the object. + */ + public function __construct(array $values = []) + { + list($parentValues, $childValues) = self::getParentValues(self::$propertyTypes, $values); + + parent::__construct($parentValues); + + if (!array_key_exists(__CLASS__, self::$properties)) { + self::$properties[__CLASS__] = array_merge(self::$properties[get_parent_class()], self::$propertyTypes); + } + + $this->setValues(__CLASS__, $childValues); + } +} diff --git a/src/Compliance/Types/ProductRecommendation.php b/src/Compliance/Types/ProductRecommendation.php new file mode 100644 index 000000000..e2a7d8eaa --- /dev/null +++ b/src/Compliance/Types/ProductRecommendation.php @@ -0,0 +1,46 @@ + [ + 'type' => 'string', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'epid' + ] + ]; + + /** + * @param array $values Optional properties and values to assign to the object. + */ + public function __construct(array $values = []) + { + list($parentValues, $childValues) = self::getParentValues(self::$propertyTypes, $values); + + parent::__construct($parentValues); + + if (!array_key_exists(__CLASS__, self::$properties)) { + self::$properties[__CLASS__] = array_merge(self::$properties[get_parent_class()], self::$propertyTypes); + } + + $this->setValues(__CLASS__, $childValues); + } +} diff --git a/src/Compliance/Types/VariationDetails.php b/src/Compliance/Types/VariationDetails.php new file mode 100644 index 000000000..6f6a675b5 --- /dev/null +++ b/src/Compliance/Types/VariationDetails.php @@ -0,0 +1,53 @@ + [ + 'type' => 'string', + 'repeatable' => false, + 'attribute' => false, + 'elementName' => 'sku' + ], + 'variationAspects' => [ + 'type' => 'DTS\eBaySDK\Compliance\Types\NameValueList', + 'repeatable' => true, + 'attribute' => false, + 'elementName' => 'variationAspects' + ] + ]; + + /** + * @param array $values Optional properties and values to assign to the object. + */ + public function __construct(array $values = []) + { + list($parentValues, $childValues) = self::getParentValues(self::$propertyTypes, $values); + + parent::__construct($parentValues); + + if (!array_key_exists(__CLASS__, self::$properties)) { + self::$properties[__CLASS__] = array_merge(self::$properties[get_parent_class()], self::$propertyTypes); + } + + $this->setValues(__CLASS__, $childValues); + } +} diff --git a/test/Compliance/Enums/ComplianceTypeEnumTest.php b/test/Compliance/Enums/ComplianceTypeEnumTest.php new file mode 100644 index 000000000..ac89ede95 --- /dev/null +++ b/test/Compliance/Enums/ComplianceTypeEnumTest.php @@ -0,0 +1,28 @@ +obj = new ComplianceTypeEnum(); + } + + public function testCanBeCreated() + { + $this->assertInstanceOf('\DTS\eBaySDK\Compliance\Enums\ComplianceTypeEnum', $this->obj); + } +} diff --git a/test/Compliance/Enums/MarketplaceIdEnumTest.php b/test/Compliance/Enums/MarketplaceIdEnumTest.php new file mode 100644 index 000000000..5c5f18c99 --- /dev/null +++ b/test/Compliance/Enums/MarketplaceIdEnumTest.php @@ -0,0 +1,28 @@ +obj = new MarketplaceIdEnum(); + } + + public function testCanBeCreated() + { + $this->assertInstanceOf('\DTS\eBaySDK\Compliance\Enums\MarketplaceIdEnum', $this->obj); + } +} diff --git a/test/Compliance/Mocks/Service.php b/test/Compliance/Mocks/Service.php new file mode 100644 index 000000000..461895c76 --- /dev/null +++ b/test/Compliance/Mocks/Service.php @@ -0,0 +1,27 @@ + [ + 'method' => 'GET', + 'resource' => 'item/{item_id}', + 'responseClass' => '\DTS\eBaySDK\Test\Mocks\ComplexClass', + 'params' => [ + ] + ] + ]; + + public function __construct(array $config) + { + parent::__construct($config); + } + + public function testOperation() + { + return $this->callOperationAsync('testOperation', new ComplexClass())->wait(); + } +} diff --git a/test/Compliance/Services/ServiceTest.php b/test/Compliance/Services/ServiceTest.php new file mode 100644 index 000000000..cc0f7903f --- /dev/null +++ b/test/Compliance/Services/ServiceTest.php @@ -0,0 +1,68 @@ +assertArrayHasKey('apiVersion', $d); + $this->assertEquals([ + 'valid' => ['string'], + 'default' => ComplianceService::API_VERSION, + 'required' => true + ], $d['apiVersion']); + + $this->assertArrayHasKey('authorization', $d); + $this->assertEquals([ + 'valid' => ['string'], + 'required' => true + ], $d['authorization']); + + $this->assertArrayHasKey('marketplaceId', $d); + $this->assertEquals([ + 'valid' => ['string'] + ], $d['marketplaceId']); + } + + public function testRequiredEbayHeaders() + { + $h = new HttpRestHandler(); + + $s = new Service([ + 'authorization' => '321', + 'httpHandler' => $h + ]); + + $s->testOperation(); + + // Test required headers first. + $this->assertArrayHasKey(ComplianceBaseService::HDR_AUTHORIZATION, $h->headers); + $this->assertEquals('Bearer 321', $h->headers[ComplianceBaseService::HDR_AUTHORIZATION]); + + // Test that optional headers have not been set until they have been configured. + $this->assertArrayNotHasKey(ComplianceBaseService::HDR_MARKETPLACE_ID, $h->headers); + } + + public function testOptionalEbayHeaders() + { + $h = new HttpRestHandler(); + + $s = new Service([ + 'authorization' => '321', + 'marketplaceId' => '123', + 'httpHandler' => $h + ]); + + $s->testOperation(); + + $this->assertArrayHasKey(ComplianceBaseService::HDR_MARKETPLACE_ID, $h->headers); + $this->assertEquals('123', $h->headers[ComplianceBaseService::HDR_MARKETPLACE_ID]); + } +} diff --git a/test/Compliance/Types/ComplianceDetailTest.php b/test/Compliance/Types/ComplianceDetailTest.php new file mode 100644 index 000000000..b0e21461c --- /dev/null +++ b/test/Compliance/Types/ComplianceDetailTest.php @@ -0,0 +1,33 @@ +obj = new ComplianceDetail(); + } + + public function testCanBeCreated() + { + $this->assertInstanceOf('\DTS\eBaySDK\Compliance\Types\ComplianceDetail', $this->obj); + } + + public function testExtendsBaseType() + { + $this->assertInstanceOf('\DTS\eBaySDK\Types\BaseType', $this->obj); + } +} diff --git a/test/Compliance/Types/ComplianceSummaryInfoTest.php b/test/Compliance/Types/ComplianceSummaryInfoTest.php new file mode 100644 index 000000000..2a09e173e --- /dev/null +++ b/test/Compliance/Types/ComplianceSummaryInfoTest.php @@ -0,0 +1,33 @@ +obj = new ComplianceSummaryInfo(); + } + + public function testCanBeCreated() + { + $this->assertInstanceOf('\DTS\eBaySDK\Compliance\Types\ComplianceSummaryInfo', $this->obj); + } + + public function testExtendsBaseType() + { + $this->assertInstanceOf('\DTS\eBaySDK\Types\BaseType', $this->obj); + } +} diff --git a/test/Compliance/Types/ComplianceSummaryTest.php b/test/Compliance/Types/ComplianceSummaryTest.php new file mode 100644 index 000000000..5c65357fa --- /dev/null +++ b/test/Compliance/Types/ComplianceSummaryTest.php @@ -0,0 +1,33 @@ +obj = new ComplianceSummary(); + } + + public function testCanBeCreated() + { + $this->assertInstanceOf('\DTS\eBaySDK\Compliance\Types\ComplianceSummary', $this->obj); + } + + public function testExtendsBaseType() + { + $this->assertInstanceOf('\DTS\eBaySDK\Types\BaseType', $this->obj); + } +} diff --git a/test/Compliance/Types/ComplianceViolationTest.php b/test/Compliance/Types/ComplianceViolationTest.php new file mode 100644 index 000000000..c047808a4 --- /dev/null +++ b/test/Compliance/Types/ComplianceViolationTest.php @@ -0,0 +1,33 @@ +obj = new ComplianceViolation(); + } + + public function testCanBeCreated() + { + $this->assertInstanceOf('\DTS\eBaySDK\Compliance\Types\ComplianceViolation', $this->obj); + } + + public function testExtendsBaseType() + { + $this->assertInstanceOf('\DTS\eBaySDK\Types\BaseType', $this->obj); + } +} diff --git a/test/Compliance/Types/CorrectiveRecommendationsTest.php b/test/Compliance/Types/CorrectiveRecommendationsTest.php new file mode 100644 index 000000000..757792ac2 --- /dev/null +++ b/test/Compliance/Types/CorrectiveRecommendationsTest.php @@ -0,0 +1,33 @@ +obj = new CorrectiveRecommendations(); + } + + public function testCanBeCreated() + { + $this->assertInstanceOf('\DTS\eBaySDK\Compliance\Types\CorrectiveRecommendations', $this->obj); + } + + public function testExtendsBaseType() + { + $this->assertInstanceOf('\DTS\eBaySDK\Types\BaseType', $this->obj); + } +} diff --git a/test/Compliance/Types/ErrorDetailV3Test.php b/test/Compliance/Types/ErrorDetailV3Test.php new file mode 100644 index 000000000..06addf33a --- /dev/null +++ b/test/Compliance/Types/ErrorDetailV3Test.php @@ -0,0 +1,33 @@ +obj = new ErrorDetailV3(); + } + + public function testCanBeCreated() + { + $this->assertInstanceOf('\DTS\eBaySDK\Compliance\Types\ErrorDetailV3', $this->obj); + } + + public function testExtendsBaseType() + { + $this->assertInstanceOf('\DTS\eBaySDK\Types\BaseType', $this->obj); + } +} diff --git a/test/Compliance/Types/ErrorParameterV3Test.php b/test/Compliance/Types/ErrorParameterV3Test.php new file mode 100644 index 000000000..2b2725118 --- /dev/null +++ b/test/Compliance/Types/ErrorParameterV3Test.php @@ -0,0 +1,33 @@ +obj = new ErrorParameterV3(); + } + + public function testCanBeCreated() + { + $this->assertInstanceOf('\DTS\eBaySDK\Compliance\Types\ErrorParameterV3', $this->obj); + } + + public function testExtendsBaseType() + { + $this->assertInstanceOf('\DTS\eBaySDK\Types\BaseType', $this->obj); + } +} diff --git a/test/Compliance/Types/GetListingViolationsRestRequestTest.php b/test/Compliance/Types/GetListingViolationsRestRequestTest.php new file mode 100644 index 000000000..93b876835 --- /dev/null +++ b/test/Compliance/Types/GetListingViolationsRestRequestTest.php @@ -0,0 +1,33 @@ +obj = new GetListingViolationsRestRequest(); + } + + public function testCanBeCreated() + { + $this->assertInstanceOf('\DTS\eBaySDK\Compliance\Types\GetListingViolationsRestRequest', $this->obj); + } + + public function testExtendsBaseType() + { + $this->assertInstanceOf('\DTS\eBaySDK\Types\BaseType', $this->obj); + } +} diff --git a/test/Compliance/Types/GetListingViolationsRestResponseTest.php b/test/Compliance/Types/GetListingViolationsRestResponseTest.php new file mode 100644 index 000000000..df650ca98 --- /dev/null +++ b/test/Compliance/Types/GetListingViolationsRestResponseTest.php @@ -0,0 +1,33 @@ +obj = new GetListingViolationsRestResponse(); + } + + public function testCanBeCreated() + { + $this->assertInstanceOf('\DTS\eBaySDK\Compliance\Types\GetListingViolationsRestResponse', $this->obj); + } + + public function testExtendsPagedComplianceViolationCollection() + { + $this->assertInstanceOf('\DTS\eBaySDK\Compliance\Types\PagedComplianceViolationCollection', $this->obj); + } +} diff --git a/test/Compliance/Types/GetListingViolationsSummaryRestRequestTest.php b/test/Compliance/Types/GetListingViolationsSummaryRestRequestTest.php new file mode 100644 index 000000000..178630f0e --- /dev/null +++ b/test/Compliance/Types/GetListingViolationsSummaryRestRequestTest.php @@ -0,0 +1,33 @@ +obj = new GetListingViolationsSummaryRestRequest(); + } + + public function testCanBeCreated() + { + $this->assertInstanceOf('\DTS\eBaySDK\Compliance\Types\GetListingViolationsSummaryRestRequest', $this->obj); + } + + public function testExtendsBaseType() + { + $this->assertInstanceOf('\DTS\eBaySDK\Types\BaseType', $this->obj); + } +} diff --git a/test/Compliance/Types/GetListingViolationsSummaryRestResponseTest.php b/test/Compliance/Types/GetListingViolationsSummaryRestResponseTest.php new file mode 100644 index 000000000..8b04e09f4 --- /dev/null +++ b/test/Compliance/Types/GetListingViolationsSummaryRestResponseTest.php @@ -0,0 +1,33 @@ +obj = new GetListingViolationsSummaryRestResponse(); + } + + public function testCanBeCreated() + { + $this->assertInstanceOf('\DTS\eBaySDK\Compliance\Types\GetListingViolationsSummaryRestResponse', $this->obj); + } + + public function testExtendsComplianceSummary() + { + $this->assertInstanceOf('\DTS\eBaySDK\Compliance\Types\ComplianceSummary', $this->obj); + } +} diff --git a/test/Compliance/Types/NameValueListTest.php b/test/Compliance/Types/NameValueListTest.php new file mode 100644 index 000000000..55bccebda --- /dev/null +++ b/test/Compliance/Types/NameValueListTest.php @@ -0,0 +1,33 @@ +obj = new NameValueList(); + } + + public function testCanBeCreated() + { + $this->assertInstanceOf('\DTS\eBaySDK\Compliance\Types\NameValueList', $this->obj); + } + + public function testExtendsBaseType() + { + $this->assertInstanceOf('\DTS\eBaySDK\Types\BaseType', $this->obj); + } +} diff --git a/test/Compliance/Types/PagedComplianceViolationCollectionTest.php b/test/Compliance/Types/PagedComplianceViolationCollectionTest.php new file mode 100644 index 000000000..ceb57b854 --- /dev/null +++ b/test/Compliance/Types/PagedComplianceViolationCollectionTest.php @@ -0,0 +1,33 @@ +obj = new PagedComplianceViolationCollection(); + } + + public function testCanBeCreated() + { + $this->assertInstanceOf('\DTS\eBaySDK\Compliance\Types\PagedComplianceViolationCollection', $this->obj); + } + + public function testExtendsBaseType() + { + $this->assertInstanceOf('\DTS\eBaySDK\Types\BaseType', $this->obj); + } +} diff --git a/test/Compliance/Types/ProductRecommendationTest.php b/test/Compliance/Types/ProductRecommendationTest.php new file mode 100644 index 000000000..7c44fe675 --- /dev/null +++ b/test/Compliance/Types/ProductRecommendationTest.php @@ -0,0 +1,33 @@ +obj = new ProductRecommendation(); + } + + public function testCanBeCreated() + { + $this->assertInstanceOf('\DTS\eBaySDK\Compliance\Types\ProductRecommendation', $this->obj); + } + + public function testExtendsBaseType() + { + $this->assertInstanceOf('\DTS\eBaySDK\Types\BaseType', $this->obj); + } +} diff --git a/test/Compliance/Types/VariationDetailsTest.php b/test/Compliance/Types/VariationDetailsTest.php new file mode 100644 index 000000000..81d766cbf --- /dev/null +++ b/test/Compliance/Types/VariationDetailsTest.php @@ -0,0 +1,33 @@ +obj = new VariationDetails(); + } + + public function testCanBeCreated() + { + $this->assertInstanceOf('\DTS\eBaySDK\Compliance\Types\VariationDetails', $this->obj); + } + + public function testExtendsBaseType() + { + $this->assertInstanceOf('\DTS\eBaySDK\Types\BaseType', $this->obj); + } +} From 22e8cf70d0a3dd51240b5f107835c08b54746ccd Mon Sep 17 00:00:00 2001 From: "David T. Sadler" Date: Thu, 28 Jun 2018 22:06:57 +0100 Subject: [PATCH 2/4] Ensure type attribute exists form ProductTypeID. close #200 --- src/Shopping/Types/ProductIDType.php | 7 +++++++ test/property_fixes/PropertyFixesTest.php | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/Shopping/Types/ProductIDType.php b/src/Shopping/Types/ProductIDType.php index cb5a68402..519dc91b1 100644 --- a/src/Shopping/Types/ProductIDType.php +++ b/src/Shopping/Types/ProductIDType.php @@ -12,6 +12,7 @@ /** * + * @property \DTS\eBaySDK\Shopping\Enums\ProductIDCodeType $type */ class ProductIDType extends \DTS\eBaySDK\Types\StringType { @@ -19,6 +20,12 @@ class ProductIDType extends \DTS\eBaySDK\Types\StringType * @var array Properties belonging to objects of this class. */ private static $propertyTypes = [ + 'type' => [ + 'type' => 'string', + 'repeatable' => false, + 'attribute' => true, + 'attributeName' => 'type' + ] ]; /** diff --git a/test/property_fixes/PropertyFixesTest.php b/test/property_fixes/PropertyFixesTest.php index 54d28d184..46a8742a9 100644 --- a/test/property_fixes/PropertyFixesTest.php +++ b/test/property_fixes/PropertyFixesTest.php @@ -195,4 +195,20 @@ public function testVerifyOnly() $obj->VerifyOnly = true; $this->assertInternalType('boolean', $obj->VerifyOnly); } + + + /** + * Code generation is not including this attribute + * as the WSDL contains NoCalls. + * In future we won't be using the WSDLs so this will + * be less of an issue. + */ + public function testProductIDTypeAttribute() + { + $obj = new Sdk\Shopping\Types\ProductIDType(); + + $obj->type = ''; + + $this->assertInternalType('string', $obj->type); + } } From 824091a68c682fa6e49631651b2d9552485a0d33 Mon Sep 17 00:00:00 2001 From: "David T. Sadler" Date: Thu, 28 Jun 2018 22:14:48 +0100 Subject: [PATCH 3/4] Update CHANGELOG --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 276723ad7..4f158439d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ * Support Compliance API version v1.1.0 +### Fixes + +* Ensure type attribute exist for ProductID. + ## 17.0.0 - 2018-06-12 ### Features From a7884cb0e3181798fede32c70f8dc7357c2d09dc Mon Sep 17 00:00:00 2001 From: "David T. Sadler" Date: Thu, 28 Jun 2018 22:17:10 +0100 Subject: [PATCH 4/4] update: bump version to 18.0.0 --- CHANGELOG.md | 2 +- src/Sdk.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f158439d..28047c591 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # CHANGELOG -## Unreleased +## 18.0.0 - 2018-06-28 ### Features diff --git a/src/Sdk.php b/src/Sdk.php index a38499aa4..c9867f7c5 100644 --- a/src/Sdk.php +++ b/src/Sdk.php @@ -30,7 +30,7 @@ */ class Sdk { - const VERSION = '17.0.0'; + const VERSION = '18.0.0'; /** * @var bool Controls if the SDK should enforce strict types