Skip to content

Commit 9e6d8fd

Browse files
authored
Merge pull request #35 from ingrammicro/v17-dev
Added 2 new methoods for product, getTemplates returns list of all te…
2 parents 26785bd + 2d56292 commit 9e6d8fd

File tree

7 files changed

+93
-1
lines changed

7 files changed

+93
-1
lines changed

src/Product.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,26 @@ public function setCustomer_ui_settings($ui_settings)
6767
{
6868
$this->customer_ui_settings = Model::modelize('ProductCustomerUISettings', $ui_settings);
6969
}
70+
71+
public function getTemplates()
72+
{
73+
if ($this->id == null) {
74+
return [];
75+
}
76+
$body = ConnectClient::getInstance()->directory->sendRequest('GET', '/products/'.$this->id.'/templates');
77+
return Model::modelize('templates', json_decode($body));
78+
}
79+
80+
public function getProductConfigurations(RQL\Query $filter = null)
81+
{
82+
if ($this->id == null){
83+
return [];
84+
}
85+
if(!$filter){
86+
$filter = new \Connect\RQL\Query();
87+
}
88+
$body = ConnectClient::getInstance()->directory->sendRequest('GET', '/products/'.$this->id.'/configurations'.$filter->compile());
89+
return Model::modelize('ProductConfigurationParameters', json_decode($body));
90+
91+
}
7092
}

src/ProductConfigurationParameter.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
/**
3+
* This file is part of the Ingram Micro Cloud Blue Connect SDK.
4+
*
5+
* @copyright (c) 2018. Ingram Micro. All Rights Reserved.
6+
*/
7+
8+
namespace Connect;
9+
10+
11+
class ProductConfigurationParameter extends Model
12+
{
13+
/**
14+
* @var string
15+
*/
16+
public $value;
17+
18+
/**
19+
* @var Param
20+
*/
21+
22+
public $parameter;
23+
24+
/**
25+
* @var Constraints
26+
*/
27+
28+
public $constraints;
29+
30+
/**
31+
* @var Events[]
32+
*/
33+
34+
public $events;
35+
}

src/Template.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,10 @@ class Template extends Model
2828
*/
2929

3030
public $name;
31+
32+
/**
33+
* @var string
34+
*/
35+
36+
public $body;
3137
}

tests/Unit/DirectoryTests/ProductTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,30 @@ public function testGetProduct()
2727
$connectClient = new ConnectClient(new Config(__DIR__ . '/config.mocked.getProduct.json'));
2828
$product = $connectClient->directory->getProduct('PRD-086-505-671');
2929
$this->assertInstanceOf("\Connect\Product", $product);
30+
$templates = $product->getTemplates();
31+
foreach($templates as $template)
32+
{
33+
$this->assertInstanceOf('\Connect\template', $template);
34+
}
35+
$configurations = $product->getProductConfigurations();
36+
foreach($configurations as $configuration)
37+
{
38+
$this->assertInstanceOf('\Connect\ProductConfigurationParameter', $configuration);
39+
}
40+
}
41+
42+
public function testEmptyProductTemplates()
43+
{
44+
$product = new \Connect\Product();
45+
$templates = $product->getTemplates();
46+
$this->assertCount(0, $templates);
3047
}
48+
49+
public function testEmptyProductConfigurations()
50+
{
51+
$product = new \Connect\Product();
52+
$configurations = $product->getProductConfigurations();
53+
$this->assertCount(0, $configurations);
54+
}
55+
3156
}

tests/Unit/Runtime/Providers/Http4DirectorygetProductServiceProvider.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ public function register(Container $container)
1717
$body = \Mockery::mock('\Psr\Http\Message\StreamInterface');
1818
$body->shouldReceive('getContents')
1919
->andReturn(
20-
trim(file_get_contents(__DIR__ . '/productGetRequest.json'))
20+
trim(file_get_contents(__DIR__ . '/productGetRequest.json')),
21+
trim(file_get_contents(__DIR__.'/producttemplates.json')),
22+
trim(file_get_contents(__DIR__. '/productConfigurations.json'))
2123
);
2224

2325
$response = \Mockery::mock('\Psr\Http\Message\ResponseInterface');
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"value":"product_value","parameter":{"id":"product_configuration","title":"product_configuration","description":"product_configuration","type":"text","scope":"product","phase":"configuration","constraints":{"hidden":false,"required":true,"unique":false}},"events":{"updated":{"at":"2019-08-26T10:42:49+00:00"},"created":{"at":"2019-08-26T10:42:49+00:00","by":{"id":"UR-841-574-187","name":"Marc Serrat"}}}},{"value":"Value 1","parameter":{"id":"item_parameter","title":"item_parameter","description":"item_parameter","type":"text","scope":"item","phase":"configuration","constraints":{"hidden":false,"required":false,"unique":false}},"item":{"id":"SKU_A","name":"Sku A"},"events":{"updated":{"at":"2019-08-27T14:21:23+00:00","by":{"id":"UR-841-574-187","name":"Marc Serrat"}},"created":{"at":"2019-08-26T10:42:56+00:00","by":{"id":"UR-841-574-187","name":"Marc Serrat"}}}},{"parameter":{"id":"item_parameter","title":"item_parameter","description":"item_parameter","type":"text","scope":"item","phase":"configuration","constraints":{"hidden":false,"required":false,"unique":false}},"item":{"id":"SKU_B","name":"Sku B"},"events":{"updated":{"at":"2019-09-02T16:00:31+00:00","by":{"id":"UR-841-574-187","name":"Marc Serrat"}},"created":{"at":"2019-08-26T10:43:10+00:00","by":{"id":"UR-841-574-187","name":"Marc Serrat"}}}},{"value":"product_marketplace","parameter":{"id":"product_Marketplace_configuration","title":"product_Marketplace_configuration","description":"product_Marketplace_configuration","type":"text","scope":"marketplace","phase":"configuration","constraints":{"hidden":false,"required":true,"unique":false}},"marketplace":{"icon":"PA-425-033/marketplaces/MP-27096/icon_ReKWo2S.png","id":"MP-27096","name":"Digital River Demo Marketplace"},"events":{"updated":{"at":"2019-08-26T10:43:16+00:00"},"created":{"at":"2019-08-26T10:43:16+00:00","by":{"id":"UR-841-574-187","name":"Marc Serrat"}}}},{"value":"product_marketplace_config","parameter":{"id":"product_Marketplace_configuration","title":"product_Marketplace_configuration","description":"product_Marketplace_configuration","type":"text","scope":"marketplace","phase":"configuration","constraints":{"hidden":false,"required":true,"unique":false}},"marketplace":{"icon":"PA-855-748/marketplaces/MP-71206/icon.png","id":"MP-71206","name":"Worldwide Marketplace"},"events":{"updated":{"at":"2019-08-26T10:43:27+00:00"},"created":{"at":"2019-08-26T10:43:27+00:00","by":{"id":"UR-841-574-187","name":"Marc Serrat"}}}},{"value":"product_marketplace_config","parameter":{"id":"product_Marketplace_configuration","title":"product_Marketplace_configuration","description":"product_Marketplace_configuration","type":"text","scope":"marketplace","phase":"configuration","constraints":{"hidden":false,"required":true,"unique":false}},"marketplace":{"icon":"PA-425-033/marketplaces/MP-91673/icon_XdcpVQk.png","id":"MP-91673","name":"IMC Demo Marketplace"},"events":{"updated":{"at":"2019-08-26T10:43:36+00:00"},"created":{"at":"2019-08-26T10:43:36+00:00","by":{"id":"UR-841-574-187","name":"Marc Serrat"}}}},{"value":"item","parameter":{"id":"item_per_marketplace","title":"item_per_marketplace","description":"item_per_marketplace","type":"text","scope":"item_marketplace","phase":"configuration","constraints":{"hidden":false,"required":true,"unique":false}},"item":{"id":"SKU_A","name":"Sku A"},"marketplace":{"icon":"PA-425-033/marketplaces/MP-27096/icon_ReKWo2S.png","id":"MP-27096","name":"Digital River Demo Marketplace"},"events":{"updated":{"at":"2019-08-26T10:44:04+00:00"},"created":{"at":"2019-08-26T10:44:04+00:00","by":{"id":"UR-841-574-187","name":"Marc Serrat"}}}},{"value":"item","parameter":{"id":"item_per_marketplace","title":"item_per_marketplace","description":"item_per_marketplace","type":"text","scope":"item_marketplace","phase":"configuration","constraints":{"hidden":false,"required":true,"unique":false}},"item":{"id":"SKU_A","name":"Sku A"},"marketplace":{"icon":"PA-855-748/marketplaces/MP-71206/icon.png","id":"MP-71206","name":"Worldwide Marketplace"},"events":{"updated":{"at":"2019-08-26T10:44:10+00:00"},"created":{"at":"2019-08-26T10:44:10+00:00","by":{"id":"UR-841-574-187","name":"Marc Serrat"}}}},{"value":"item","parameter":{"id":"item_per_marketplace","title":"item_per_marketplace","description":"item_per_marketplace","type":"text","scope":"item_marketplace","phase":"configuration","constraints":{"hidden":false,"required":true,"unique":false}},"item":{"id":"SKU_A","name":"Sku A"},"marketplace":{"icon":"PA-425-033/marketplaces/MP-91673/icon_XdcpVQk.png","id":"MP-91673","name":"IMC Demo Marketplace"},"events":{"updated":{"at":"2019-08-26T10:44:16+00:00"},"created":{"at":"2019-08-26T10:44:16+00:00","by":{"id":"UR-841-574-187","name":"Marc Serrat"}}}},{"value":"item","parameter":{"id":"item_per_marketplace","title":"item_per_marketplace","description":"item_per_marketplace","type":"text","scope":"item_marketplace","phase":"configuration","constraints":{"hidden":false,"required":true,"unique":false}},"item":{"id":"SKU_B","name":"Sku B"},"marketplace":{"icon":"PA-425-033/marketplaces/MP-27096/icon_ReKWo2S.png","id":"MP-27096","name":"Digital River Demo Marketplace"},"events":{"updated":{"at":"2019-08-26T10:44:19+00:00"},"created":{"at":"2019-08-26T10:44:19+00:00","by":{"id":"UR-841-574-187","name":"Marc Serrat"}}}},{"value":"item","parameter":{"id":"item_per_marketplace","title":"item_per_marketplace","description":"item_per_marketplace","type":"text","scope":"item_marketplace","phase":"configuration","constraints":{"hidden":false,"required":true,"unique":false}},"item":{"id":"SKU_B","name":"Sku B"},"marketplace":{"icon":"PA-855-748/marketplaces/MP-71206/icon.png","id":"MP-71206","name":"Worldwide Marketplace"},"events":{"updated":{"at":"2019-08-26T10:44:26+00:00"},"created":{"at":"2019-08-26T10:44:26+00:00","by":{"id":"UR-841-574-187","name":"Marc Serrat"}}}},{"value":"item","parameter":{"id":"item_per_marketplace","title":"item_per_marketplace","description":"item_per_marketplace","type":"text","scope":"item_marketplace","phase":"configuration","constraints":{"hidden":false,"required":true,"unique":false}},"item":{"id":"SKU_B","name":"Sku B"},"marketplace":{"icon":"PA-425-033/marketplaces/MP-91673/icon_XdcpVQk.png","id":"MP-91673","name":"IMC Demo Marketplace"},"events":{"updated":{"at":"2019-08-26T10:44:31+00:00"},"created":{"at":"2019-08-26T10:44:31+00:00","by":{"id":"UR-841-574-187","name":"Marc Serrat"}}}}]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"id":"TL-596-091-463","title":"Default Activation Template","body":"# Sample Activation Template\n\nSu suscripción en Microsoft es: {{ SubscriptionId }}"},{"id":"TL-027-745-332","title":"Default Activation Template","body":"# Sample Template For Setup of Tier 1\n\nThis template is used to share details of the **successful** setup configuration of reseller of 1st level.\n\nThis template uses **[Markdown](https://en.wikipedia.org/wiki/Markdown)** syntax and allows to use Parameters of the product which have scope 'Tier 1'.\n\n### Formatting\n\nMarkdown allows you to control various aspects of the document:\n\n1. Text formatting like **bold** or *italic*\n2. Images embedding\n3. Lists\n4. and more\n\n### Parameters\n\nYou can refer to the Parameters using their ID, like in the following example:\n\n* The value of **param_a** is **{{ param_a }}**\n* The value of **param_b** is **{{ param_b }}**\n\nYou can also embed pictures like the one below:\n\n![logo](https://upload.wikimedia.org/wikipedia/commons/thumb/b/b2/Ringworld_Waiting.jpg/270px-Ringworld_Waiting.jpg)"},{"id":"TL-396-677-691","title":"Default Activation Template","body":"# Sample Template For Setup of Tier 2\n\nThis template is used to share details of the **successful** setup configuration of reseller of 2nd level.\n\nThis template uses **[Markdown](https://en.wikipedia.org/wiki/Markdown)** syntax and allows to use Parameters of the product which have scope 'Tier 2'.\n\n### Formatting\n\nMarkdown allows you to control various aspects of the document:\n\n1. Text formatting like **bold** or *italic*\n2. Images embedding\n3. Lists\n4. and more\n\n### Parameters\n\nYou can refer to the Parameters using their ID, like in the following example:\n\n* The value of **param_a** is **{{ param_a }}**\n* The value of **param_b** is **{{ param_b }}**\n\nYou can also embed pictures like the one below:\n\n![logo](https://upload.wikimedia.org/wikipedia/commons/thumb/b/b2/Ringworld_Waiting.jpg/270px-Ringworld_Waiting.jpg)"}]

0 commit comments

Comments
 (0)