Skip to content

Commit 055ea61

Browse files
committed
Remove dataview mode from methods
Add DataViewMode to constructor on required resources Add Async Methods
1 parent da5a853 commit 055ea61

File tree

251 files changed

+9570
-607
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

251 files changed

+9570
-607
lines changed

README.md

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,42 @@ $appAuthInfo->sharedSecret = [sharedSecret];<br>
1313
$appAuthInfo->applicationId = [applicationId];<br>
1414
AppAuthenticator::initialize($appAuthInfo,null);<br>
1515
<br>
16-
<B>Get Tenant Information</B><br>
16+
<B>Get Tenant Information using Async operation</B><br>
1717
$tenantResource = new TenantResource();<br>
18-
$tenant = $tenantResource->getTenant([tenantId]);<br>
18+
$promise = $tenantResource->getTenantAsync([tenantId]);<br>
19+
$tenant = $promise->wait()->json();
1920
<br>
2021
<B>Get Products</B><br>
2122
$apiContext = new ApiContext($tenant);<br>
2223
<B>Note:</B> You might need to create an API Context with a specific Mastercatalog or catalogId if you own a multi-catalog tenant<br>
23-
$productResource = new ProductResource($apiContext);<br>
24-
$productCollection = $productResource->getProducts(DataViewMode::LIVE, 0, 200, null, null, null, null, null);<br>
24+
$productResource = new ProductResource($apiContext, DataViewMode::LIVE);<br>
25+
$promise = $productResource->getProductsAsync(0, 200, null, null, null, null, null);<br>
26+
$promise->then(function($mozuResult) {<br>
27+
printf($mozuResult->json()->pageCount);<br>
28+
printf($mozuResult->json()->items);<br>
29+
<br>
30+
printf($mozuResult->correlationId);<br>
31+
}, function($apiException) {<br>
32+
printf("Exception : code - " . $apiException->getCode() . ", message - " . $apiException->getMessage(). ", correlationid - " . $apiException->getCorrelationId() );
33+
});
2534
<br>
2635
<B>Get Orders - Filter by date</B><br>
2736
$orderResource = new OrderResource($apiContext);<br>
28-
$filters = urlencode("submittedDate+gt+2013-12-15T12:21:24z");<br>
29-
$orders = $orderResource->getOrders('0',100, null,$filters, null, null);<br>
30-
37+
$filters = urlencode("submittedDate gt 2013-12-15T12:21:24z");<br>
38+
$promise = $orderResource->getOrdersAsync('0',100, null,$filters, null, null);<br>
39+
$mozuResult = $promise->wait();
40+
$correlation = $mozuResult->correlationId;
41+
$orders = $mozuResult->json()->items;
3142

3243
<br>
33-
See Mozu.Api\Tests for more examples
44+
<B>Get Products - Pool multiple requests</B><br>
45+
$productResource = new ProductResource($apiContext, DataViewMode::LIVE);<br>
46+
$promises = [<br>
47+
"product1" => $this->object->getProductAsync("product1"),<br>
48+
"product2" => $this->object->getProductAsync("product2"),<br>
49+
"product3" => $this->object->getProductAsync("product3")<br>
50+
];<br>
51+
$results = Promise\unwrap($promises);<br>
52+
printf($results["product1"]->json()->productCode);<br>
53+
printf($results["product2"]->json()->productCode);<br>
54+
printf($results["product3"]->json()->productCode);<br>

src/Mozu/Api/ApiException.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,62 +15,62 @@ public function __construct($message, $code) {
1515
return parent::__construct($message, $code);
1616
}
1717

18-
18+
1919
public function getCorrelationId() {
2020
return $this->correlationId;
2121
}
22-
22+
2323
public function getApiContext() {
2424
return $this->apiContext;
25-
}
26-
25+
}
26+
2727

2828
public function getItems() {
2929
return $this->items;
3030
}
31-
31+
3232

3333
public function setCorrelationId($correlationId) {
3434
$this->correlationId = $correlationId;
3535
}
36-
36+
3737
public function setApiContext($apiContext) {
3838
$this->apiContext = $apiContext;
3939
}
40-
40+
4141
public function setItems($items) {
4242
$this->items = $items;
4343
}
44-
44+
4545
public function getAdditionalErrorData() {
4646
return $this->additionalErrorData;
4747
}
48-
48+
4949
public function setAdditionalErrorData($additionalErrorData) {
5050
$this->additionalErrorData = $additionalErrorData;
5151
return $this;
5252
}
53-
53+
5454
public function getErrorCode() {
5555
return $this->errorCode;
5656
}
57-
57+
5858
public function setErrorCode($errorCode) {
5959
$this->errorCode = $errorCode;
6060
return $this;
6161
}
62-
62+
6363
public function getApplicationName() {
6464
return $this->applicationName;
6565
}
66-
66+
6767
public function setApplicationName($applicationName) {
6868
$this->applicationName = $applicationName;
6969
return $this;
7070
}
71-
72-
73-
71+
72+
73+
7474
}
7575

7676
?>

src/Mozu/Api/Clients/Commerce/Admin/LocationClient.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Mozu\Api\MozuClient;
1616
use Mozu\Api\Urls\Commerce\Admin\LocationUrl;
1717

18+
1819
/**
1920
* Use the Locations resource to manage each physical location associated with a tenant. Locations enable tenants to associate a physical address with product inventory, provide a store finder for in-store pickup, or both. Locations that support inventory can use both direct ship and in-store pickup fulfillment types.
2021
*/

src/Mozu/Api/Clients/Commerce/Admin/LocationTypeClient.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Mozu\Api\MozuClient;
1616
use Mozu\Api\Urls\Commerce\Admin\LocationTypeUrl;
1717

18+
1819
/**
1920
* Use the Location Types resource to manage the types of locations your tenant maintains, such as warehouses, physical storefronts, and kiosks.
2021
*/

src/Mozu/Api/Clients/Commerce/CartClient.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Mozu\Api\MozuClient;
1616
use Mozu\Api\Urls\Commerce\CartUrl;
1717

18+
1819
/**
1920
* Use this resource to manage storefront shopping carts as shoppers add and remove items for purchase. Each time a shopper's cart is modified, the Carts resource updates the estimated total with any applicable discounts.
2021
*/

src/Mozu/Api/Clients/Commerce/Carts/AppliedDiscountClient.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Mozu\Api\MozuClient;
1616
use Mozu\Api\Urls\Commerce\Carts\AppliedDiscountUrl;
1717

18+
1819
/**
1920
* Use the Cart Coupons resource to apply a coupon to a defined cart or remove a coupon from a cart. When the shopper proceeds to checkout, the coupons applied to the cart apply to the order.
2021
*/

src/Mozu/Api/Clients/Commerce/Carts/CartItemClient.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Mozu\Api\MozuClient;
1616
use Mozu\Api\Urls\Commerce\Carts\CartItemUrl;
1717

18+
1819
/**
1920
* Use the Cart Items subresource to manage a collection of items in an active shopping cart.
2021
*/

src/Mozu/Api/Clients/Commerce/Carts/ChangeMessageClient.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Mozu\Api\MozuClient;
1616
use Mozu\Api\Urls\Commerce\Carts\ChangeMessageUrl;
1717

18+
1819
/**
1920
* Use the Cart Messages resource to retrieve messages for live carts that the system logs when a product's price or inventory level changes.
2021
*/

src/Mozu/Api/Clients/Commerce/Carts/ExtendedPropertyClient.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Mozu\Api\MozuClient;
1616
use Mozu\Api\Urls\Commerce\Carts\ExtendedPropertyUrl;
1717

18+
1819
/**
1920
* commerce/carts/cartextendedproperties related resources. DOCUMENT_HERE
2021
*/

src/Mozu/Api/Clients/Commerce/Catalog/Admin/Attributedefinition/AttributeClient.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Mozu\Api\MozuClient;
1616
use Mozu\Api\Urls\Commerce\Catalog\Admin\Attributedefinition\AttributeUrl;
1717

18+
1819
/**
1920
* Use the Attribute Definition resource to manage the properties, options, and extras that uniquely describe products of a specific type. Attributes can be associated with a product type, assigned values by a client or shopper, and added as faceted search filters for a product category. Options are product attributes that describe unique configurations made by the shopper, such as size or color, and generate a new product variation (or unique SKU). Properties are product attributes that describe aspects of the product that do not represent an option configurable by the shopper, such as screen resolution or brand. Extras are product attributes that describe add-on configurations made by the shopper that do not represent a product variation, such as a monogram.
2021
*/

0 commit comments

Comments
 (0)