Skip to content

Commit 41689bd

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 9acd6ef + f1a3abf commit 41689bd

File tree

1 file changed

+46
-37
lines changed

1 file changed

+46
-37
lines changed

README.md

Lines changed: 46 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,63 @@
1-
php-mozu-api
2-
============
1+
# Mozu PHP SDK
32

43
PHP SDK for the full v1 Mozu Api
54

65
PackageGist: https://packagist.org/packages/mozu/api
76

8-
Usage:
7+
## Usage:
98

10-
<B>Authenticating an Application with server provided refresh interval tokens</B><br>
9+
### Authenticating an Application with server provided refresh interval tokens
10+
```
1111
$appAuthInfo = new AppAuthInfo();<br>
12-
$appAuthInfo->sharedSecret = [sharedSecret];<br>
13-
$appAuthInfo->applicationId = [applicationId];<br>
14-
AppAuthenticator::initialize($appAuthInfo,null);<br>
15-
<br>
16-
<B>Get Tenant Information using Async operation</B><br>
17-
$tenantResource = new TenantResource();<br>
18-
$promise = $tenantResource->getTenantAsync([tenantId]);<br>
12+
$appAuthInfo->sharedSecret = [sharedSecret];
13+
$appAuthInfo->applicationId = [applicationId];
14+
AppAuthenticator::initialize($appAuthInfo,null);
15+
```
16+
17+
###Get Tenant Information using Async operation
18+
```
19+
$tenantResource = new TenantResource();
20+
$promise = $tenantResource->getTenantAsync([tenantId]);
1921
$tenant = $promise->wait()->json();
20-
<br>
21-
<B>Get Products</B><br>
22-
$apiContext = new ApiContext($tenant);<br>
23-
<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>
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>
22+
```
23+
24+
###Get Products
25+
26+
```
27+
$apiContext = new ApiContext($tenant);
28+
#You might need to create an API Context with a specific Mastercatalog or catalogId if you own a multi-catalog tenant<br>
29+
$productResource = new ProductResource($apiContext, DataViewMode::LIVE);
30+
$promise = $productResource->getProductsAsync(0, 200, null, null, null, null, null);
31+
$promise->then(function($mozuResult) {
32+
printf($mozuResult->json()->pageCount);
33+
printf($mozuResult->json()->items);
34+
35+
printf($mozuResult->correlationId);
36+
}, function($apiException) {
3237
printf("Exception : code - " . $apiException->getCode() . ", message - " . $apiException->getMessage(). ", correlationid - " . $apiException->getCorrelationId() );
3338
});
34-
<br>
35-
<B>Get Orders - Filter by date</B><br>
36-
$orderResource = new OrderResource($apiContext);<br>
37-
$filters = urlencode("submittedDate gt 2013-12-15T12:21:24z");<br>
38-
$promise = $orderResource->getOrdersAsync('0',100, null,$filters, null, null);<br>
39+
```
40+
41+
###Get Orders - Filter by date
42+
```
43+
$orderResource = new OrderResource($apiContext);
44+
$filters = urlencode("submittedDate gt 2013-12-15T12:21:24z");
45+
$promise = $orderResource->getOrdersAsync('0',100, null,$filters, null, null);
3946
$mozuResult = $promise->wait();
4047
$correlation = $mozuResult->correlationId;
4148
$orders = $mozuResult->json()->items;
49+
```
4250

43-
<br>
44-
<B>Get Products - Pool multiple requests</B><br>
45-
$productResource = new ProductResource($apiContext, DataViewMode::LIVE);<br>
46-
$promises = [<br>
51+
###Get Products - Pool multiple requests
52+
```
53+
$productResource = new ProductResource($apiContext, DataViewMode::LIVE);
54+
$promises = [
4755
"product1" => $this->object->getProductAsync("product1"),<br>
4856
"product2" => $this->object->getProductAsync("product2"),<br>
4957
"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>
58+
];
59+
$results = Promise\unwrap($promises);
60+
printf($results["product1"]->json()->productCode);
61+
printf($results["product2"]->json()->productCode);
62+
printf($results["product3"]->json()->productCode);
63+
```

0 commit comments

Comments
 (0)