diff --git a/README.md b/README.md index 5a875e6..0cbbf9a 100644 --- a/README.md +++ b/README.md @@ -163,6 +163,7 @@ class UploadUsage extends \Connect\UsageAutomation //This is for Provider XYZ, also can be seen from $listing->provider->id and parametrized further via marketplace available at $listing->marketplace->id date_default_timezone_set('UTC'); //reporting must be always based on UTC $usages = []; + //Creating QT SCHEMA records, pplease check Connect\Usage\FileUsageRecord for further possible data to be passed array_push($usages, new Connect\Usage\FileUsageRecord([ 'record_id' => 'unique record value', 'item_search_criteria' => 'item.mpn', //Possible values are item.mpn or item.local_id @@ -174,7 +175,10 @@ class UploadUsage extends \Connect\UsageAutomation 'asset_search_value' => 'tenant2' ])); $usageFile = new \Connect\Usage\File([ - 'name' => 'sdk test', + "period" => [ + "from"=> date('Y-m-d H:i:s', strtotime("-1 days")), + "to"=> date("Y-m-d H:i:s") + ], 'product' => new \Connect\Product( ['id' => $listing->product->id] ), @@ -248,6 +252,40 @@ try { } ``` +## A simple Example of automating workflow for Tier Account Requests +```php + +require_once "vendor/autoload.php"; +class ProcessTAR extends \Connect\TierAccountRequestsAutomation +{ + public function processTierAccountRequest(\Connect\TierAccountRequest $request) + { + //$request is instance of \Connect\TierAccountRequest + try{ + //Get changes + $changes = $request->account->diffWithPreviousVersion(); + + //Do something with external system to change TA data + + throw new \Connect\TierAccountRequestAccept("Proocessed"); + } + catch (Exception $e){ + throw new \Connect\TierAccountRequestIgnore("Issue while processing, we ignore"); + } + } + +} + +//Main Code Block + +try{ + $tarProcessor = new ProcessTar(); + $tarProcessor->process(); +} catch (Exception $e) { + print "error ".$e->getMessage(); +} +``` + ## Client class Starting with the Connect PHP SDK version 17 the Client class has been introduced. This class allows running multiple operations in Connect like get the list of requests, configurations, etc. Client class may be instantiated from any application to obtain information needed to run an operation, like, for example, get the Asset information in the context of an action. Client will provide access to: @@ -337,3 +375,60 @@ $requests = $connect->fulfillment->listRequests(['status' => 'approved']); $connect = new Connect\ConnectClient(); $request = $connect->fulfillment->getRequest('PR-XXXX-XXXX-XXXXX'); ``` + +* List all Tier Accoounts + +```php +directory->listTierAccounts(['marketplace' => 'MP-XXXXXXX']); +``` + +* Get concrete Tier Account + +```php +directory->getTierAccountById('TA-XXXXXX-XXXXX'); +``` + +* List tier account requests + +```php +directory->listTierAccountRequests(['status' => 'pending']); +``` + +* List Asset Subscriptions + +```php +subscriptions->listSubscriptionAssets(); +``` + +* Get Subscription Asset + +```php +subscriptions->getSubscriptionAssetById('AS-1234-1234'); +``` + +* Get Billing Subscription Requests + +```php +subscriptions->listSubscriptionRequests(); +``` + +* Get concrete Billing request + +```php +subscriptions->getSubscriptionRequestById('PR-XXXXX-XXXXX-XXXXX'); +``` \ No newline at end of file diff --git a/composer.json b/composer.json index 6008dfc..b2124b6 100644 --- a/composer.json +++ b/composer.json @@ -12,12 +12,12 @@ "psr/log": "^1.0.0", "pimple/pimple": "^3.0", "guzzlehttp/guzzle": "~6.0", - "phpoffice/phpspreadsheet": "^1.6" + "phpoffice/phpspreadsheet": "^1.6", + "lukascivil/treewalker": "^0.9" }, "require-dev": { "phpunit/phpunit": "^5.7", - "mockery/mockery": "^1.0", - "lukascivil/treewalker": "^0.9" + "mockery/mockery": "^1.0" }, "autoload": { "psr-4": { diff --git a/phpunit.xml b/phpunit.xml index 5dbddb7..1dbd74b 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -10,9 +10,17 @@ - tests/Unit/DirectoryTests/AssetTest.php - tests/Unit/DirectoryTests/ProductTest.php - tests/Unit/DirectoryTests/TierConfigTest.php + tests/Unit/DirectoryTests/AssetTest.php + tests/Unit/DirectoryTests/ProductTest.php + tests/Unit/DirectoryTests/TierConfigTest.php + tests/Unit/DirectoryTests/TierAccountsTest.php + + + tests/Unit/SubscriptionTests/SubscriptionRequestTest.php + + + tests/Unit/TierAccountRequests/ResponsesTest.php + tests/Unit/TierAccountRequests/TierAccountRequestsBasicsTest.php tests/Unit/FulfillmentTests/FailTest.php diff --git a/src/Account.php b/src/Account.php index 5482022..68e5400 100644 --- a/src/Account.php +++ b/src/Account.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/Activation.php b/src/Activation.php index fbaa15f..1bd2a37 100644 --- a/src/Activation.php +++ b/src/Activation.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/ActivationTemplateResponse.php b/src/ActivationTemplateResponse.php index 02f05c5..38fd4b3 100644 --- a/src/ActivationTemplateResponse.php +++ b/src/ActivationTemplateResponse.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/ActivationTileResponse.php b/src/ActivationTileResponse.php index f2ae5c2..0ca9696 100644 --- a/src/ActivationTileResponse.php +++ b/src/ActivationTileResponse.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/Agreement.php b/src/Agreement.php index 35d52e5..09117dc 100644 --- a/src/Agreement.php +++ b/src/Agreement.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/Asset.php b/src/Asset.php index 6c295ef..b19b707 100644 --- a/src/Asset.php +++ b/src/Asset.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/AutomationEngine.php b/src/AutomationEngine.php index d215bdf..ec6cabb 100644 --- a/src/AutomationEngine.php +++ b/src/AutomationEngine.php @@ -3,12 +3,13 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; use Connect\Modules\Fulfillment; +use Connect\Modules\Subscriptions; use Connect\Modules\TierConfiguration; use Connect\Modules\Usage; use Connect\Modules\Directory; @@ -27,6 +28,7 @@ * @property TierConfiguration $tierConfiguration * @property Usage $usage * @property Directory $directory + * @property Subscriptions $subscriptions * @package Connect */ abstract class AutomationEngine diff --git a/src/By.php b/src/By.php index a4e3c4d..f812d49 100644 --- a/src/By.php +++ b/src/By.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/Choice.php b/src/Choice.php index bad2311..d4a523d 100644 --- a/src/Choice.php +++ b/src/Choice.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/Config.php b/src/Config.php index 3cb493d..73bd6f6 100644 --- a/src/Config.php +++ b/src/Config.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; @@ -76,7 +76,8 @@ class Config extends Model 'fulfillment' => '\Connect\Runtime\Providers\FulfillmentServiceProvider', 'tierConfiguration' => '\Connect\Runtime\Providers\TierConfigurationServiceProvider', 'usage' => '\Connect\Runtime\Providers\UsageServiceProvider', - 'directory' => '\Connect\Runtime\Providers\DirectoryServiceProvider' + 'directory' => '\Connect\Runtime\Providers\DirectoryServiceProvider', + 'subscriptions' => '\Connect\Runtime\Providers\SubscriptionsServiceProvider' ]; /** diff --git a/src/Config/VaultConfig.php b/src/Config/VaultConfig.php index 2d636d0..a0f80a3 100644 --- a/src/Config/VaultConfig.php +++ b/src/Config/VaultConfig.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect\Config; diff --git a/src/ConfigException.php b/src/ConfigException.php index 5d50b8e..e33a726 100644 --- a/src/ConfigException.php +++ b/src/ConfigException.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/ConfigPropertyMissed.php b/src/ConfigPropertyMissed.php index 9c50192..0440e1a 100644 --- a/src/ConfigPropertyMissed.php +++ b/src/ConfigPropertyMissed.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/Configuration.php b/src/Configuration.php index f928429..7bfecc6 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/ConnectClient.php b/src/ConnectClient.php index b986718..17afd4b 100644 --- a/src/ConnectClient.php +++ b/src/ConnectClient.php @@ -2,7 +2,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2018. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/Connection.php b/src/Connection.php index 4a57f38..829f9b7 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/Constants.php b/src/Constants.php index c07d3a4..55227d0 100644 --- a/src/Constants.php +++ b/src/Constants.php @@ -2,7 +2,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2018. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; @@ -11,10 +11,18 @@ class Constants { const USAGE_FILES_PATH = '/usage/files/'; const SPREADSHEET_SHEET_NAME = 'usage_records'; + const SPREADSHEET_SHEET_CATEGORIES = 'categories'; const TIER_CONFIG_REQUESTS_PATH = '/tier/config-requests/'; const REQUESTS_PATH = '/requests/'; const APPROVE_SUFFIX = '/approve'; const INQUIRE_SUFFIX = '/inquire'; const FAIL_SUFFIX = '/fail'; + const PRODUCTS_PATH = '/products/'; + const TIER_ACCOUNTS_PATH = '/tier/accounts/'; + const TIER_CONFIG_PATH = '/tier/configs/'; + const TIER_ACCOUNT_REQUESTS_PATH = '/tier/account-requests/'; const GENERIC_CONVERSATION_ERROR_MESSAGE = 'Error while saving result on conversation for request '; + const SUBSCRIPTIONS_ASSETS_PATH = '/subscriptions/assets/'; + const SUBSCRIPTIONS_REQUESTS_PATH = '/subscriptions/requests/'; + const ASSETS_PATH = '/assets/'; } diff --git a/src/Constraints.php b/src/Constraints.php index 1d38a51..1fcb3ff 100644 --- a/src/Constraints.php +++ b/src/Constraints.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/Contact.php b/src/Contact.php index 09d21e1..288e61e 100644 --- a/src/Contact.php +++ b/src/Contact.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/ContactInfo.php b/src/ContactInfo.php index fb18b4b..baa4e53 100644 --- a/src/ContactInfo.php +++ b/src/ContactInfo.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/Contract.php b/src/Contract.php index 97b1dc2..191242c 100644 --- a/src/Contract.php +++ b/src/Contract.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/Conversation.php b/src/Conversation.php index 5b64b9b..2fd921d 100644 --- a/src/Conversation.php +++ b/src/Conversation.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; @@ -49,7 +49,7 @@ public function setMessages($messages) /** * @param string $message - * @return array|Model + * @return array|ConversationMessage * @throws ConfigException * @throws \GuzzleHttp\Exception\GuzzleException */ diff --git a/src/ConversationMessage.php b/src/ConversationMessage.php index bb7cc32..d1567b3 100644 --- a/src/ConversationMessage.php +++ b/src/ConversationMessage.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/Customer.php b/src/Customer.php index d7589c6..3a0cdb1 100644 --- a/src/Customer.php +++ b/src/Customer.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/Event.php b/src/Event.php index 95f0fb9..19a54d5 100644 --- a/src/Event.php +++ b/src/Event.php @@ -2,7 +2,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/Events.php b/src/Events.php index 22e3a84..a5567e9 100644 --- a/src/Events.php +++ b/src/Events.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/Exception.php b/src/Exception.php index 54bafb7..90d75df 100644 --- a/src/Exception.php +++ b/src/Exception.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/Fail.php b/src/Fail.php index 70be407..ef7b0d0 100644 --- a/src/Fail.php +++ b/src/Fail.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/FulfillmentAutomation.php b/src/FulfillmentAutomation.php index 6a0751d..fa966da 100644 --- a/src/FulfillmentAutomation.php +++ b/src/FulfillmentAutomation.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; @@ -44,7 +44,7 @@ protected function dispatchTierConfig($tierConfigRequest) if ($this->config->products && !in_array( $tierConfigRequest->configuration->product->id, $this->config->products - )) { + )) { return 'Invalid product'; } diff --git a/src/FulfillmentAutomationInterface.php b/src/FulfillmentAutomationInterface.php index aa66a3f..f395797 100644 --- a/src/FulfillmentAutomationInterface.php +++ b/src/FulfillmentAutomationInterface.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/Hub.php b/src/Hub.php index 307608b..6e92758 100644 --- a/src/Hub.php +++ b/src/Hub.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/Inquire.php b/src/Inquire.php index 90d156a..3272c91 100644 --- a/src/Inquire.php +++ b/src/Inquire.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/Item.php b/src/Item.php index b978f36..01e4500 100644 --- a/src/Item.php +++ b/src/Item.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; @@ -16,8 +16,15 @@ class Item extends Model { /** * @var string + * @deprecated */ public $display_name; + + /** + * @var string + */ + public $name; + /** * @var string */ @@ -58,11 +65,6 @@ class Item extends Model */ public $renewal; - /** - * @var name - */ - public $name; - /** * @var Param[] */ diff --git a/src/Listing.php b/src/Listing.php index 6137ae4..f2e56c2 100644 --- a/src/Listing.php +++ b/src/Listing.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/Logger.php b/src/Logger.php index 4065a87..f206cd5 100644 --- a/src/Logger.php +++ b/src/Logger.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/Logger/LogRecord.php b/src/Logger/LogRecord.php index a2712a6..d2e5b4f 100644 --- a/src/Logger/LogRecord.php +++ b/src/Logger/LogRecord.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect\Logger; diff --git a/src/Logger/LogSession.php b/src/Logger/LogSession.php index de2a6b5..6ec97d1 100644 --- a/src/Logger/LogSession.php +++ b/src/Logger/LogSession.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect\Logger; diff --git a/src/Logger/LoggerInterface.php b/src/Logger/LoggerInterface.php index b5d491c..d97e448 100644 --- a/src/Logger/LoggerInterface.php +++ b/src/Logger/LoggerInterface.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect\Logger; diff --git a/src/Marketplace.php b/src/Marketplace.php index 9e4ac9a..bdb1ace 100644 --- a/src/Marketplace.php +++ b/src/Marketplace.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/Message.php b/src/Message.php index 65d6dfb..9a8c8d2 100644 --- a/src/Message.php +++ b/src/Message.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/Model.php b/src/Model.php index 4947146..943b859 100644 --- a/src/Model.php +++ b/src/Model.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; @@ -170,7 +170,12 @@ public static function modelize($key, $value) switch (gettype($value)) { case 'object': - $namespaces = ['\Connect\\', '\Connect\Usage\\']; + $namespaces = ['\Connect\\', + '\Connect\Usage\\', + '\Connect\Product\Capabilities\\', + 'Connect\Product\Actions\\', + 'Connect\Subscription\\' + ]; /** * if the item is an object search if there are any model that match with it: diff --git a/src/Modules/Core.php b/src/Modules/Core.php index 5b15a47..c7d48c6 100644 --- a/src/Modules/Core.php +++ b/src/Modules/Core.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect\Modules; diff --git a/src/Modules/Directory.php b/src/Modules/Directory.php index fdbd189..5fc3362 100644 --- a/src/Modules/Directory.php +++ b/src/Modules/Directory.php @@ -2,15 +2,17 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2018. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect\Modules; use Connect\Config; +use Connect\Constants; use Connect\Model; use Connect\Asset; use Connect\Product; +use Connect\TierAccount; use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\GuzzleException; use Psr\Log\LoggerInterface; @@ -36,7 +38,7 @@ public function __construct(Config $config, LoggerInterface $logger, ClientInter /** * List the Assets - * @param $filters, it may be due backwards compatibility an array of key->value + * @param $filters , it may be due backwards compatibility an array of key->value * or object of class \Connect\RQL * @return Asset[] * @throws GuzzleException @@ -57,7 +59,7 @@ public function listAssets($filters = null) : explode(',', $this->config->products)); } - $body = $this->sendRequest('GET', '/assets' . $query->compile()); + $body = $this->sendRequest('GET', \Connect\Constants::ASSETS_PATH . $query->compile()); /** @var Asset[] $models */ return Model::modelize('assets', json_decode($body)); @@ -70,7 +72,7 @@ public function listAssets($filters = null) */ public function getAssetById($assetID) { - $body = $this->sendRequest('GET', '/assets/' . $assetID); + $body = $this->sendRequest('GET', \Connect\Constants::ASSETS_PATH . $assetID); /** @var Asset $model */ return Model::modelize('asset', json_decode($body)); } @@ -89,7 +91,7 @@ public function listProducts($filters = null) $query = new \Connect\RQL\Query(); } - $body = $this->sendRequest('GET', '/products' . $query->compile()); + $body = $this->sendRequest('GET', \Connect\Constants::PRODUCTS_PATH . $query->compile()); /** @var \Connect\Product[] $models */ return Model::modelize('products', json_decode($body)); @@ -103,7 +105,7 @@ public function listProducts($filters = null) public function getProduct($productID) { - $body = $this->sendRequest('GET', '/products/'.$productID); + $body = $this->sendRequest('GET', \Connect\Constants::PRODUCTS_PATH . $productID); /** @var Product $model */ return Model::modelize('product', json_decode($body)); } @@ -129,7 +131,7 @@ public function listTierConfigs($filters = null) : explode(',', $this->config->products)); } - $body = $this->sendRequest('GET', '/tier/configs' . $query->compile()); + $body = $this->sendRequest('GET', \Connect\Constants::TIER_CONFIG_PATH . $query->compile()); /** @var \Connect\TierConfig[] $models */ return Model::modelize('tierConfig', json_decode($body)); @@ -142,8 +144,94 @@ public function listTierConfigs($filters = null) */ public function getTierConfigById($id) { - $body = $this->sendRequest('GET', '/tier/configs/' . $id); + $body = $this->sendRequest('GET', \CONNECT\Constants::TIER_CONFIG_PATH . $id); /** @var \Connect\TierConfig $model */ return Model::modelize('tierConfig', json_decode($body)); } + + /** + * @param null $filters + * @return array|TierAccount + * @throws GuzzleException + * Available filters + * id + * external_id + * external_uid + * environment + * scopes + * marketplace.id + * marketplace.name + * hub.id + * hub.name + */ + public function listTierAccounts($filters = null) + { + if ($filters instanceof \Connect\RQL\Query) { + $query = $filters; + } elseif (is_array($filters)) { + $query = new \Connect\RQL\Query($filters); + } else { + $query = new \Connect\RQL\Query(); + } + + $body = $this->sendRequest('GET', \Connect\Constants::TIER_ACCOUNTS_PATH . $query->compile()); + /** @var \Connect\TierAccount[] $model */ + return Model::modelize('tierAccount', json_decode($body)); + } + + /** + * @param $id + * @return array|Model + * @throws GuzzleException + */ + public function getTierAccountById($id) + { + $body = $this->sendRequest('GET', \Connect\Constants::TIER_ACCOUNTS_PATH . $id); + return Model::modelize('tierAccount', json_decode($body)); + } + + /** + * @param null $filters + * @return array|Model + * @throws GuzzleException + * Possible filters: + * -status + * -id + * -product.id + * -product.name + * -vendor.id + * -vendor.name + * -provider.id + * -provider.name + * -account.id + * -account.name + * -account.external_id + * -account.external_uid + * -account.environment + * -account.scopes + * -account.marketplace.id + * -account.marketplace.name + * -account.hub.id + * -account.hub.name + */ + public function listTierAccountRequests($filters = null) + { + if ($filters instanceof \Connect\RQL\Query) { + $query = $filters; + } elseif (is_array($filters)) { + $query = new \Connect\RQL\Query($filters); + } else { + $query = new \Connect\RQL\Query(); + } + $body = $this->sendRequest('GET', Constants::TIER_ACCOUNT_REQUESTS_PATH. $query->compile()); + /** @var \Connect\TierAccountRequest[] $model */ + return Model::modelize('tierAccountRequest', json_decode($body)); + } + + public function createTierAccountRequest(\Connect\TierAccountRequest $request) + { + $body = $this->sendRequest('POST', Constants::TIER_ACCOUNT_REQUESTS_PATH, json_encode($request)); + /** @var \Connect\TierAccountRequest[] $model */ + return Model::modelize('tierAccountRequest', json_decode($body)); + } } diff --git a/src/Modules/Fulfillment.php b/src/Modules/Fulfillment.php index 13f8507..982a2fb 100644 --- a/src/Modules/Fulfillment.php +++ b/src/Modules/Fulfillment.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect\Modules; @@ -46,7 +46,7 @@ public function __construct(Config $config, LoggerInterface $logger, ClientInter /** * List the pending requests * @param array $filters Filter for listing key->value or key->array(value1, value2) - * @return array|Model + * @return array|Request * @throws GuzzleException */ public function listRequests(array $filters = []) @@ -121,7 +121,7 @@ public function __call($name, $arguments) /** * @param $requestId - * @return array|Model + * @return array|Request * @throws GuzzleException * @throws \Connect\ConfigException */ @@ -134,7 +134,7 @@ public function getRequest($requestId) /** * To be used only with provider token * @param Request $request - * @return array|Model + * @return array|Request * @throws GuzzleException * @throws \Connect\ConfigException */ diff --git a/src/Modules/Subscriptions.php b/src/Modules/Subscriptions.php new file mode 100644 index 0000000..cbe4dea --- /dev/null +++ b/src/Modules/Subscriptions.php @@ -0,0 +1,146 @@ +config->products) { + $query->in('product.id', is_array($this->config->products) + ? $this->config->products + : explode(',', $this->config->products)); + } + + $body = $this->sendRequest('GET', Constants::SUBSCRIPTIONS_ASSETS_PATH . $query->compile()); + + /** @var \Connect\Subscription\SubscriptionAsset[] $models */ + return Model::modelize('SubscriptionAsset', json_decode($body)); + } + + /** + * @param $id + * @return SubscriptionAsset + * @throws GuzzleException + */ + public function getSubscriptionAssetById($id) + { + $body = $this->sendRequest('GET', Constants::SUBSCRIPTIONS_ASSETS_PATH .$id); + return Model::modelize('SubscriptionAsset', json_decode($body)); + } + + /** + * @param null $filters + * @return array|SubscriptionRequest + * @throws GuzzleException + * Possible filters: + * type + * events.created.at (le, ge) + * events.created.at (le, ge) + * asset.billing.period.uom + * asset.billing.next_date + * asset.external_id + * asset.external_uid + * asset.product.id + * asset.product.name + * asset.connection.id + * asset.connection.type + * asset.connection.provider.id + * asset.connection.provider.name + * asset.connection.vendor.id + * asset.connection.vendor.name + * asset.connection.hub.id + * asset.tiers.customer.id (Customer ID) + * asset.tiers.tier1.id + * asset.tiers.tier2.id + */ + public function listSubscriptionRequests($filters = null) + { + $query = new \Connect\RQL\Query(); + + if (is_array($filters)) { + $query = new \Connect\RQL\Query($filters); + } elseif ($filters instanceof \Connect\RQL\Query) { + $query = $filters; + } + + if ($this->config->products) { + $query->in('product.id', is_array($this->config->products) + ? $this->config->products + : explode(',', $this->config->products)); + } + + $body = $this->sendRequest('GET', Constants::SUBSCRIPTIONS_REQUESTS_PATH . $query->compile()); + /** @var \Connect\Subscription\SubscriptionRequest[] $models */ + return Model::modelize('SubscriptionRequests', json_decode($body)); + } + + public function getSubscriptionRequestById($id) + { + $body = $this->sendRequest('GET', Constants::SUBSCRIPTIONS_REQUESTS_PATH .$id); + return Model::modelize('SubscriptionRequest', json_decode($body)); + } +} diff --git a/src/Modules/TierConfiguration.php b/src/Modules/TierConfiguration.php index 59fe4f9..db5a254 100644 --- a/src/Modules/TierConfiguration.php +++ b/src/Modules/TierConfiguration.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect\Modules; diff --git a/src/Modules/Usage.php b/src/Modules/Usage.php index 2169919..163cfa0 100644 --- a/src/Modules/Usage.php +++ b/src/Modules/Usage.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect\Modules; @@ -119,16 +119,12 @@ public function listUsageFiles(array $filters = null) /** * @param File $usageFile - * @return array|Model + * @return array|File * @throws FileCreationException * @throws GuzzleException */ public function createUsageFile(File $usageFile) { - if (!isset($usageFile->name) || !isset($usageFile->product->id) || !isset($usageFile->contract->id)) { - throw new FileCreationException("Usage File Creation requieres name, product id, contract id"); - } - if (!isset($usageFile->description)) { $usageFile->description = ""; } @@ -150,13 +146,31 @@ private function createUsageSpreadSheet() ), 0); $spreadSheet->setActiveSheetIndexByName(Constants::SPREADSHEET_SHEET_NAME); $spreadSheet->getActiveSheet()->setCellValue('A1', "record_id"); - $spreadSheet->getActiveSheet()->setCellValue('B1', "item_search_criteria"); - $spreadSheet->getActiveSheet()->setCellValue('C1', "item_search_value"); - $spreadSheet->getActiveSheet()->setCellValue('D1', "quantity"); - $spreadSheet->getActiveSheet()->setCellValue('E1', "start_time_utc"); - $spreadSheet->getActiveSheet()->setCellValue('F1', "end_time_utc"); - $spreadSheet->getActiveSheet()->setCellValue('G1', "asset_search_criteria"); - $spreadSheet->getActiveSheet()->setCellValue('H1', "asset_search_value"); + $spreadSheet->getActiveSheet()->setCellValue('B1', "record_note"); + $spreadSheet->getActiveSheet()->setCellValue('C1', "item_search_criteria"); + $spreadSheet->getActiveSheet()->setCellValue('D1', "item_search_value"); + $spreadSheet->getActiveSheet()->setCellValue('E1', "amount"); + $spreadSheet->getActiveSheet()->setCellValue('F1', "quantity"); + $spreadSheet->getActiveSheet()->setCellValue('G1', "start_time_utc"); + $spreadSheet->getActiveSheet()->setCellValue('H1', "end_time_utc"); + $spreadSheet->getActiveSheet()->setCellValue('I1', "asset_search_criteria"); + $spreadSheet->getActiveSheet()->setCellValue('J1', "asset_search_value"); + $spreadSheet->getActiveSheet()->setCellValue('K1', "item_name"); + $spreadSheet->getActiveSheet()->setCellValue('L1', "item_mpn"); + $spreadSheet->getActiveSheet()->setCellValue('M1', "item_precision"); + $spreadSheet->getActiveSheet()->setCellValue('N1', "item_unit"); + $spreadSheet->getActiveSheet()->setCellValue('O1', "category_id"); + $spreadSheet->getActiveSheet()->setCellValue('P1', "asset_recon_id"); + $spreadSheet->getActiveSheet()->setCellValue('Q1', "tier"); + + $spreadSheet->addSheet(new \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet( + $spreadSheet, + Constants::SPREADSHEET_SHEET_CATEGORIES + ), 1); + $spreadSheet->setActiveSheetIndexByName(Constants::SPREADSHEET_SHEET_CATEGORIES); + $spreadSheet->getActiveSheet()->setCellValue('A1', "category_id"); + $spreadSheet->getActiveSheet()->setCellValue('B1', "category_name"); + $spreadSheet->getActiveSheet()->setCellValue('C1', "category_description"); return $spreadSheet; } @@ -206,7 +220,7 @@ private function uploadSpreadSheet(File $usageFile, Spreadsheet $spreadSheet) ] ); } catch (GuzzleException $e) { - throw new FileCreationException("Error uploading file:" . $e->getMessage()); + throw new FileCreationException("Error uploading file:" . $e->getResponse()->getBody()->getContents()); } $this->logger->info('HTTP Code: ' . $response->getStatusCode()); @@ -220,22 +234,55 @@ private function uploadSpreadSheet(File $usageFile, Spreadsheet $spreadSheet) /** * @param array $fileusagerecords + * @param array\FileUsageCategory $categories | null * @return Spreadsheet * @throws \PhpOffice\PhpSpreadsheet\Exception */ - private function createAndPopulateSpreadSheet($fileusagerecords) + private function createAndPopulateSpreadSheet($fileusagerecords, $usageFileID, $categories = null) { $spreadSheet = $this->createUsageSpreadSheet(); $spreadSheet->setActiveSheetIndexByName(Constants::SPREADSHEET_SHEET_NAME); for ($i = 0; $i < count($fileusagerecords); $i++) { - $spreadSheet->getActiveSheet()->setCellValue('A' . ($i + 2), $fileusagerecords[$i]->record_id); - $spreadSheet->getActiveSheet()->setCellValue('B' . ($i + 2), $fileusagerecords[$i]->item_search_criteria); - $spreadSheet->getActiveSheet()->setCellValue('C' . ($i + 2), $fileusagerecords[$i]->item_search_value); - $spreadSheet->getActiveSheet()->setCellValue('D' . ($i + 2), $fileusagerecords[$i]->quantity); - $spreadSheet->getActiveSheet()->setCellValue('E' . ($i + 2), $fileusagerecords[$i]->start_time_utc); - $spreadSheet->getActiveSheet()->setCellValue('F' . ($i + 2), $fileusagerecords[$i]->end_time_utc); - $spreadSheet->getActiveSheet()->setCellValue('G' . ($i + 2), $fileusagerecords[$i]->asset_search_criteria); - $spreadSheet->getActiveSheet()->setCellValue('H' . ($i + 2), $fileusagerecords[$i]->asset_search_value); + $spreadSheet->getActiveSheet()->setCellValue('A' . ($i + 2), (is_null($fileusagerecords[$i]->record_id) ? $usageFileID."_record_".$i:$fileusagerecords[$i]->record_id)); + $spreadSheet->getActiveSheet()->setCellValue('B' . ($i + 2), $fileusagerecords[$i]->record_note); + $spreadSheet->getActiveSheet()->setCellValue('C' . ($i + 2), $fileusagerecords[$i]->item_search_criteria); + $spreadSheet->getActiveSheet()->setCellValue('D' . ($i + 2), $fileusagerecords[$i]->item_search_value); + $spreadSheet->getActiveSheet()->setCellValue('E' . ($i + 2), (is_null($fileusagerecords[$i]->amount) ? "":$fileusagerecords[$i]->amount)); + $spreadSheet->getActiveSheet()->setCellValue('F' . ($i + 2), (is_null($fileusagerecords[$i]->quantity) ? "":$fileusagerecords[$i]->quantity)); + $spreadSheet->getActiveSheet()->setCellValue('G' . ($i + 2), $fileusagerecords[$i]->start_time_utc); + $spreadSheet->getActiveSheet()->setCellValue('H' . ($i + 2), $fileusagerecords[$i]->end_time_utc); + $spreadSheet->getActiveSheet()->setCellValue('I' . ($i + 2), $fileusagerecords[$i]->asset_search_criteria); + $spreadSheet->getActiveSheet()->setCellValue('J' . ($i + 2), $fileusagerecords[$i]->asset_search_value); + $spreadSheet->getActiveSheet()->setCellValue('K' . ($i + 2), (is_null($fileusagerecords[$i]->item_name) ? "":$fileusagerecords[$i]->item_name)); + $spreadSheet->getActiveSheet()->setCellValue('L' . ($i + 2), (is_null($fileusagerecords[$i]->item_mpn) ? "":$fileusagerecords[$i]->item_mpn)); + $spreadSheet->getActiveSheet()->setCellValue('M' . ($i + 2), (is_null($fileusagerecords[$i]->item_precision) ? "":$fileusagerecords[$i]->item_precision)); + $spreadSheet->getActiveSheet()->setCellValue('N' . ($i + 2), (is_null($fileusagerecords[$i]->item_unit) ? "":$fileusagerecords[$i]->item_unit)); + $spreadSheet->getActiveSheet()->setCellValue('O' . ($i + 2), (is_null($fileusagerecords[$i]->category_id) ? "generic_category":$fileusagerecords[$i]->category_id)); + $spreadSheet->getActiveSheet()->setCellValue('P' . ($i + 2), (is_null($fileusagerecords[$i]->asset_recon_id) ? "":$fileusagerecords[$i]->asset_recon_id)); + $spreadSheet->getActiveSheet()->setCellValue('Q' . ($i + 2), (is_null($fileusagerecords[$i]->tier) ? "":$fileusagerecords[$i]->tier)); + } + + return $this->populateCategories($spreadSheet, $categories); + } + + /** + * @param $spreadSheet + * @param $categories + * @return mixed + */ + private function populateCategories($spreadSheet, $categories) + { + $spreadSheet->setActiveSheetIndexByName(Constants::SPREADSHEET_SHEET_CATEGORIES); + if (is_null($categories)) { + $spreadSheet->getActiveSheet()->setCellValue('A2', 'generic_category'); + $spreadSheet->getActiveSheet()->setCellValue('B2', 'Generic Category'); + $spreadSheet->getActiveSheet()->setCellValue('C2', 'Generic autogenerated category'); + } else { + for ($i = 0; $i < count($categories); $i++) { + $spreadSheet->getActiveSheet()->setCellValue('A' . ($i + 2), $categories[$i]->category_id); + $spreadSheet->getActiveSheet()->setCellValue('B' . ($i + 2), $categories[$i]->category_name); + $spreadSheet->getActiveSheet()->setCellValue('C' . ($i + 2), $categories[$i]->category_description); + } } return $spreadSheet; } @@ -247,11 +294,11 @@ private function createAndPopulateSpreadSheet($fileusagerecords) * @throws FileCreationException * @throws FileRetrieveException */ - public function uploadUsageRecords(File $usageFile, $fileRecords) + public function uploadUsageRecords(File $usageFile, $fileRecords, $categories = null) { //Using XLSX mechanism till usage records json api is available try { - $spreadsheet = $this->createAndPopulateSpreadSheet($fileRecords); + $spreadsheet = $this->createAndPopulateSpreadSheet($fileRecords, $usageFile->id, $categories); return $this->uploadSpreadSheet($usageFile, $spreadsheet); } catch (\PhpOffice\PhpSpreadsheet\Exception $e) { throw new FileCreationException("Error processing usage records: " . $e->getMessage()); @@ -304,15 +351,15 @@ private function retrieveUsageTemplate($downloadlocation) /** * @param File $file * @param FileUsageRecord[] $usageRecords - * @return array|Model + * @return array|File * @throws FileCreationException * @throws FileRetrieveException * @throws GuzzleException */ - public function submitUsage(File $file, $usageRecords) + public function submitUsage(File $file, $usageRecords, $categories=null) { $usageFile = $this->createUsageFile($file); - $this->uploadUsageRecords($usageFile, $usageRecords); + $this->uploadUsageRecords($usageFile, $usageRecords, $categories); return $usageFile; } diff --git a/src/OpenRequest.php b/src/OpenRequest.php index 3cbfe18..d942b12 100644 --- a/src/OpenRequest.php +++ b/src/OpenRequest.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/Owner.php b/src/Owner.php index 44bb546..9b69bb0 100644 --- a/src/Owner.php +++ b/src/Owner.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/Param.php b/src/Param.php index 25472f8..5648a1d 100644 --- a/src/Param.php +++ b/src/Param.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/PhoneNumber.php b/src/PhoneNumber.php index 9d42dd8..6ecff80 100644 --- a/src/PhoneNumber.php +++ b/src/PhoneNumber.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/Product.php b/src/Product.php index b1f8274..13832ef 100644 --- a/src/Product.php +++ b/src/Product.php @@ -3,11 +3,13 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; +use Connect\Product\Actions\Action; + /** * Class Product * @package Connect @@ -80,6 +82,42 @@ class Product extends Model protected $stats; + /** + * @var ProductMedia + */ + + protected $media; + + /** + * @var ProductVisibility + */ + protected $visibility; + + /** + * @var ProductCapabilities + */ + protected $capabilities; + + /** + * @var bool + */ + public $latest; + + public function setCapabilities($capabilities) + { + $this->capabilities = Model::modelize('ProductCapabilities', $capabilities); + } + + public function setVisibility($visibility) + { + $this->visibility = Model::modelize('ProductVisibility', $visibility); + } + + public function setMedia($media) + { + $this->media = Model::modelize('ProductMedia', $media); + } + public function setStats($stats) { $this->stats = Model::modelize('ProductStats', $stats); @@ -100,15 +138,26 @@ public function setCategory($category) $this->category = Model::modelize('ProductCategory', $category); } + /** + * @return array|Template + * @throws ConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ public function getTemplates() { if ($this->id == null) { return []; } - $body = ConnectClient::getInstance()->directory->sendRequest('GET', '/products/'.$this->id.'/templates'); - return Model::modelize('templates', json_decode($body)); + $body = ConnectClient::getInstance()->directory->sendRequest('GET', Constants::PRODUCTS_PATH . $this->id . '/templates'); + return Model::modelize('Templates', json_decode($body)); } + /** + * @param RQL\Query|null $filter + * @return array|ProductConfigurationParameter + * @throws ConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ public function getProductConfigurations(RQL\Query $filter = null) { if ($this->id == null) { @@ -117,7 +166,90 @@ public function getProductConfigurations(RQL\Query $filter = null) if (!$filter) { $filter = new \Connect\RQL\Query(); } - $body = ConnectClient::getInstance()->directory->sendRequest('GET', '/products/'.$this->id.'/configurations'.$filter->compile()); + $body = ConnectClient::getInstance()->directory->sendRequest( + 'GET', + Constants::PRODUCTS_PATH . $this->id . '/configurations' . $filter->compile() + ); return Model::modelize('ProductConfigurationParameters', json_decode($body)); } + + /** + * @param RQL\Query|null $filter + * @return array|ProductMedia + * @throws ConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getAllMedia(RQL\Query $filter = null) + { + if ($this->id == null) { + return []; + } + if (!$filter) { + $filter = new \Connect\RQL\Query(); + } + $body = ConnectClient::getInstance()->directory->sendRequest( + 'GET', + Constants::PRODUCTS_PATH . $this->id . '/media' . $filter->compile() + ); + return Model::modelize('ProductMedias', json_decode($body)); + } + + /** + * @param RQL\Query|null $filter + * @return array|Item + * @throws ConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getAllItems(RQL\Query $filter = null) + { + if ($this->id == null) { + return []; + } + if (!$filter) { + $filter = new \Connect\RQL\Query(); + } + $body = ConnectClient::getInstance()->directory->sendRequest( + 'GET', + Constants::PRODUCTS_PATH . $this->id . '/items' . $filter->compile() + ); + return Model::modelize('Items', json_decode($body)); + } + + /** + * @param RQL\Query|null $filter + * @return array|Agreement + * @throws ConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getAllAgreements(RQL\Query $filter = null) + { + if ($this->id == null) { + return []; + } + if (!$filter) { + $filter = new \Connect\RQL\Query(); + } + $body = ConnectClient::getInstance()->directory->sendRequest( + 'GET', + Constants::PRODUCTS_PATH . $this->id . '/agreements' . $filter->compile() + ); + return Model::modelize('Agreements', json_decode($body)); + } + + /** + * @return array|Action + * @throws ConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getAllActions() + { + if ($this->id == null) { + return []; + } + $body = ConnectClient::getInstance()->directory->sendRequest( + 'GET', + Constants::PRODUCTS_PATH . $this->id . '/actions' + ); + return Model::modelize('Actions', json_decode($body)); + } } diff --git a/src/Product/Actions/Action.php b/src/Product/Actions/Action.php new file mode 100644 index 0000000..6933833 --- /dev/null +++ b/src/Product/Actions/Action.php @@ -0,0 +1,49 @@ +id)) { + return new PALink(); + } + $body = ConnectClient::getInstance()->directory->sendRequest('GET', '/products/'.$asset->product->id.'/actions/'.$this->id.'/actionLink'); + return Model::modelize('PALink', json_decode($body)); + } +} diff --git a/src/Product/Actions/PALink.php b/src/Product/Actions/PALink.php new file mode 100644 index 0000000..72391fa --- /dev/null +++ b/src/Product/Actions/PALink.php @@ -0,0 +1,18 @@ +ppu = Model::modelize('PCPPU', $ppu); + } + + public function setReservation($reservation) + { + $this->reservation = Model::modelize('PCReservation', $reservation); + } + + public function setCart($cart) + { + $this->cart = Model::modelize('PCCart', $cart); + } + + public function setTiers($tiers) + { + $this->tiers = Model::modelize('PCTiers', $tiers); + } + + public function setBilling($billing) + { + $this->billing = Model::modelize('PCBilling', $billing); + } +} diff --git a/src/ProductCategory.php b/src/ProductCategory.php index 2c60a86..8b59f07 100644 --- a/src/ProductCategory.php +++ b/src/ProductCategory.php @@ -2,7 +2,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2018. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/ProductConfiguration.php b/src/ProductConfiguration.php index c7deb43..72d72f4 100644 --- a/src/ProductConfiguration.php +++ b/src/ProductConfiguration.php @@ -2,7 +2,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2018. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/ProductConfigurationParameter.php b/src/ProductConfigurationParameter.php index 75ba7e1..34447af 100644 --- a/src/ProductConfigurationParameter.php +++ b/src/ProductConfigurationParameter.php @@ -2,7 +2,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2018. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/ProductCustomerUISettings.php b/src/ProductCustomerUISettings.php index 460aa22..43b83c5 100644 --- a/src/ProductCustomerUISettings.php +++ b/src/ProductCustomerUISettings.php @@ -2,7 +2,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2018. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; @@ -29,6 +29,21 @@ class ProductCustomerUISettings extends Model */ protected $documents; + /** + * @var ProductLanguages[] | null + */ + protected $languages; + + /** + * @var string; + */ + public $provisioning_message; + + public function setLanguages($languages) + { + $this->languages = Model::modelize('ProductLanguage', $languages); + } + public function setDownload_links($downloadLinks) { $this->download_links = Model::modelize('ProductDownloadLink', $downloadLinks); diff --git a/src/ProductDocument.php b/src/ProductDocument.php index b6f934e..3bf158f 100644 --- a/src/ProductDocument.php +++ b/src/ProductDocument.php @@ -2,7 +2,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2018. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/ProductDownloadLink.php b/src/ProductDownloadLink.php index db80d2c..438048b 100644 --- a/src/ProductDownloadLink.php +++ b/src/ProductDownloadLink.php @@ -2,7 +2,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2018. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/ProductLanguage.php b/src/ProductLanguage.php new file mode 100644 index 0000000..fa76b94 --- /dev/null +++ b/src/ProductLanguage.php @@ -0,0 +1,21 @@ +contracts = Model::modelize('ProductStatsCounters', $contracts); - } - - public function setAgreements($agreements) - { - $this->agreements = Model::modelize('ProductStatsCounters', $agreements); - } + public $versions; } diff --git a/src/ProductStatsCounters.php b/src/ProductStatsCounters.php deleted file mode 100644 index 2e4331a..0000000 --- a/src/ProductStatsCounters.php +++ /dev/null @@ -1,23 +0,0 @@ -last_request = Model::modelize('SubscriptionRequest', $last_request); + } +} diff --git a/src/Subscription/Anniversary.php b/src/Subscription/Anniversary.php new file mode 100644 index 0000000..be21591 --- /dev/null +++ b/src/Subscription/Anniversary.php @@ -0,0 +1,23 @@ +vendor = Model::modelize('Model', $vendor); + } + + public function setProvider($provider) + { + $this->provider = Model::modelize('Model', $provider); + } +} diff --git a/src/Subscription/Billing.php b/src/Subscription/Billing.php new file mode 100644 index 0000000..0507fca --- /dev/null +++ b/src/Subscription/Billing.php @@ -0,0 +1,47 @@ +stats = Model::modelize('Subscription\Stats', $stats); + } + + public function setPeriod($period) + { + $this->period = Model::modelize('Subscription\Period', $period); + } +} diff --git a/src/Subscription/Stats.php b/src/Subscription/Stats.php new file mode 100644 index 0000000..01a4195 --- /dev/null +++ b/src/Subscription/Stats.php @@ -0,0 +1,37 @@ +vendor = Model::modelize('ActorStats', $vendor); + } + + public function setProvider($provider) + { + $this->provider = Model::modelize('ActorStats', $provider); + } +} diff --git a/src/Subscription/SubscriptionAsset.php b/src/Subscription/SubscriptionAsset.php new file mode 100644 index 0000000..91548de --- /dev/null +++ b/src/Subscription/SubscriptionAsset.php @@ -0,0 +1,98 @@ +items = Model::modelize('subscriptionItems', $items); + } + + public function setBilling($billing) + { + $this->billing = Model::modelize('billing', $billing); + } +} diff --git a/src/Subscription/SubscriptionItem.php b/src/Subscription/SubscriptionItem.php new file mode 100644 index 0000000..1980917 --- /dev/null +++ b/src/Subscription/SubscriptionItem.php @@ -0,0 +1,86 @@ +billing = Model::modelize('Billing', $billing); + } +} diff --git a/src/Subscription/SubscriptionPeriod.php b/src/Subscription/SubscriptionPeriod.php new file mode 100644 index 0000000..a9b030d --- /dev/null +++ b/src/Subscription/SubscriptionPeriod.php @@ -0,0 +1,33 @@ +subscriptions->sendRequest('PUT', Constants::SUBSCRIPTIONS_REQUESTS_PATH.$this->id.'/attributes', json_encode(array("vendor" => $model->toArray()))); + $this->attributes->vendor = Model::modelize('Model', json_decode($output)); + } + + public function setProviderAttributes(Model $model) + { + $output = ConnectClient::getInstance()->subscriptions->sendRequest('PUT', Constants::SUBSCRIPTIONS_REQUESTS_PATH.$this->id.'/attributes', json_encode(array("provider" => $model->toArray()))); + $this->attributes->provider = Model::modelize('Model', json_decode($output)); + } + + public function setPeriod($period) + { + $this->period = Model::modelize('SubscriptionPeriod', $period); + } +} diff --git a/src/Template.php b/src/Template.php index 3f7027c..0f035c0 100644 --- a/src/Template.php +++ b/src/Template.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/Tier.php b/src/Tier.php index 399bd56..ee6eb66 100644 --- a/src/Tier.php +++ b/src/Tier.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Connect; diff --git a/src/TierAccount.php b/src/TierAccount.php new file mode 100644 index 0000000..30131bb --- /dev/null +++ b/src/TierAccount.php @@ -0,0 +1,107 @@ +contact_info) && $this->id) { + $tempAccount = ConnectClient::getInstance()->directory->sendRequest('GET', '/tier/accounts/'.$this->id); + $this->contact_info = \Connect\Model::modelize('ContactInfo', json_decode($tempAccount)->contact_info); + } + } + + public function diffWithPreviousVersion($version = null) + { + $treeWalker = new \TreeWalker( + array( + "returntype" => "array" + ) + ); + if ($version == null) { + $version = $this->version - 1; + } + $version = ConnectClient::getInstance()->directory->sendRequest( + 'GET', + '/tier/accounts/' . $this->id . '/versions/' . $version + ); + $diff = $treeWalker->getdiff(json_decode($this->toJSON()), json_decode($version), true); + unset($diff['edited']['version']); + return $diff; + } +} diff --git a/src/TierAccountRequest.php b/src/TierAccountRequest.php new file mode 100644 index 0000000..e1aa277 --- /dev/null +++ b/src/TierAccountRequest.php @@ -0,0 +1,66 @@ +account = Model::modelize('TierAccount', $account); + } +} diff --git a/src/TierAccountRequestAccept.php b/src/TierAccountRequestAccept.php new file mode 100644 index 0000000..e33df11 --- /dev/null +++ b/src/TierAccountRequestAccept.php @@ -0,0 +1,16 @@ +directory->listTierAccountRequests(['status' => 'pending']) as $tierAccountRequest) { + $this->dispatchTierAccountRequest($tierAccountRequest); + } + } + + /** + * @param $tierAccountRequest + * @return string + * @throws GuzzleException + */ + protected function dispatchTierAccountRequest($tierAccountRequest) + { + try { + if ($this->config->products && !in_array($tierAccountRequest->product->id, $this->config->products)) { + return 'Invalid product'; + } + + $processingResult = 'unknown'; + + $this->logger->info("Starting processing of Tier Account request with ID=" . $tierAccountRequest->id); + + /** @noinspection PhpVoidFunctionResultUsedInspection */ + $msg = $this->processTierAccountRequest($tierAccountRequest); + + if (is_string($msg)) { + $this->logger->warning("Result of Processing Tier account request returned $msg while is expected to return Exception of Tier Account Request types (TierAccountRequestAccept or TierAccountRequesIgnore)"); + } elseif ($msg) { + $this->logger->warning("Result of Processing Tier account request returned instance of " . gettype($msg) . " while is expected to return Exception of Tier Account Request types (TierAccountRequestAccept or TierAccountRequesIgnore)"); + } + } catch (TierAccountRequestAccept $e) { + $this->directory->sendRequest( + 'POST', + Constants::TIER_ACCOUNT_REQUESTS_PATH. $tierAccountRequest->id . '/accept/', + '{}' + ); + $processingResult = 'accept'; + } catch (TierAccountRequestIgnore $e) { + $this->usage->sendRequest( + 'POST', + Constants::TIER_ACCOUNT_REQUESTS_PATH. $tierAccountRequest->id . '/ignore/', + json_encode(['reason' => $e->getMessage()]) + ); + $processingResult = 'ignore'; + } + + $this->logger->info("Finished processing of Tier Account Request with ID=" . $tierAccountRequest->id . " result=" . $processingResult); + + return $processingResult; + } +} diff --git a/src/TierAccountRequestsAutomationInterface.php b/src/TierAccountRequestsAutomationInterface.php new file mode 100644 index 0000000..6ee9530 --- /dev/null +++ b/src/TierAccountRequestsAutomationInterface.php @@ -0,0 +1,22 @@ +assertInstanceOf('\Connect\Config', $cfg); $this->assertInternalType('array', $cfg->runtimeServices); - $this->assertCount(7, $cfg->runtimeServices); + $this->assertCount(8, $cfg->runtimeServices); } /** diff --git a/tests/Unit/DirectoryTests/AssetTest.php b/tests/Unit/DirectoryTests/AssetTest.php index b117fcd..e8c8e50 100644 --- a/tests/Unit/DirectoryTests/AssetTest.php +++ b/tests/Unit/DirectoryTests/AssetTest.php @@ -2,7 +2,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2018. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit\DirectoryTests; diff --git a/tests/Unit/DirectoryTests/ProductTest.php b/tests/Unit/DirectoryTests/ProductTest.php index a1d7ed3..583e53d 100644 --- a/tests/Unit/DirectoryTests/ProductTest.php +++ b/tests/Unit/DirectoryTests/ProductTest.php @@ -2,11 +2,12 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2018. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit\DirectoryTests; +use Connect\Asset; use Connect\Config; use Connect\ConnectClient; use Connect\RQL\Query; @@ -59,6 +60,25 @@ public function testGetProduct() foreach ($configurations as $configuration) { $this->assertInstanceOf('\Connect\ProductConfigurationParameter', $configuration); } + $mediaObject = $product->getAllMedia(); + foreach ($mediaObject as $media) { + $this->assertInstanceOf('\Connect\ProductMedia', $media); + } + $items = $product->getAllItems(); + foreach ($items as $item) { + $this->assertInstanceOf('\Connect\Item', $item); + } + $agreements = $product->getAllAgreements(); + foreach ($agreements as $agreement) { + $this->assertInstanceOf('\Connect\Agreement', $agreement); + } + $actions = $product->getAllActions(); + foreach ($actions as $action) { + $this->assertInstanceOf('Connect\Product\Actions\Action', $action); + } + $asset = new Asset(json_decode(file_get_contents(__DIR__.'/../Runtime/Providers/requestassets.json'))); + $link = $actions[0]->getActionLink($asset); + $this->assertInstanceOf('Connect\Product\Actions\PALink', $link); } public function testEmptyProductTemplates() @@ -74,4 +94,38 @@ public function testEmptyProductConfigurations() $configurations = $product->getProductConfigurations(); $this->assertCount(0, $configurations); } + + public function testEmptyProductMedia() + { + $product = new \Connect\Product(); + $media = $product->getAllMedia(); + $this->assertCount(0, $media); + } + + public function testEmptyItem() + { + $product = new \Connect\Product(); + $items = $product->getAllItems(); + $this->assertCount(0, $items); + } + + public function testEmptyAgreements() + { + $product = new \Connect\Product(); + $agreements = $product->getAllAgreements(); + $this->assertCount(0, $agreements); + } + + public function testEmptyActions() + { + $product = new \Connect\Product(); + $actions = $product->getAllActions(); + $this->assertCount(0, $actions); + } + + public function testEmptyActionLink() + { + $action = new \Connect\Product\Actions\Action(); + $this->assertInstanceOf('\Connect\Product\Actions\PALink', $action->getActionLink(new Asset())); + } } diff --git a/tests/Unit/DirectoryTests/TierAccountsTest.php b/tests/Unit/DirectoryTests/TierAccountsTest.php new file mode 100644 index 0000000..85fd540 --- /dev/null +++ b/tests/Unit/DirectoryTests/TierAccountsTest.php @@ -0,0 +1,43 @@ +directory->listTierAccounts(); + foreach ($accounts as $account) { + $this->assertInstanceOf("\Connect\TierAccount", $account); + } + } + + public function testGetTierAccountsRQL() + { + $connectClient = new ConnectClient(new Config(__DIR__ . '/config.mocked.getTierAccounts.json')); + $accounts = $connectClient->directory->listTierAccounts(new Query(['limit' => 3])); + foreach ($accounts as $account) { + $this->assertInstanceOf("\Connect\TierAccount", $account); + } + } + + public function testGetTierAccountsArray() + { + $connectClient = new ConnectClient(new Config(__DIR__ . '/config.mocked.getTierAccounts.json')); + $accounts = $connectClient->directory->listTierAccounts(['limit' => 3]); + foreach ($accounts as $account) { + $this->assertInstanceOf("\Connect\TierAccount", $account); + } + $this->assertInstanceOf("\Connect\TierAccount", $connectClient->directory->getTierAccountById($account->id)); + } +} diff --git a/tests/Unit/DirectoryTests/TierConfigTest.php b/tests/Unit/DirectoryTests/TierConfigTest.php index 62f4be3..2c8d3bd 100644 --- a/tests/Unit/DirectoryTests/TierConfigTest.php +++ b/tests/Unit/DirectoryTests/TierConfigTest.php @@ -2,7 +2,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2018. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit\DirectoryTests; diff --git a/tests/Unit/DirectoryTests/config.mocked.getTierAccounts.json b/tests/Unit/DirectoryTests/config.mocked.getTierAccounts.json new file mode 100644 index 0000000..982c660 --- /dev/null +++ b/tests/Unit/DirectoryTests/config.mocked.getTierAccounts.json @@ -0,0 +1,12 @@ +{ + "apiKey": "ApiKey SU-766-419-989:56fda6081cd5200f089d28f7f9a6d390bf7ffcec", + "apiEndpoint": "https://api.connect.cloud.im/public/v1", + "logLevel": 4, + "timeout": 10, + "sslVerifyHost": false, + "runtimeServices": { + "logger": "Test\\Unit\\Runtime\\Providers\\LoggerServiceProvider", + "http": "Test\\Unit\\Runtime\\Providers\\Http4DirectoryTierAccountsTestwithRequestServiceProvider", + "std": "Test\\Unit\\Runtime\\Providers\\StdClassServiceProvider" + } +} \ No newline at end of file diff --git a/tests/Unit/FulfillmentTests/ActivationTemplateResponseTest.php b/tests/Unit/FulfillmentTests/ActivationTemplateResponseTest.php index de3dfd7..814c6bc 100644 --- a/tests/Unit/FulfillmentTests/ActivationTemplateResponseTest.php +++ b/tests/Unit/FulfillmentTests/ActivationTemplateResponseTest.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; diff --git a/tests/Unit/FulfillmentTests/ActivationTileResponseTest.php b/tests/Unit/FulfillmentTests/ActivationTileResponseTest.php index 0c49ac1..da002c8 100644 --- a/tests/Unit/FulfillmentTests/ActivationTileResponseTest.php +++ b/tests/Unit/FulfillmentTests/ActivationTileResponseTest.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; diff --git a/tests/Unit/FulfillmentTests/FailTest.php b/tests/Unit/FulfillmentTests/FailTest.php index f94d2a9..a713705 100644 --- a/tests/Unit/FulfillmentTests/FailTest.php +++ b/tests/Unit/FulfillmentTests/FailTest.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; diff --git a/tests/Unit/FulfillmentTests/FulfillmentAutomationHelper.php b/tests/Unit/FulfillmentTests/FulfillmentAutomationHelper.php index caad2c5..dc4b0c6 100644 --- a/tests/Unit/FulfillmentTests/FulfillmentAutomationHelper.php +++ b/tests/Unit/FulfillmentTests/FulfillmentAutomationHelper.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; diff --git a/tests/Unit/FulfillmentTests/FulfillmentAutomationTest.php b/tests/Unit/FulfillmentTests/FulfillmentAutomationTest.php index 26bc91c..05e7dba 100644 --- a/tests/Unit/FulfillmentTests/FulfillmentAutomationTest.php +++ b/tests/Unit/FulfillmentTests/FulfillmentAutomationTest.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; @@ -117,6 +117,7 @@ public function testFakeShurtcut() $app = new RequestProcessorHelper(); $app->fulfillment->__call("wrong", array()); $app->usage->__call("wrong", array()); + $this->assertInstanceOf('Test\Unit\RequestProcessorHelper', $app); } public function testTemplateRetrive() diff --git a/tests/Unit/FulfillmentTests/InquireTest.php b/tests/Unit/FulfillmentTests/InquireTest.php index edbacb6..292b6dc 100644 --- a/tests/Unit/FulfillmentTests/InquireTest.php +++ b/tests/Unit/FulfillmentTests/InquireTest.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; diff --git a/tests/Unit/FulfillmentTests/RequestProcessorHelper.php b/tests/Unit/FulfillmentTests/RequestProcessorHelper.php index 5366a6a..624aa3a 100644 --- a/tests/Unit/FulfillmentTests/RequestProcessorHelper.php +++ b/tests/Unit/FulfillmentTests/RequestProcessorHelper.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; diff --git a/tests/Unit/FulfillmentTests/RequestTest.php b/tests/Unit/FulfillmentTests/RequestTest.php index 8dfd0f9..bd68a9e 100644 --- a/tests/Unit/FulfillmentTests/RequestTest.php +++ b/tests/Unit/FulfillmentTests/RequestTest.php @@ -2,7 +2,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; diff --git a/tests/Unit/FulfillmentTests/SkipTest.php b/tests/Unit/FulfillmentTests/SkipTest.php index a799b46..760ac12 100644 --- a/tests/Unit/FulfillmentTests/SkipTest.php +++ b/tests/Unit/FulfillmentTests/SkipTest.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; diff --git a/tests/Unit/FulfillmentTests/TierRequestHelper.php b/tests/Unit/FulfillmentTests/TierRequestHelper.php index f7d6dd2..a40bcae 100644 --- a/tests/Unit/FulfillmentTests/TierRequestHelper.php +++ b/tests/Unit/FulfillmentTests/TierRequestHelper.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; diff --git a/tests/Unit/FulfillmentTests/TierRequestTest.php b/tests/Unit/FulfillmentTests/TierRequestTest.php index 291e50c..38cd419 100644 --- a/tests/Unit/FulfillmentTests/TierRequestTest.php +++ b/tests/Unit/FulfillmentTests/TierRequestTest.php @@ -2,7 +2,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2018. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; diff --git a/tests/Unit/LoggerTest.php b/tests/Unit/LoggerTest.php index 6216b8a..579213e 100644 --- a/tests/Unit/LoggerTest.php +++ b/tests/Unit/LoggerTest.php @@ -2,7 +2,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; diff --git a/tests/Unit/MessageTest.php b/tests/Unit/MessageTest.php index 7f0c217..cc4990c 100644 --- a/tests/Unit/MessageTest.php +++ b/tests/Unit/MessageTest.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; diff --git a/tests/Unit/ModelsTests/AssetTest.php b/tests/Unit/ModelsTests/AssetTest.php index a66dc47..261741b 100644 --- a/tests/Unit/ModelsTests/AssetTest.php +++ b/tests/Unit/ModelsTests/AssetTest.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; diff --git a/tests/Unit/ModelsTests/ContactInfoTest.php b/tests/Unit/ModelsTests/ContactInfoTest.php index f45e5ab..5904943 100644 --- a/tests/Unit/ModelsTests/ContactInfoTest.php +++ b/tests/Unit/ModelsTests/ContactInfoTest.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; diff --git a/tests/Unit/ModelsTests/ModelHelper.php b/tests/Unit/ModelsTests/ModelHelper.php index f5a045d..8c2b98f 100644 --- a/tests/Unit/ModelsTests/ModelHelper.php +++ b/tests/Unit/ModelsTests/ModelHelper.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; diff --git a/tests/Unit/ModelsTests/ModelTest.php b/tests/Unit/ModelsTests/ModelTest.php index 559d380..b1b0a47 100644 --- a/tests/Unit/ModelsTests/ModelTest.php +++ b/tests/Unit/ModelsTests/ModelTest.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; diff --git a/tests/Unit/ModelsTests/ParamTest.php b/tests/Unit/ModelsTests/ParamTest.php index 94b96a1..924a03b 100644 --- a/tests/Unit/ModelsTests/ParamTest.php +++ b/tests/Unit/ModelsTests/ParamTest.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; diff --git a/tests/Unit/ModelsTests/RequestStructureTest.php b/tests/Unit/ModelsTests/RequestStructureTest.php index 2df4e91..38a2a88 100644 --- a/tests/Unit/ModelsTests/RequestStructureTest.php +++ b/tests/Unit/ModelsTests/RequestStructureTest.php @@ -2,7 +2,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; diff --git a/tests/Unit/ModelsTests/StructureTest.php b/tests/Unit/ModelsTests/StructureTest.php index 8907c16..b97b82f 100644 --- a/tests/Unit/ModelsTests/StructureTest.php +++ b/tests/Unit/ModelsTests/StructureTest.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; @@ -98,6 +98,7 @@ public function testAssetModel() public function testProductModel() { + $tobediscarted = ['customer_ui_settings/languages', 'capabilities/tiers/configs']; $apiOutput = json_decode(file_get_contents(__DIR__.'/apiOutput/product_request.json')); $product = Model::modelize('product', $apiOutput); $treeWalker = new \TreeWalker( @@ -111,11 +112,13 @@ public function testProductModel() fwrite(STDOUT, var_dump($difference['new'])); } $this->assertCount(0, $difference['new']); + $difference['removed'] = $this->removeDiscarted($difference['removed'], $tobediscarted); if (count($difference['removed']) > 0) { fwrite(STDOUT, "New model entries\n"); fwrite(STDOUT, var_dump($difference['removed'])); } $this->assertCount(0, $difference['removed']); + return $this; } @@ -203,10 +206,56 @@ public function testGetParamByIdOnItem() $this->assertEquals('item', $item->getParameterByID('item_per_marketplace')->value); } - public function getRequestParameter() + public function testgetRequestParameter() { $apiOutput = json_decode(file_get_contents(__DIR__.'/apiOutput/fulfillment_request.json')); $request = Model::modelize('request', $apiOutput); $this->assertEquals('Fulfillment param', $request->asset->getParameterByID('fulfillment_param_b')->value); } + + public function testSubscriptionAssetModel() + { + $apiOutput = json_decode(file_get_contents(__DIR__.'/apiOutput/SubscriptionAsset.json')); + $subscriptionAsset = Model::modelize('SubscriptionAsset', $apiOutput); + $treeWalker = new \TreeWalker( + array( + "debug"=>true, + "returntype"=>"array") + ); + $difference = $treeWalker->getdiff($subscriptionAsset->toJSON(), $apiOutput); + if (count($difference['new']) > 0) { + fwrite(STDOUT, "Removed SubscriptionAsset entries\n"); + fwrite(STDOUT, var_dump($difference['new'])); + } + $this->assertCount(0, $difference['new']); + if (count($difference['removed']) > 0) { + fwrite(STDOUT, "New model entries\n"); + fwrite(STDOUT, var_dump($difference['removed'])); + } + $this->assertCount(0, $difference['removed']); + return $this; + } + + public function testSubscriptionRequestModel() + { + $apiOutput = json_decode(file_get_contents(__DIR__.'/apiOutput/SubscriptionRequest.json')); + $subscriptioRequest = Model::modelize('SubscriptionRequest', $apiOutput); + $treeWalker = new \TreeWalker( + array( + "debug"=>true, + "returntype"=>"array") + ); + $difference = $treeWalker->getdiff($subscriptioRequest->toJSON(), $apiOutput); + if (count($difference['new']) > 0) { + fwrite(STDOUT, "Removed Subscription Request entries\n"); + fwrite(STDOUT, var_dump($difference['new'])); + } + $this->assertCount(0, $difference['new']); + if (count($difference['removed']) > 0) { + fwrite(STDOUT, "New model entries\n"); + fwrite(STDOUT, var_dump($difference['removed'])); + } + $this->assertCount(0, $difference['removed']); + return $this; + } } diff --git a/tests/Unit/ModelsTests/apiOutput/SubscriptionAsset.json b/tests/Unit/ModelsTests/apiOutput/SubscriptionAsset.json new file mode 100644 index 0000000..3adddef --- /dev/null +++ b/tests/Unit/ModelsTests/apiOutput/SubscriptionAsset.json @@ -0,0 +1,181 @@ +{ + "id": "AS-1611-4204-8054", + "status": "active", + "events": { + "created": { + "at": "2020-03-02T14:02:23+00:00" + }, + "updated": { + "at": "2020-03-02T14:03:38+00:00" + } + }, + "external_id": "QI1MKRTHNB", + "external_uid": "6ea4b798-fcda-4936-99d1-b9156d95bdbd", + "product": { + "id": "PRD-012-832-886", + "name": "Wordpress", + "status": "published", + "icon": "" + }, + "connection": { + "id": "CT-0000-0000-0000", + "hub": { + "id": "HB-0000-0000", + "name": "ACME Hub" + }, + "provider": { + "id": "PA-931-712", + "name": "Provider company for osrivastava" + }, + "vendor": { + "id": "VA-394-324", + "name": "APSConnect Dev" + }, + "type": "" + }, + "items": [ + { + "id": "SKU_A", + "display_name": "Sku A", + "global_id": "PRD-012-832-886-0001", + "item_type": "reservation", + "mpn": "MPN-A", + "period": "monthly", + "quantity": "72.0", + "billing": { + "stats": { + "vendor": { + "last_request": { + "id": "BRV-3639-3001-0669", + "type": "vendor", + "period": { + "from": "2020-03-02T13:30:18.295214+00:00", + "to": "2020-04-02T13:30:18.295214+00:00", + "delta": "1.0", + "uom": "monthly" + } + }, + "count": 3 + } + } + } + }, + { + "id": "SKU_B", + "display_name": "Sku B", + "global_id": "PRD-012-832-886-0002", + "item_type": "reservation", + "mpn": "MPN-B", + "period": "monthly", + "quantity": "47.0", + "billing": { + "stats": { + "vendor": { + "last_request": { + "id": "BRV-3639-3001-0669", + "type": "vendor", + "period": { + "from": "2020-03-02T13:30:18.295214+00:00", + "to": "2020-04-02T13:30:18.295214+00:00", + "delta": "1.0", + "uom": "monthly" + } + }, + "count": 3 + } + } + } + }, + { + "id": "PRD_012_832_886_0003", + "display_name": "ppu item", + "global_id": "PRD-012-832-886-0003", + "item_type": "ppu", + "mpn": "dascadsvadsv21313", + "period": "monthly", + "quantity": "-1.0" + } + ], + "params": [ + { + "id": "param_b", + "name": "Title of the Parameter B", + "description": "Description of the Parameter B", + "type": "text", + "value": "fsdfsd" + } + ], + "tiers": { + "customer": { + "id": "TA-9991-6127-7322", + "external_id": "25649", + "external_uid": "465ccb6b-f930-433c-a8ea-a9bd01a1279a", + "name": "Wisozk and Sons", + "contact_info": { + "address_line1": "Jordy Plain", + "address_line2": "Prosacco Coves", + "city": "Anxi County", + "state": "Fujian", + "postal_code": "362400", + "country": "CN", + "contact": { + "first_name": "Joany", + "last_name": "Hermiston", + "email": "akataev+Joany_Hermiston@odin.com", + "phone_number": { + "country_code": "86", + "area_code": "155", + "phone_number": "55319659" + } + } + } + } + }, + "marketplace": { + "id": "MP-67458", + "name": "China Marketplace", + "icon": "/media/PA-931-712/marketplaces/MP-67458/icon.png" + }, + "contract": { + "id": "CRD-00000-00000-00000", + "name": "ACME Distribution Contract" + }, + "billing": { + "period": { + "delta": "1.0", + "uom": "monthly" + }, + "next_date": "2020-04-02T13:46:58.636199+00:00", + "anniversary": { + "day": 2 + }, + "stats": { + "vendor": { + "last_request": { + "id": "BRV-9900-0013-9967", + "type": "vendor", + "period": { + "from": "2020-03-02T13:46:58.636199+00:00", + "to": "2020-04-02T13:46:58.636199+00:00", + "delta": "1.0", + "uom": "monthly" + } + }, + "count": 1 + }, + "provider": { + "last_request": { + "id": "BRV-9900-0013-9968", + "type": "provider", + "period": { + "from": "2020-03-02T13:46:58.636199+00:00", + "to": "2020-04-02T13:46:58.636199+00:00", + "delta": "1.0", + "uom": "monthly" + } + }, + "count": 1 + } + } + } +} \ No newline at end of file diff --git a/tests/Unit/ModelsTests/apiOutput/SubscriptionRequest.json b/tests/Unit/ModelsTests/apiOutput/SubscriptionRequest.json new file mode 100644 index 0000000..35fb7e2 --- /dev/null +++ b/tests/Unit/ModelsTests/apiOutput/SubscriptionRequest.json @@ -0,0 +1,82 @@ +{ + "id": "BRV-0000-0000-0002", + "type": "vendor", + "events": { + "created": { + "at": "2021-01-01T00:00:00+00:00" + }, + "updated": { + "at": "2021-01-01T00:00:00+00:00" + } + }, + "asset": { + "id": "AS-0000-0000-0002", + "status": "active", + "events": { + "created": { + "at": "2019-12-31T23:00:00+00:00" + }, + "updated": { + "at": "2019-12-31T23:00:00+00:00" + } + }, + "external_id": "EX000000ID", + "external_uid": "00000000-0000-0000-0000-000000000002", + "product": { + "id": "PRD-000-000-001", + "name": "PocketPack", + "status": "published", + "icon": "/media/VA-000-001/PRD-000-000-001/media/PRD-000-000-001-logo.png" + }, + "connection": { + "id": "CT-0000-0001", + "hub": { + "id": "HB-0000-0001", + "name": "Demo hub for vendor" + }, + "provider": { + "id": "PA-000-001", + "name": "provider" + }, + "vendor": { + "id": "VA-000-001", + "name": "vendor" + }, + "type": "test" + }, + "marketplace": { + "id": "MP-00001", + "name": "Marketplace M01 for provider", + "icon": "/media/logo_marketplace_1.png" + }, + "contract": { + "id": "CRP-00000-00000-00001", + "name": "Contract of Program Agreement PA01" + } + }, + "items": [ + { + "id": "poor_hounds_002_0001", + "global_id": "PRD-000-000-002-0001", + "mpn": "MPN-A", + "quantity": "4.0", + "type": "Gb", + "display_name": "Sku A", + "period": "yearly", + "item_type": "reservation" + } + ], + "attributes": { + "vendor": { + "CC": "AA", + "A": "BB", + "Key 3": "Value 3.1" + } + }, + "period": { + "from": "2019-12-31T23:00:00+00:00", + "to": "2020-12-31T23:00:00+00:00", + "delta": "1.0", + "uom": "year" + } +} \ No newline at end of file diff --git a/tests/Unit/ModelsTests/apiOutput/product_request.json b/tests/Unit/ModelsTests/apiOutput/product_request.json index c031291..47a5997 100644 --- a/tests/Unit/ModelsTests/apiOutput/product_request.json +++ b/tests/Unit/ModelsTests/apiOutput/product_request.json @@ -1,17 +1,18 @@ { - "id": "PRD-086-505-671", - "name": "Mega Cloud Backup", - "icon": "VA-896-811/PRD-086-505-671/media/PRD-086-505-671-logo_NyKuQfs.png", - "short_description": "Cloud Backup is the easier and more reliable way to do workstations backup in the cloud", - "detailed_description": "# Overview\n\nCloud Backup is the easier and more reliable way to do workstations backup in the cloud.\n\nService is structured in 3 license types:\n\n* Bronze License: To store up to 10 GB per seat sold\n* Gold License: To store up to 100GB per seat sold\n* Diamond License: To store up to 1TB per seat sold\n\nEach license allows to backup any device that runs:\n\n* Windows (Windows 8 or newer)\n* MacOS X (High Sierra or newer)\n* Android (4.0 or newer)\n* iOS (9 or newer)\n\nBuyers will have a nice interface where to handle their users and the registered devices.", - "published_at": "2019-03-18 08:33:51.459015+00:00", + "id": "PRD-045-171-563", + "name": "El Ten Eleven", + "icon": "", + "status": "published", + "short_description": "The service directly enables service providers to add new revenue streams. This offering is a comprehensive solution that enables service providers to expand their market share, automate, grow recurring revenue, and increase customer stickiness.", + "detailed_description": "# Overview\n\nThe service gives companies a majority of the same benefits that on-premises deployments provide. By integrating with the cloud service, companies can expand their market share, automate and grow recurring revenue, increase customer satisfaction, and cut operational costs at the same time.", + "published_at": "2020-02-19T13:41:45+00:00", "configurations": { "suspend_resume_supported": false, - "requires_reseller_information": true + "requires_reseller_information": false }, "customer_ui_settings": { - "description": "We are happy to provide you the Cloud Backup Service - an ultimate solution for your company. Stop using the legacy on-premises solution on your computer. Move to the cloud with our help.", - "getting_started": "You are now ready to use the Cloud Backup Service, the ultimate solution to Backup all your devices. Download apps for Windows Desktop, Windows Phone, Mac OS or Android following one of the links below, or access the service web interface directly.", + "description": "We are happy to provide you the Cloud Service - an ultimate solution for your company. Stop using the legacy on-premises solution on your computer. Move to the cloud with our help.", + "getting_started": "You are now ready to use the Cloud Service and migrate the files from your local computer and mobile devices to the cloud. Download apps for Windows Desktop, Windows Phone, Mac OS or Android following one of the links below, or access the service web interface directly.", "download_links": [ { "title": "Windows", @@ -39,22 +40,55 @@ "title": "Admin Manual", "url": "https://example.com/manual/admin" } - ] + ], + "languages": [], + "provisioning_message": "Please wait while your request is being fulfilled." }, - "version": 2, + "version": 3, "category": { - "id": "CAT-95793", - "name": "Communication and Collaboration" + "id": "CAT-41972", + "name": "Backup and Disaster Recovery" + }, + "owner": { + "id": "VA-774-602", + "name": "APSConnect Dev" + }, + "latest": true, + "media": { + "position": 1, + "id": "PRM-045-171-563-82858", + "type": "image", + "thumbnail": "/media/VA-774-602/PRD-045-171-563/media/media.png", + "url": "/media/VA-774-602/PRD-045-171-563/media/media.png" }, "stats": { - "contracts": { - "distribution": 1, - "sourcing": 0 + "versions": 3 + }, + "capabilities": { + "ppu": { + "schema": "QT", + "dynamic": false, + "predictive": true }, - "listings": 1, - "agreements": { - "distribution": 1, - "sourcing": 0 + "reservation": { + "consumption": true + }, + "cart": { + "validation": false + }, + "tiers": { + "configs": null, + "updates": false + }, + "hold": true, + "billing": { + "schema": "explicit" } + }, + "visibility": { + "owner": false, + "listing": false, + "syndication": false, + "catalog": true } } \ No newline at end of file diff --git a/tests/Unit/ModelsTests/apiOutput/usagefile_request.json b/tests/Unit/ModelsTests/apiOutput/usagefile_request.json index 23ed108..e8f1d34 100644 --- a/tests/Unit/ModelsTests/apiOutput/usagefile_request.json +++ b/tests/Unit/ModelsTests/apiOutput/usagefile_request.json @@ -1,76 +1,76 @@ { - "id": "UF-2018-11-9878764342", - "name": "Usage for Feb 2019", - "description": "This file contains usage for the product belonging to month Feb 2019", - "note": "My personal note", - "status": "ready", - "product": { - "id": "CN-783-317-575", - "name": "Google Apps", - "icon": "/media/VA-587-127/CN-783-317-575/media/CN-783-317-575-logo.png" + "id":"UF-2020-03-8705-3864", + "name":"8", + "status":"closed", + "vendor":{ + "id":"VA-993-502", + "name":"Vendor for ayermakov" }, - "contract": { - "id": "CRD-00000-00000-00000", - "name": "ACME Distribution Contract" + "provider":{ + "id":"PA-153-558", + "name":"Provider for ayermakov" }, - "marketplace": { - "id": "MP-198987", - "name": "France", - "icon": "/media/PA-123-123/marketplaces/MP-12345/image.png" + "environment":"production", + "marketplace":{ + "id":"MP-56616", + "name":"Germany" }, - "vendor": { - "id": "VA-587-127", - "name": "Symantec" + "product":{ + "id":"PRD-272-877-838", + "name":"Test ARTEM", + "icon":"" }, - "provider": { - "id": "PA-587-127", - "name": "ABC Corp" + "acceptance_note":"Auto Approved", + "schema":"tr", + "stats":{ + "uploaded":2, + "validated":0, + "pending":0, + "accepted":0, + "closed":2 }, - "upload_file_uri": "", - "processed_file_uri": "", - "acceptance_note": "All usage data is correct", - "rejection_note": "Rejected due to wrong usage for item 56", - "error_detail": "Error details in case of usage file is marked as invalid", - "records": { - "valid": 56, - "invalid": 0 + "usage_file_uri":"https://devconnect.blob.core.windows.net/usage-collector-dev/PRD-272-877-838/UF-2020-03-8705-3864/uploaded/UF-2020-03-8705-3864.xlsx?se=2020-03-04T15%3A42%3A12Z&sp=r&sv=2019-02-02&sr=b&sig=IGD/LlmCWiYy7LF2foY9F4%2BN72uCNJZIyt0rHJSmwz0%3D", + "processed_file_uri":"https://devconnect.blob.core.windows.net/usage-collector-dev/PRD-272-877-838/UF-2020-03-8705-3864/processed/UF-2020-03-8705-3864-PROCESSED.xlsx?se=2020-03-04T15%3A42%3A12Z&sp=r&sv=2019-02-02&sr=b&sig=J9Z7wSVAaWLHtrnZKWl6A4m3pmkmxz6q2a4/HeRsnU0%3D", + "records":{ + "valid":2, + "invalid":0, + "closed":2 }, - "events": { - "created": { - "by": { - "id": "SU-123123" - }, - "at": "2018-11-21T11:10:29+00:00" + "events":{ + "created":{ + "at":"2020-03-04T03:24:28.137141+00:00", + "by":{ + "id":"UR-552-340-461", + "name":"Artem Yermakov" + } }, - "uploaded": { - "by": { - "id": "SU-123123" - }, - "at": "2018-11-21T11:10:29+00:00" + "uploaded":{ + "at":"2020-03-04T03:40:33.272329+00:00", + "by":{ + "id":"UR-552-340-461", + "name":"Artem Yermakov" + } }, - "submitted": { - "by": { - "id": "SU-123123" - }, - "at": "2018-11-21T11:10:29+00:00" + "submitted":{ + "at":"2020-03-04T03:41:35.700804+00:00", + "by":{ + "id":"UR-552-340-461", + "name":"Artem Yermakov" + } }, - "accepted": { - "by": { - "id": "SU-123123" - }, - "at": "2018-11-21T11:10:29+00:00" + "accepted":{ + "at":"2020-03-04T03:41:39.269057+00:00" }, - "rejected": { - "by": { - "id": "SU-123123" - }, - "at": "2018-11-21T11:10:29+00:00" - }, - "closed": { - "by": { - "id": "SU-123123" - }, - "at": "2018-11-21T11:10:29+00:00" + "closed":{ + "at":"2020-03-04T07:38:17.158668+00:00", + "by":{ + "id":"somebody", + "name":"ayermakov+@odin.com" + } } + }, + "contract":{ + "id":"CRD-87450-19644-06118", + "name":"Contract of Germany Onboarding Agreement" } } \ No newline at end of file diff --git a/tests/Unit/RQL/QueryTest.php b/tests/Unit/RQL/QueryTest.php index 3a85132..8143510 100644 --- a/tests/Unit/RQL/QueryTest.php +++ b/tests/Unit/RQL/QueryTest.php @@ -2,7 +2,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2018. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; diff --git a/tests/Unit/Runtime/Providers/Http4DirectoryTierAccountsTestwithRequestServiceProvider.php b/tests/Unit/Runtime/Providers/Http4DirectoryTierAccountsTestwithRequestServiceProvider.php new file mode 100644 index 0000000..3cf30ed --- /dev/null +++ b/tests/Unit/Runtime/Providers/Http4DirectoryTierAccountsTestwithRequestServiceProvider.php @@ -0,0 +1,37 @@ +shouldReceive('getContents') + ->andReturn( + trim(file_get_contents(__DIR__ . '/tierAccountList.json')), + trim(file_get_contents(__DIR__ . '/tierAccountDetails.json')) + ); + + $response = \Mockery::mock('\Psr\Http\Message\ResponseInterface'); + $response->shouldReceive('getStatusCode') + ->andReturn(200); + + $response->shouldReceive('getBody') + ->andReturn($body); + + $client = \Mockery::mock('GuzzleHttp\ClientInterface'); + $client->shouldReceive('request') + ->withAnyArgs() + ->andReturn($response); + + return $client; + } +} diff --git a/tests/Unit/Runtime/Providers/Http4DirectorygetProductServiceProvider.php b/tests/Unit/Runtime/Providers/Http4DirectorygetProductServiceProvider.php index 5fd227d..1a7a032 100644 --- a/tests/Unit/Runtime/Providers/Http4DirectorygetProductServiceProvider.php +++ b/tests/Unit/Runtime/Providers/Http4DirectorygetProductServiceProvider.php @@ -2,7 +2,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2018. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit\Runtime\Providers; @@ -19,7 +19,12 @@ public function register(Container $container) ->andReturn( trim(file_get_contents(__DIR__ . '/productGetRequest.json')), trim(file_get_contents(__DIR__.'/producttemplates.json')), - trim(file_get_contents(__DIR__. '/productConfigurations.json')) + trim(file_get_contents(__DIR__. '/productConfigurations.json')), + trim(file_get_contents(__DIR__. '/productMedia.json')), + trim(file_get_contents(__DIR__.'/productItems.json')), + trim(file_get_contents(__DIR__.'/productAgreements.json')), + trim(file_get_contents(__DIR__.'/productActions.json')), + trim(file_get_contents(__DIR__.'/productActionLink.json')) ); $response = \Mockery::mock('\Psr\Http\Message\ResponseInterface'); diff --git a/tests/Unit/Runtime/Providers/Http4DirectorygetTierConfigServiceProvider.php b/tests/Unit/Runtime/Providers/Http4DirectorygetTierConfigServiceProvider.php index 6b0bf3e..1a8d18c 100644 --- a/tests/Unit/Runtime/Providers/Http4DirectorygetTierConfigServiceProvider.php +++ b/tests/Unit/Runtime/Providers/Http4DirectorygetTierConfigServiceProvider.php @@ -2,7 +2,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2018. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit\Runtime\Providers; diff --git a/tests/Unit/Runtime/Providers/Http4SubscriptionsServiceOperationsProvider.php b/tests/Unit/Runtime/Providers/Http4SubscriptionsServiceOperationsProvider.php new file mode 100644 index 0000000..0652625 --- /dev/null +++ b/tests/Unit/Runtime/Providers/Http4SubscriptionsServiceOperationsProvider.php @@ -0,0 +1,43 @@ +shouldReceive('getContents') + ->andReturn( + trim("[".file_get_contents(__DIR__ . '/subscriptionRequest.json')."]"), + trim("[".file_get_contents(__DIR__ . '/subscriptionRequest.json')."]"), + trim("[".file_get_contents(__DIR__ . '/subscriptionRequest.json')."]"), + trim("[".file_get_contents(__DIR__ . '/subscriptionAsset.json')."]"), + trim("[".file_get_contents(__DIR__ . '/subscriptionAsset.json')."]"), + trim("[".file_get_contents(__DIR__ . '/subscriptionAsset.json')."]"), + trim(file_get_contents(__DIR__ . '/subscriptionAsset.json')) + ); + + $response = \Mockery::mock('\Psr\Http\Message\ResponseInterface'); + $response->shouldReceive('getStatusCode') + ->andReturn(200); + + $response->shouldReceive('getBody') + ->andReturn($body); + + $client = \Mockery::mock('GuzzleHttp\ClientInterface'); + $client->shouldReceive('request') + ->withAnyArgs() + ->andReturn($response); + + return $client; + } +} diff --git a/tests/Unit/Runtime/Providers/Http4SubscriptionsServiceProvider.php b/tests/Unit/Runtime/Providers/Http4SubscriptionsServiceProvider.php new file mode 100644 index 0000000..27c8b90 --- /dev/null +++ b/tests/Unit/Runtime/Providers/Http4SubscriptionsServiceProvider.php @@ -0,0 +1,43 @@ +shouldReceive('getContents') + ->andReturn( + trim(file_get_contents(__DIR__ . '/subscriptionRequest.json')), + trim('{"something": "value"}'), + trim('{"something": "value"}') + ); + + $response = \Mockery::mock('\Psr\Http\Message\ResponseInterface'); + $response->shouldReceive('getStatusCode') + ->andReturn(200); + + $response->shouldReceive('getBody') + ->andReturn($body); + + $client = \Mockery::mock('GuzzleHttp\ClientInterface'); + $client->shouldReceive('request') + ->withAnyArgs() + ->andReturn($response); + + return $client; + } +} diff --git a/tests/Unit/Runtime/Providers/HttpServiceProviderTAR.php b/tests/Unit/Runtime/Providers/HttpServiceProviderTAR.php new file mode 100644 index 0000000..d063c7a --- /dev/null +++ b/tests/Unit/Runtime/Providers/HttpServiceProviderTAR.php @@ -0,0 +1,41 @@ +shouldReceive('getContents') + ->andReturn( + trim(file_get_contents(__DIR__ . '/ProvidersTARLIST.json')) + ); + $response = \Mockery::mock('\Psr\Http\Message\ResponseInterface'); + $response->shouldReceive('getStatusCode') + ->andReturn(200); + + $response->shouldReceive('getBody') + ->andReturn($body); + + $client = \Mockery::mock('GuzzleHttp\ClientInterface'); + $client->shouldReceive('request') + ->withAnyArgs() + ->andReturn($response); + + return $client; + } +} diff --git a/tests/Unit/Runtime/Providers/HttpServiceProviderTARCreation.php b/tests/Unit/Runtime/Providers/HttpServiceProviderTARCreation.php new file mode 100644 index 0000000..752ac67 --- /dev/null +++ b/tests/Unit/Runtime/Providers/HttpServiceProviderTARCreation.php @@ -0,0 +1,37 @@ +shouldReceive('getContents') + ->andReturn( + trim(file_get_contents(__DIR__ . '/ProvidersTARLIST.json')) + ); + $response = \Mockery::mock('\Psr\Http\Message\ResponseInterface'); + $response->shouldReceive('getStatusCode') + ->andReturn(200); + + $response->shouldReceive('getBody') + ->andReturn($body); + + $client = \Mockery::mock('GuzzleHttp\ClientInterface'); + $client->shouldReceive('request') + ->withAnyArgs() + ->andReturn($response); + + return $client; + } +} diff --git a/tests/Unit/Runtime/Providers/ProvidersTARLIST.json b/tests/Unit/Runtime/Providers/ProvidersTARLIST.json new file mode 100644 index 0000000..adfa405 --- /dev/null +++ b/tests/Unit/Runtime/Providers/ProvidersTARLIST.json @@ -0,0 +1,387 @@ +[ + { + "id": "TAR-2709-2353-6222-008-001", + "type": "update", + "status": "pending", + "account": { + "id": "TA-2709-2353-6222", + "environment": "production", + "name": "string4", + "external_uid": "482dfa1a-1287-4b4b-a8cd-93c0b4c4ad8f", + "events": { + "created": { + "at": "2020-03-02T13:18:57+00:00", + "by": { + "id": "SU-905-226-238", + "name": "PRS_bot" + } + }, + "updated": { + "at": "2020-03-02T13:18:57+00:00" + } + }, + "scopes": [ + "customer" + ], + "marketplace": { + "id": "MP-00000", + "name": "ACME Marketplace" + }, + "hub": { + "id": "HB-3452-8063", + "name": "Main hub" + }, + "contact_info": { + "address_line1": "120354 Main street", + "address_line2": "", + "city": "Springfield", + "state": "string", + "postal_code": "10500", + "country": "tr", + "contact": { + "first_name": "Xander", + "last_name": "Cage", + "email": "xandercage@xxx.net", + "phone_number": { + "country_code": "+252", + "area_code": "1", + "phone_number": "017136", + "extension": "" + } + } + }, + "version": 9 + }, + "vendor": { + "id": "VA-394-324", + "name": "APSConnect Dev" + }, + "provider": { + "id": "PA-478-398", + "name": "Operative systematic function" + }, + "product": { + "id": "PRD-245-341-069", + "icon": "/media/VA-394-324/PRD-245-341-069/media/PRD-245-341-069-logo_UujodCh.png", + "name": "Blast-stream", + "status": "published" + }, + "reason": null, + "events": { + "created": { + "at": "2020-03-02T22:19:03+00:00" + }, + "updated": { + "at": "2020-03-02T22:19:03+00:00" + } + } + }, + { + "id": "TAR-2709-2353-6222-008-002", + "type": "update", + "status": "pending", + "account": { + "id": "TA-2709-2353-6222", + "environment": "production", + "name": "string4", + "external_uid": "482dfa1a-1287-4b4b-a8cd-93c0b4c4ad8f", + "events": { + "created": { + "at": "2020-03-02T13:18:57+00:00", + "by": { + "id": "SU-905-226-238", + "name": "PRS_bot" + } + }, + "updated": { + "at": "2020-03-02T13:18:57+00:00" + } + }, + "scopes": [ + "customer" + ], + "marketplace": { + "id": "MP-00000", + "name": "ACME Marketplace" + }, + "hub": { + "id": "HB-3452-8063", + "name": "Main hub" + }, + "contact_info": { + "address_line1": "120354 Main street", + "address_line2": "", + "city": "Springfield", + "state": "string", + "postal_code": "10500", + "country": "tr", + "contact": { + "first_name": "Xander", + "last_name": "Cage", + "email": "xandercage@xxx.net", + "phone_number": { + "country_code": "+252", + "area_code": "1", + "phone_number": "017136", + "extension": "" + } + } + }, + "version": 9 + }, + "vendor": { + "id": "VA-394-324", + "name": "APSConnect Dev" + }, + "provider": { + "id": "PA-478-398", + "name": "Operative systematic function" + }, + "product": { + "id": "PRD-254-370-432", + "icon": "/media/VA-394-324/PRD-254-370-432/media/PRD-254-370-432-logo.png", + "name": "Suicidal Races", + "status": "published" + }, + "reason": null, + "events": { + "created": { + "at": "2020-03-02T22:19:03+00:00" + }, + "updated": { + "at": "2020-03-02T22:19:03+00:00" + } + } + }, + { + "id": "TAR-2709-2353-6222-008-003", + "type": "update", + "status": "pending", + "account": { + "id": "TA-2709-2353-6222", + "environment": "production", + "name": "string4", + "external_uid": "482dfa1a-1287-4b4b-a8cd-93c0b4c4ad8f", + "events": { + "created": { + "at": "2020-03-02T13:18:57+00:00", + "by": { + "id": "SU-905-226-238", + "name": "PRS_bot" + } + }, + "updated": { + "at": "2020-03-02T13:18:57+00:00" + } + }, + "scopes": [ + "customer" + ], + "marketplace": { + "id": "MP-00000", + "name": "ACME Marketplace" + }, + "hub": { + "id": "HB-3452-8063", + "name": "Main hub" + }, + "contact_info": { + "address_line1": "120354 Main street", + "address_line2": "", + "city": "Springfield", + "state": "string", + "postal_code": "10500", + "country": "tr", + "contact": { + "first_name": "Xander", + "last_name": "Cage", + "email": "xandercage@xxx.net", + "phone_number": { + "country_code": "+252", + "area_code": "1", + "phone_number": "017136", + "extension": "" + } + } + }, + "version": 9 + }, + "vendor": { + "id": "VA-394-324", + "name": "APSConnect Dev" + }, + "provider": { + "id": "PA-478-398", + "name": "Operative systematic function" + }, + "product": { + "id": "SKiPED DUE CONFIG", + "icon": "/media/VA-394-324/PRD-254-370-432/media/PRD-254-370-432-logo.png", + "name": "Suicidal Races", + "status": "published" + }, + "reason": null, + "events": { + "created": { + "at": "2020-03-02T22:19:03+00:00" + }, + "updated": { + "at": "2020-03-02T22:19:03+00:00" + } + } + }, + { + "id": "TAR-2709-2353-6222-008-004", + "type": "update", + "status": "pending", + "account": { + "id": "TA-2709-2353-6222", + "environment": "production", + "name": "string4", + "external_uid": "482dfa1a-1287-4b4b-a8cd-93c0b4c4ad8f", + "events": { + "created": { + "at": "2020-03-02T13:18:57+00:00", + "by": { + "id": "SU-905-226-238", + "name": "PRS_bot" + } + }, + "updated": { + "at": "2020-03-02T13:18:57+00:00" + } + }, + "scopes": [ + "customer" + ], + "marketplace": { + "id": "MP-00000", + "name": "ACME Marketplace" + }, + "hub": { + "id": "HB-3452-8063", + "name": "Main hub" + }, + "contact_info": { + "address_line1": "120354 Main street", + "address_line2": "", + "city": "Springfield", + "state": "string", + "postal_code": "10500", + "country": "tr", + "contact": { + "first_name": "Xander", + "last_name": "Cage", + "email": "xandercage@xxx.net", + "phone_number": { + "country_code": "+252", + "area_code": "1", + "phone_number": "017136", + "extension": "" + } + } + }, + "version": 9 + }, + "vendor": { + "id": "VA-394-324", + "name": "APSConnect Dev" + }, + "provider": { + "id": "PA-478-398", + "name": "Operative systematic function" + }, + "product": { + "id": "PRD-245-341-069", + "icon": "/media/VA-394-324/PRD-245-341-069/media/PRD-245-341-069-logo_UujodCh.png", + "name": "Blast-stream", + "status": "published" + }, + "reason": null, + "events": { + "created": { + "at": "2020-03-02T22:19:03+00:00" + }, + "updated": { + "at": "2020-03-02T22:19:03+00:00" + } + } + }, + { + "id": "TAR-2709-2353-6222-008-005", + "type": "update", + "status": "pending", + "account": { + "id": "TA-2709-2353-6222", + "environment": "production", + "name": "string4", + "external_uid": "482dfa1a-1287-4b4b-a8cd-93c0b4c4ad8f", + "events": { + "created": { + "at": "2020-03-02T13:18:57+00:00", + "by": { + "id": "SU-905-226-238", + "name": "PRS_bot" + } + }, + "updated": { + "at": "2020-03-02T13:18:57+00:00" + } + }, + "scopes": [ + "customer" + ], + "marketplace": { + "id": "MP-00000", + "name": "ACME Marketplace" + }, + "hub": { + "id": "HB-3452-8063", + "name": "Main hub" + }, + "contact_info": { + "address_line1": "120354 Main street", + "address_line2": "", + "city": "Springfield", + "state": "string", + "postal_code": "10500", + "country": "tr", + "contact": { + "first_name": "Xander", + "last_name": "Cage", + "email": "xandercage@xxx.net", + "phone_number": { + "country_code": "+252", + "area_code": "1", + "phone_number": "017136", + "extension": "" + } + } + }, + "version": 9 + }, + "vendor": { + "id": "VA-394-324", + "name": "APSConnect Dev" + }, + "provider": { + "id": "PA-478-398", + "name": "Operative systematic function" + }, + "product": { + "id": "PRD-245-341-069", + "icon": "/media/VA-394-324/PRD-245-341-069/media/PRD-245-341-069-logo_UujodCh.png", + "name": "Blast-stream", + "status": "published" + }, + "reason": null, + "events": { + "created": { + "at": "2020-03-02T22:19:03+00:00" + }, + "updated": { + "at": "2020-03-02T22:19:03+00:00" + } + } + } +] \ No newline at end of file diff --git a/tests/Unit/Runtime/Providers/productActionLink.json b/tests/Unit/Runtime/Providers/productActionLink.json new file mode 100644 index 0000000..a5544d2 --- /dev/null +++ b/tests/Unit/Runtime/Providers/productActionLink.json @@ -0,0 +1,3 @@ +{ + "link": "https://stub-dot-mydevball.appspot.com/" +} \ No newline at end of file diff --git a/tests/Unit/Runtime/Providers/productActions.json b/tests/Unit/Runtime/Providers/productActions.json new file mode 100644 index 0000000..cf8a331 --- /dev/null +++ b/tests/Unit/Runtime/Providers/productActions.json @@ -0,0 +1,9 @@ +[ + { + "id": "sso_action", + "title": "Sign In", + "type": "button", + "scope": "asset", + "description": "Sign in into the service by clicking at this button" + } +] \ No newline at end of file diff --git a/tests/Unit/Runtime/Providers/productAgreements.json b/tests/Unit/Runtime/Providers/productAgreements.json new file mode 100644 index 0000000..5f495b8 --- /dev/null +++ b/tests/Unit/Runtime/Providers/productAgreements.json @@ -0,0 +1,39 @@ +[ + { + "id": "AGR-107-526-821", + "type": "product-sourcing", + "title": "El Ten Eleven", + "description": "El Ten Eleven", + "created": "2020-02-18T11:56:50+00:00", + "updated": "2020-02-18T11:56:50+00:00", + "owner": { + "id": "PA-239-263", + "name": "Devolved stable hardware" + }, + "author": { + "id": "UR-398-820-096", + "name": "Shagit" + }, + "version": 1, + "active": true, + "link": "https://example.com", + "version_created": "2020-02-18T11:56:50+00:00", + "parent": { + "id": "AGU-233-635-216", + "name": "El Ten Eleven" + }, + "listing": { + "id": "LST-107-526-821" + }, + "product": { + "id": "PRD-045-171-563", + "icon": "", + "name": "El Ten Eleven", + "status": "published" + }, + "marketplace": { + "id": "MP-17540", + "name": "El Ten Eleven" + } + } +] \ No newline at end of file diff --git a/tests/Unit/Runtime/Providers/productItems.json b/tests/Unit/Runtime/Providers/productItems.json new file mode 100644 index 0000000..5290fb9 --- /dev/null +++ b/tests/Unit/Runtime/Providers/productItems.json @@ -0,0 +1,66 @@ +[ + { + "id": "PRD-045-171-563-0001", + "name": "Sku A", + "status": "published", + "unit": { + "id": "gb", + "title": "Gb", + "unit": "unit" + }, + "mpn": "MPN-A", + "ui": { + "visibility": true + }, + "ui_visibility": true, + "position": 10000, + "type": "reservation", + "local_id": "SKU_A", + "display_name": "Sku A", + "period": "monthly", + "precision": "integer", + "description": "MPN-A", + "depth": 0, + "events": { + "created": { + "at": "2020-02-19T13:41:45+00:00" + }, + "updated": { + "at": "2020-02-19T13:41:45+00:00" + } + }, + "dynamic": false + }, + { + "id": "PRD-045-171-563-0002", + "name": "Sku B", + "status": "published", + "unit": { + "id": "devices", + "title": "Devices", + "unit": "unit" + }, + "mpn": "MPN-B", + "ui": { + "visibility": true + }, + "ui_visibility": true, + "position": 20000, + "type": "reservation", + "local_id": "SKU_B", + "display_name": "Sku B", + "period": "monthly", + "precision": "integer", + "description": "MPN-B", + "depth": 0, + "events": { + "created": { + "at": "2020-02-19T13:41:45+00:00" + }, + "updated": { + "at": "2020-02-19T13:41:45+00:00" + } + }, + "dynamic": false + } +] \ No newline at end of file diff --git a/tests/Unit/Runtime/Providers/productMedia.json b/tests/Unit/Runtime/Providers/productMedia.json new file mode 100644 index 0000000..fb5caf0 --- /dev/null +++ b/tests/Unit/Runtime/Providers/productMedia.json @@ -0,0 +1,16 @@ +[ + { + "position": 1, + "id": "PRM-045-171-563-82858", + "type": "image", + "thumbnail": "/media/VA-774-602/PRD-045-171-563/media/media.png", + "url": "/media/VA-774-602/PRD-045-171-563/media/media.png" + }, + { + "position": 2, + "id": "PRM-045-171-563-68891", + "type": "image", + "thumbnail": "/media/VA-774-602/PRD-045-171-563/media/media_6uZOmR2.png", + "url": "/media/VA-774-602/PRD-045-171-563/media/media_6uZOmR2.png" + } +] \ No newline at end of file diff --git a/tests/Unit/Runtime/Providers/subscriptionAsset.json b/tests/Unit/Runtime/Providers/subscriptionAsset.json new file mode 100644 index 0000000..3adddef --- /dev/null +++ b/tests/Unit/Runtime/Providers/subscriptionAsset.json @@ -0,0 +1,181 @@ +{ + "id": "AS-1611-4204-8054", + "status": "active", + "events": { + "created": { + "at": "2020-03-02T14:02:23+00:00" + }, + "updated": { + "at": "2020-03-02T14:03:38+00:00" + } + }, + "external_id": "QI1MKRTHNB", + "external_uid": "6ea4b798-fcda-4936-99d1-b9156d95bdbd", + "product": { + "id": "PRD-012-832-886", + "name": "Wordpress", + "status": "published", + "icon": "" + }, + "connection": { + "id": "CT-0000-0000-0000", + "hub": { + "id": "HB-0000-0000", + "name": "ACME Hub" + }, + "provider": { + "id": "PA-931-712", + "name": "Provider company for osrivastava" + }, + "vendor": { + "id": "VA-394-324", + "name": "APSConnect Dev" + }, + "type": "" + }, + "items": [ + { + "id": "SKU_A", + "display_name": "Sku A", + "global_id": "PRD-012-832-886-0001", + "item_type": "reservation", + "mpn": "MPN-A", + "period": "monthly", + "quantity": "72.0", + "billing": { + "stats": { + "vendor": { + "last_request": { + "id": "BRV-3639-3001-0669", + "type": "vendor", + "period": { + "from": "2020-03-02T13:30:18.295214+00:00", + "to": "2020-04-02T13:30:18.295214+00:00", + "delta": "1.0", + "uom": "monthly" + } + }, + "count": 3 + } + } + } + }, + { + "id": "SKU_B", + "display_name": "Sku B", + "global_id": "PRD-012-832-886-0002", + "item_type": "reservation", + "mpn": "MPN-B", + "period": "monthly", + "quantity": "47.0", + "billing": { + "stats": { + "vendor": { + "last_request": { + "id": "BRV-3639-3001-0669", + "type": "vendor", + "period": { + "from": "2020-03-02T13:30:18.295214+00:00", + "to": "2020-04-02T13:30:18.295214+00:00", + "delta": "1.0", + "uom": "monthly" + } + }, + "count": 3 + } + } + } + }, + { + "id": "PRD_012_832_886_0003", + "display_name": "ppu item", + "global_id": "PRD-012-832-886-0003", + "item_type": "ppu", + "mpn": "dascadsvadsv21313", + "period": "monthly", + "quantity": "-1.0" + } + ], + "params": [ + { + "id": "param_b", + "name": "Title of the Parameter B", + "description": "Description of the Parameter B", + "type": "text", + "value": "fsdfsd" + } + ], + "tiers": { + "customer": { + "id": "TA-9991-6127-7322", + "external_id": "25649", + "external_uid": "465ccb6b-f930-433c-a8ea-a9bd01a1279a", + "name": "Wisozk and Sons", + "contact_info": { + "address_line1": "Jordy Plain", + "address_line2": "Prosacco Coves", + "city": "Anxi County", + "state": "Fujian", + "postal_code": "362400", + "country": "CN", + "contact": { + "first_name": "Joany", + "last_name": "Hermiston", + "email": "akataev+Joany_Hermiston@odin.com", + "phone_number": { + "country_code": "86", + "area_code": "155", + "phone_number": "55319659" + } + } + } + } + }, + "marketplace": { + "id": "MP-67458", + "name": "China Marketplace", + "icon": "/media/PA-931-712/marketplaces/MP-67458/icon.png" + }, + "contract": { + "id": "CRD-00000-00000-00000", + "name": "ACME Distribution Contract" + }, + "billing": { + "period": { + "delta": "1.0", + "uom": "monthly" + }, + "next_date": "2020-04-02T13:46:58.636199+00:00", + "anniversary": { + "day": 2 + }, + "stats": { + "vendor": { + "last_request": { + "id": "BRV-9900-0013-9967", + "type": "vendor", + "period": { + "from": "2020-03-02T13:46:58.636199+00:00", + "to": "2020-04-02T13:46:58.636199+00:00", + "delta": "1.0", + "uom": "monthly" + } + }, + "count": 1 + }, + "provider": { + "last_request": { + "id": "BRV-9900-0013-9968", + "type": "provider", + "period": { + "from": "2020-03-02T13:46:58.636199+00:00", + "to": "2020-04-02T13:46:58.636199+00:00", + "delta": "1.0", + "uom": "monthly" + } + }, + "count": 1 + } + } + } +} \ No newline at end of file diff --git a/tests/Unit/Runtime/Providers/subscriptionRequest.json b/tests/Unit/Runtime/Providers/subscriptionRequest.json new file mode 100644 index 0000000..4ae0d5c --- /dev/null +++ b/tests/Unit/Runtime/Providers/subscriptionRequest.json @@ -0,0 +1,83 @@ +{ + "id":"BRV-0000-0000-0002", + "type":"vendor", + "events":{ + "created":{ + "at":"2021-01-01T00:00:00+00:00" + }, + "updated":{ + "at":"2021-01-01T00:00:00+00:00" + } + }, + "asset":{ + "id":"AS-0000-0000-0002", + "status":"active", + "events":{ + "created":{ + "at":"2019-12-31T23:00:00+00:00" + }, + "updated":{ + "at":"2019-12-31T23:00:00+00:00" + } + }, + "external_id":"EX000000ID", + "external_uid":"00000000-0000-0000-0000-000000000002", + "product":{ + "id":"PRD-000-000-001", + "name":"PocketPack", + "status":"published", + "icon":"/media/VA-000-001/PRD-000-000-001/media/PRD-000-000-001-logo.png" + }, + "connection":{ + "id":"CT-0000-0001", + "hub":{ + "id":"HB-0000-0001", + "name":"Demo hub for vendor" + }, + "provider":{ + "id":"PA-000-001", + "name":"provider" + }, + "vendor":{ + "id":"VA-000-001", + "name":"vendor" + }, + "type":"test" + }, + "marketplace":{ + "id":"MP-00001", + "name":"Marketplace M01 for provider", + "icon":"/media/logo_marketplace_1.png" + }, + "contract":{ + "id":"CRP-00000-00000-00001", + "name":"Contract of Program Agreement PA01" + } + }, + "items":[ + { + "id":"poor_hounds_002_0001", + "global_id":"PRD-000-000-002-0001", + "mpn":"MPN-A", + "quantity":"4.0", + "type":"Gb", + "display_name":"Sku A", + "period":"yearly", + "item_type":"reservation" + } + ], + "attributes":{ + "vendor":{ + "test":"marc", + "CC":"AA", + "A":"BB", + "Key 3":"Value 3.1" + } + }, + "period":{ + "from":"2019-12-31T23:00:00+00:00", + "to":"2020-12-31T23:00:00+00:00", + "delta":"1.0", + "uom":"year" + } +} \ No newline at end of file diff --git a/tests/Unit/Runtime/Providers/tierAccountDetails.json b/tests/Unit/Runtime/Providers/tierAccountDetails.json new file mode 100644 index 0000000..1cade81 --- /dev/null +++ b/tests/Unit/Runtime/Providers/tierAccountDetails.json @@ -0,0 +1,55 @@ +{ + "id": "TA-3633-0299-5209", + "environment": "preview", + "name": "Wisoky, Mueller and Will", + "external_id": "96409", + "external_uid": "12b744bb-1b60-4753-87e3-f5cf1252a893", + "events": { + "created": { + "at": "2020-03-02T07:59:13+00:00", + "by": { + "id": "UR-904-621-770", + "name": "Alexandra" + } + }, + "updated": { + "at": "2020-03-02T07:59:13+00:00", + "by": { + "id": "UR-413-015-088", + "name": "Aleksandr" + } + } + }, + "scopes": [ + "customer", + "tier1" + ], + "marketplace": { + "id": "MP-28655", + "name": "Marketplace M01 for nrudra", + "icon": "/media/logo_marketplace_1.png" + }, + "hub": { + "id": "HB-0000-0000", + "name": "ACME Hub" + }, + "contact_info": { + "address_line1": "Quigley Pine", + "address_line2": "Ledner Station", + "city": "Karlshamn", + "state": "Blekinge Län ", + "postal_code": "374 02", + "country": "AS", + "contact": { + "first_name": "Payton", + "last_name": "Haag", + "email": "atroitskaya+Payton_Haag@odin.com", + "phone_number": { + "country_code": "+46", + "area_code": "755", + "phone_number": "5526", + "extension": "" + } + } + } +} \ No newline at end of file diff --git a/tests/Unit/Runtime/Providers/tierAccountList.json b/tests/Unit/Runtime/Providers/tierAccountList.json new file mode 100644 index 0000000..4c9aced --- /dev/null +++ b/tests/Unit/Runtime/Providers/tierAccountList.json @@ -0,0 +1,38 @@ +[ + { + "id": "TA-3633-0299-5209", + "environment": "preview", + "name": "Wisoky, Mueller and Will", + "external_id": "96409", + "external_uid": "12b744bb-1b60-4753-87e3-f5cf1252a893", + "events": { + "created": { + "at": "2020-03-02T07:59:13+00:00", + "by": { + "id": "UR-904-621-770", + "name": "Alexandra" + } + }, + "updated": { + "at": "2020-03-02T07:59:13+00:00", + "by": { + "id": "UR-413-015-088", + "name": "Aleksandr" + } + } + }, + "scopes": [ + "customer", + "tier1" + ], + "marketplace": { + "id": "MP-28655", + "name": "Marketplace M01 for nrudra", + "icon": "/media/logo_marketplace_1.png" + }, + "hub": { + "id": "HB-0000-0000", + "name": "ACME Hub" + } + } +] \ No newline at end of file diff --git a/tests/Unit/SubscriptionTests/SubscriptionRequestTest.php b/tests/Unit/SubscriptionTests/SubscriptionRequestTest.php new file mode 100644 index 0000000..af5c8d8 --- /dev/null +++ b/tests/Unit/SubscriptionTests/SubscriptionRequestTest.php @@ -0,0 +1,59 @@ +subscriptions->getSubscriptionRequestById('BRV-0000-0000-0002'); + $this->assertInstanceOf('Connect\Subscription\SubscriptionRequest', $request); + $model = new Model([ + "something" => "value" + ]); + $request->setVendorAttributes($model); + $this->assertEquals($request->attributes->vendor->something, "value"); + $request->setProviderAttributes($model); + $this->assertEquals($request->attributes->provider->something, "value"); + } + + public function testOperationsSubscriptions() + { + $connectClient = new ConnectClient(new Config(__DIR__. '/config.mocked.testOperations.json')); + $requests = $connectClient->subscriptions->listSubscriptionRequests(); + foreach ($requests as $request) { + $this->assertInstanceOf('Connect\Subscription\SubscriptionRequest', $request); + } + $requests = $connectClient->subscriptions->listSubscriptionRequests(new Query(['id' => 'BRV-0000-0000-0002'])); + foreach ($requests as $request) { + $this->assertInstanceOf('Connect\Subscription\SubscriptionRequest', $request); + $this->assertEquals('BRV-0000-0000-0002', $request->id); + } + $requests = $connectClient->subscriptions->listSubscriptionRequests(['id' => 'BRV-0000-0000-0002']); + $this->assertInstanceOf('Connect\Subscription\SubscriptionRequest', $requests[0]); + $assetList = $connectClient->subscriptions->listSubscriptionAssets(); + foreach ($assetList as $asset) { + $this->assertInstanceOf('Connect\Subscription\SubscriptionAsset', $asset); + } + $assetList = $connectClient->subscriptions->listSubscriptionAssets(new Query(["id" => "AS-1611-4204-8054"])); + foreach ($assetList as $asset) { + $this->assertInstanceOf('Connect\Subscription\SubscriptionAsset', $asset); + } + $assetList = $connectClient->subscriptions->listSubscriptionAssets(["id" => "AS-1611-4204-8054"]); + $this->assertInstanceOf('Connect\Subscription\SubscriptionAsset', $assetList[0]); + $asset = $connectClient->subscriptions->getSubscriptionAssetById("AS-1611-4204-8054"); + $this->assertInstanceOf('Connect\Subscription\SubscriptionAsset', $asset); + $this->assertEquals("AS-1611-4204-8054", $asset->id); + } +} diff --git a/tests/Unit/SubscriptionTests/config.mocked.testOperations.json b/tests/Unit/SubscriptionTests/config.mocked.testOperations.json new file mode 100644 index 0000000..5872157 --- /dev/null +++ b/tests/Unit/SubscriptionTests/config.mocked.testOperations.json @@ -0,0 +1,15 @@ +{ + "apiKey": "ApiKey SU-766-419-989:56fda6081cd5200f089d28f7f9a6d390bf7ffcec", + "apiEndpoint": "https://api.connect.cloud.im/public/v1", + "logLevel": 4, + "timeout": 10, + "sslVerifyHost": false, + "products": [ + "PRD-863-384-534" + ], + "runtimeServices": { + "logger": "Test\\Unit\\Runtime\\Providers\\LoggerServiceProvider", + "http": "Test\\Unit\\Runtime\\Providers\\Http4SubscriptionsServiceOperationsProvider", + "std": "Test\\Unit\\Runtime\\Providers\\StdClassServiceProvider" + } +} \ No newline at end of file diff --git a/tests/Unit/SubscriptionTests/config.mocked.testSetAttributes.json b/tests/Unit/SubscriptionTests/config.mocked.testSetAttributes.json new file mode 100644 index 0000000..15df425 --- /dev/null +++ b/tests/Unit/SubscriptionTests/config.mocked.testSetAttributes.json @@ -0,0 +1,15 @@ +{ + "apiKey": "ApiKey SU-766-419-989:56fda6081cd5200f089d28f7f9a6d390bf7ffcec", + "apiEndpoint": "https://api.connect.cloud.im/public/v1", + "logLevel": 4, + "timeout": 10, + "sslVerifyHost": false, + "products": [ + "PRD-863-384-534" + ], + "runtimeServices": { + "logger": "Test\\Unit\\Runtime\\Providers\\LoggerServiceProvider", + "http": "Test\\Unit\\Runtime\\Providers\\Http4SubscriptionsServiceProvider", + "std": "Test\\Unit\\Runtime\\Providers\\StdClassServiceProvider" + } +} \ No newline at end of file diff --git a/tests/Unit/TierAccountRequests/ResponsesTest.php b/tests/Unit/TierAccountRequests/ResponsesTest.php new file mode 100644 index 0000000..ae1353c --- /dev/null +++ b/tests/Unit/TierAccountRequests/ResponsesTest.php @@ -0,0 +1,49 @@ +assertInstanceOf('\Connect\TierAccountRequestAccept', $accept); + + $this->assertEquals("TAR Processed", $accept->getMessage()); + $this->assertEquals('accepted', $accept->getCode()); + $this->assertEquals(null, $accept->getObject()); + return $accept; + } + + /** + * @return mixed + */ + public function testInstantiationIgnore() + { + $ignore = new TierAccountRequestIgnore(); + + $this->assertInstanceOf('\Connect\TierAccountRequestIgnore', $ignore); + + $this->assertEquals("This product can not process account change requests", $ignore->getMessage()); + $this->assertEquals('ignore', $ignore->getCode()); + $this->assertEquals(null, $ignore->getObject()); + return $ignore; + } +} diff --git a/tests/Unit/TierAccountRequests/TierAccountRequestsBasicsHelper.php b/tests/Unit/TierAccountRequests/TierAccountRequestsBasicsHelper.php new file mode 100644 index 0000000..a85e115 --- /dev/null +++ b/tests/Unit/TierAccountRequests/TierAccountRequestsBasicsHelper.php @@ -0,0 +1,62 @@ +id) { + case 'TAR-2709-2353-6222-008-001': + $request->account->diffWithPreviousVersion(); + throw new TierAccountRequestAccept("YES"); + case 'TAR-2709-2353-6222-008-002': + $request->account->diffWithPreviousVersion($request->account->version -1); + throw new TierAccountRequestIgnore("NO WAY"); + case 'TAR-2709-2353-6222-008-004': + return "This will not work and will be skiped"; + case 'TAR-2709-2353-6222-008-005': + $object = new \stdClass(); + $object->message = "this will not work and will be skipped"; + return $object; + } + } + + public function getConfig() + { + return $this->config; + } + + public function getLogger() + { + return $this->logger; + } + + public function getHttp() + { + return $this->http; + } + + public function getStd() + { + return $this->std; + } +} diff --git a/tests/Unit/TierAccountRequests/TierAccountRequestsBasicsTest.php b/tests/Unit/TierAccountRequests/TierAccountRequestsBasicsTest.php new file mode 100644 index 0000000..fe826dd --- /dev/null +++ b/tests/Unit/TierAccountRequests/TierAccountRequestsBasicsTest.php @@ -0,0 +1,101 @@ +assertInstanceOf('\Connect\TierAccountRequestsAutomation', $app); + $app->process(); + } + + public function testListTARsWithFiltersArray() + { + $client = new \Connect\ConnectClient(new Config('./config.mocked.json')); + $requests = $client->directory->listTierAccountRequests(['status' => 'pending']); + foreach ($requests as $request) { + $this->assertInstanceOf('\Connect\TierAccountRequest', $request); + } + } + + public function testListTARsWithFiltersRQL() + { + $client = new \Connect\ConnectClient(new Config('./config.mocked.json')); + $requests = $client->directory->listTierAccountRequests(new Query(['status' => 'pending'])); + foreach ($requests as $request) { + $this->assertInstanceOf('\Connect\TierAccountRequest', $request); + } + } + + public function testListTARsWithoutFilters() + { + $client = new \Connect\ConnectClient(new Config('./config.mocked.json')); + $requests = $client->directory->listTierAccountRequests(); + foreach ($requests as $request) { + $this->assertInstanceOf('\Connect\TierAccountRequest', $request); + } + } + + public function testCreateTierAccountRequestChange() + { + $client = new \Connect\ConnectClient(new Config('./config.creation.mocked.json')); + $tar = new TierAccountRequest([ + "type" => "update", + "account" => [ + "id" => "TA-2709-2353-6222", + "external_uid" => "2f706f59-d0fe-493f-be4c-63059ea81bd2", + "name" => "string4", + "contact_info" => [ + "address_line1" => "120354 Main street", + "address_line2" => "", + "city" => "Springfield", + "state" => "string", + "postal_code" => "10500", + "country" => "tr", + "contact" => [ + "email" => "xandercage@xxx.net", + "first_name" => "Xander", + "last_name" => "Cage", + "phone_number" => [ + "area_code" => "1", + "country_code" => "+252", + "extension" => "", + "phone_number" => "017136" + ] + ] + ] + ] + ]); + $responses = $client->directory->createTierAccountRequest($tar); + foreach ($responses as $response) { + $this->assertInstanceOf('\Connect\TierAccountRequest', $response); + } + } +} diff --git a/tests/Unit/TierAccountRequests/config.creation.mocked.json b/tests/Unit/TierAccountRequests/config.creation.mocked.json new file mode 100644 index 0000000..19ebac1 --- /dev/null +++ b/tests/Unit/TierAccountRequests/config.creation.mocked.json @@ -0,0 +1,16 @@ +{ + "apiKey": "ApiKey SU-766-419-989:56fda6081cd5200f089d28f7f9a6d390bf7ffcec", + "apiEndpoint": "https://api.connect.cloud.im/public/v1", + "logLevel": 4, + "timeout": 10, + "sslVerifyHost": false, + "products": [ + "PRD-254-370-432", + "PRD-245-341-069" + ], + "runtimeServices": { + "logger": "Test\\Unit\\Runtime\\Providers\\LoggerServiceProvider", + "http": "Test\\Unit\\Runtime\\Providers\\HttpServiceProviderTARCreation", + "std": "Test\\Unit\\Runtime\\Providers\\StdClassServiceProvider" + } +} \ No newline at end of file diff --git a/tests/Unit/TierAccountRequests/config.mocked.json b/tests/Unit/TierAccountRequests/config.mocked.json new file mode 100644 index 0000000..49cb4f9 --- /dev/null +++ b/tests/Unit/TierAccountRequests/config.mocked.json @@ -0,0 +1,16 @@ +{ + "apiKey": "ApiKey SU-766-419-989:56fda6081cd5200f089d28f7f9a6d390bf7ffcec", + "apiEndpoint": "https://api.connect.cloud.im/public/v1", + "logLevel": 4, + "timeout": 10, + "sslVerifyHost": false, + "products": [ + "PRD-254-370-432", + "PRD-245-341-069" + ], + "runtimeServices": { + "logger": "Test\\Unit\\Runtime\\Providers\\LoggerServiceProvider", + "http": "Test\\Unit\\Runtime\\Providers\\HttpServiceProviderTAR", + "std": "Test\\Unit\\Runtime\\Providers\\StdClassServiceProvider" + } +} \ No newline at end of file diff --git a/tests/Unit/UsageTests/AcceptTest.php b/tests/Unit/UsageTests/AcceptTest.php index a102873..7164dab 100644 --- a/tests/Unit/UsageTests/AcceptTest.php +++ b/tests/Unit/UsageTests/AcceptTest.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; diff --git a/tests/Unit/UsageTests/CloseTest.php b/tests/Unit/UsageTests/CloseTest.php index 1b6ffc2..46fb9fb 100644 --- a/tests/Unit/UsageTests/CloseTest.php +++ b/tests/Unit/UsageTests/CloseTest.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; diff --git a/tests/Unit/UsageTests/DeleteTest.php b/tests/Unit/UsageTests/DeleteTest.php index ec32958..6bd77ee 100644 --- a/tests/Unit/UsageTests/DeleteTest.php +++ b/tests/Unit/UsageTests/DeleteTest.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; diff --git a/tests/Unit/UsageTests/FileCreationExceptionTest.php b/tests/Unit/UsageTests/FileCreationExceptionTest.php index 0d7bffb..25fdd0e 100644 --- a/tests/Unit/UsageTests/FileCreationExceptionTest.php +++ b/tests/Unit/UsageTests/FileCreationExceptionTest.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; diff --git a/tests/Unit/UsageTests/FileRetrieveExceptionTest.php b/tests/Unit/UsageTests/FileRetrieveExceptionTest.php index ae176c0..a254826 100644 --- a/tests/Unit/UsageTests/FileRetrieveExceptionTest.php +++ b/tests/Unit/UsageTests/FileRetrieveExceptionTest.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; diff --git a/tests/Unit/UsageTests/RejectTest.php b/tests/Unit/UsageTests/RejectTest.php index 6e95e06..a03ac30 100644 --- a/tests/Unit/UsageTests/RejectTest.php +++ b/tests/Unit/UsageTests/RejectTest.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; diff --git a/tests/Unit/UsageTests/SubmitTest.php b/tests/Unit/UsageTests/SubmitTest.php index bb776c7..a147243 100644 --- a/tests/Unit/UsageTests/SubmitTest.php +++ b/tests/Unit/UsageTests/SubmitTest.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; diff --git a/tests/Unit/UsageTests/UsageAutomationBasicsHelper.php b/tests/Unit/UsageTests/UsageAutomationBasicsHelper.php index 962d74b..9d5d0f6 100644 --- a/tests/Unit/UsageTests/UsageAutomationBasicsHelper.php +++ b/tests/Unit/UsageTests/UsageAutomationBasicsHelper.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; diff --git a/tests/Unit/UsageTests/UsageAutomationBasicsTest.php b/tests/Unit/UsageTests/UsageAutomationBasicsTest.php index 11e37fe..9d3ce39 100644 --- a/tests/Unit/UsageTests/UsageAutomationBasicsTest.php +++ b/tests/Unit/UsageTests/UsageAutomationBasicsTest.php @@ -2,7 +2,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2018. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; @@ -44,6 +44,7 @@ public function testFakeShurtcut() { //to be deprecated $app = new UsageAutomationBasicsHelper(new Config('./config.mocked4usageautomationbasics.json')); + $this->assertInstanceOf('Test\Unit\UsageAutomationBasicsHelper', $app); $app->usage->__call("wrong", array()); } } diff --git a/tests/Unit/UsageTests/UsageAutomationHelper.php b/tests/Unit/UsageTests/UsageAutomationHelper.php index 385f64a..f7d0171 100644 --- a/tests/Unit/UsageTests/UsageAutomationHelper.php +++ b/tests/Unit/UsageTests/UsageAutomationHelper.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; diff --git a/tests/Unit/UsageTests/UsageAutomationTest.php b/tests/Unit/UsageTests/UsageAutomationTest.php index 2ee5d31..758dda9 100644 --- a/tests/Unit/UsageTests/UsageAutomationTest.php +++ b/tests/Unit/UsageTests/UsageAutomationTest.php @@ -2,7 +2,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2018. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; @@ -29,6 +29,7 @@ protected function setUp() public function testUsageAutomation() { $app = new UsageAutomationHelper(new Config('./config.mocked4usageautomation.json')); + $this->assertInstanceOf('Test\Unit\UsageAutomationHelper', $app); $app->process(); return $app; } @@ -36,6 +37,7 @@ public function testUsageAutomation() public function testUsageConfig() { $app = new UsageAutomationHelper(); + $this->assertInstanceOf('Test\Unit\UsageAutomationHelper', $app); return $app; } } diff --git a/tests/Unit/UsageTests/UsageFileAutomationHelper.php b/tests/Unit/UsageTests/UsageFileAutomationHelper.php index 26284fd..bc5e640 100644 --- a/tests/Unit/UsageTests/UsageFileAutomationHelper.php +++ b/tests/Unit/UsageTests/UsageFileAutomationHelper.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; diff --git a/tests/Unit/UsageTests/UsageFileAutomationTest.php b/tests/Unit/UsageTests/UsageFileAutomationTest.php index 58634b0..4aa6b15 100644 --- a/tests/Unit/UsageTests/UsageFileAutomationTest.php +++ b/tests/Unit/UsageTests/UsageFileAutomationTest.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit; diff --git a/tests/Unit/UsageTests/UsageSkipTest.php b/tests/Unit/UsageTests/UsageSkipTest.php index a168c8b..3d85927 100644 --- a/tests/Unit/UsageTests/UsageSkipTest.php +++ b/tests/Unit/UsageTests/UsageSkipTest.php @@ -3,7 +3,7 @@ /** * This file is part of the Ingram Micro Cloud Blue Connect SDK. * - * @copyright (c) 2019. Ingram Micro. All Rights Reserved. + * @copyright (c) 2018-2020. Ingram Micro. All Rights Reserved. */ namespace Test\Unit;