Skip to content

Commit

Permalink
Merge pull request #54 from cloudblue/v19-dev
Browse files Browse the repository at this point in the history
Changes for v19
  • Loading branch information
marcserrat authored Mar 19, 2020
2 parents f55566f + c6aa4b6 commit 76f4ee6
Show file tree
Hide file tree
Showing 202 changed files with 4,079 additions and 329 deletions.
97 changes: 96 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
),
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
<?php
$connect = new Connect\ConnectClient();
//List all tier accounts from a given marketplace
$tierAccounts = $connect->directory->listTierAccounts(['marketplace' => 'MP-XXXXXXX']);
```

* Get concrete Tier Account

```php
<?php
$connect = new Connect\ConnectClient();
$tierAccounts = $connect->directory->getTierAccountById('TA-XXXXXX-XXXXX');
```

* List tier account requests

```php
<?php
$connect = new Connect\ConnectClient();
$tar = $connect->directory->listTierAccountRequests(['status' => 'pending']);
```

* List Asset Subscriptions

```php
<?php
$connect = new Connect\ConnectClient();
$billingAssets = $connect->subscriptions->listSubscriptionAssets();
```

* Get Subscription Asset

```php
<?php
$connect = new Connect\ConnectClient();
$billingAsset = $connect->subscriptions->getSubscriptionAssetById('AS-1234-1234');
```

* Get Billing Subscription Requests

```php
<?php
$connect = new Connect\ConnectClient();
$billingRequests = $connect->subscriptions->listSubscriptionRequests();
```

* Get concrete Billing request

```php
<?php
$connect = new Connect\ConnectClient();
$billingAsset = $connect->subscriptions->getSubscriptionRequestById('PR-XXXXX-XXXXX-XXXXX');
```
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
14 changes: 11 additions & 3 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@
</logging>
<testsuites>
<testsuite name="Directory Services">
<file> tests/Unit/DirectoryTests/AssetTest.php</file>
<file> tests/Unit/DirectoryTests/ProductTest.php</file>
<file> tests/Unit/DirectoryTests/TierConfigTest.php</file>
<file>tests/Unit/DirectoryTests/AssetTest.php</file>
<file>tests/Unit/DirectoryTests/ProductTest.php</file>
<file>tests/Unit/DirectoryTests/TierConfigTest.php</file>
<file>tests/Unit/DirectoryTests/TierAccountsTest.php</file>
</testsuite>
<testsuite name="Subscription Services">
<file>tests/Unit/SubscriptionTests/SubscriptionRequestTest.php</file>
</testsuite>
<testsuite name="Tier Account Requests">
<file>tests/Unit/TierAccountRequests/ResponsesTest.php</file>
<file>tests/Unit/TierAccountRequests/TierAccountRequestsBasicsTest.php</file>
</testsuite>
<testsuite name="Fail">
<file>tests/Unit/FulfillmentTests/FailTest.php</file>
Expand Down
2 changes: 1 addition & 1 deletion src/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Activation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/ActivationTemplateResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/ActivationTileResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Agreement.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/AutomationEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,6 +28,7 @@
* @property TierConfiguration $tierConfiguration
* @property Usage $usage
* @property Directory $directory
* @property Subscriptions $subscriptions
* @package Connect
*/
abstract class AutomationEngine
Expand Down
2 changes: 1 addition & 1 deletion src/By.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Choice.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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'
];

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Config/VaultConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/ConfigException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/ConfigPropertyMissed.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/ConnectClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 9 additions & 1 deletion src/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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/';
}
2 changes: 1 addition & 1 deletion src/Constraints.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/ContactInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Contract.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 76f4ee6

Please sign in to comment.