Skip to content

Commit c0090a8

Browse files
Merge branch 'develop' into ACQE-functional-deployment-v4-5
2 parents 7725fc6 + ae1f272 commit c0090a8

File tree

4 files changed

+35
-22
lines changed

4 files changed

+35
-22
lines changed

InventoryInStorePickupApi/Test/Api/GetPickupLocationsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,7 @@ private function sendRequest(array $requestData)
10991099
$serviceInfo = [
11001100
'rest' => [
11011101
'resourcePath' => self::RESOURCE_PATH . '?' . http_build_query($requestData),
1102-
'httpMethod' => Request::HTTP_METHOD_GET,
1102+
'httpMethod' => Request::HTTP_METHOD_POST,
11031103
],
11041104
'soap' => [
11051105
'service' => self::SERVICE_NAME,

InventoryInStorePickupApi/etc/webapi.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,10 @@
1313
<resource ref="anonymous"/>
1414
</resources>
1515
</route>
16+
<route url="/V1/inventory/in-store-pickup/pickup-locations/" method="POST">
17+
<service class="Magento\InventoryInStorePickupApi\Api\GetPickupLocationsInterface" method="execute"/>
18+
<resources>
19+
<resource ref="anonymous"/>
20+
</resources>
21+
</route>
1622
</routes>

InventoryInStorePickupFrontend/view/frontend/web/js/model/pickup-locations-service.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,22 +82,24 @@ define([
8282
*/
8383
getNearbyLocations: function (searchCriteria) {
8484
var self = this,
85-
serviceUrl = resourceUrlManager.getUrlForNearbyPickupLocations(websiteCode, searchCriteria);
85+
serviceUrl = resourceUrlManager.getUrlForNearbyPickupLocations(),
86+
requestData = resourceUrlManager.getNearbyPickupLocationsRequestData(websiteCode, searchCriteria),
87+
cacheKey = serviceUrl + JSON.stringify(requestData);
8688

87-
if (self.locationsCache[serviceUrl]) {
88-
return $.Deferred().resolve(self.locationsCache[serviceUrl]).promise();
89+
if (self.locationsCache[cacheKey]) {
90+
return $.Deferred().resolve(self.locationsCache[cacheKey]).promise();
8991
}
9092

9193
self.isLoading(true);
9294

9395
return storage
94-
.get(serviceUrl, {}, false)
96+
.post(serviceUrl, JSON.stringify(requestData), false)
9597
.then(function (result) {
96-
self.locationsCache[serviceUrl] = _.map(result.items, function (address) {
98+
self.locationsCache[cacheKey] = _.map(result.items, function (address) {
9799
return self.formatAddress(address);
98100
});
99101

100-
return self.locationsCache[serviceUrl];
102+
return self.locationsCache[cacheKey];
101103
})
102104
.fail(function (response) {
103105
self.processError(response);

InventoryInStorePickupFrontend/view/frontend/web/js/model/resource-url-manager.js

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,38 @@ define(['jquery', 'Magento_Checkout/js/model/resource-url-manager'], function (
1111

1212
return {
1313
/**
14-
* Returns URL for REST API to fetch nearby pickup locations defined for given sales channel.
14+
* Returns URL for REST API to fetch nearby pickup locations.
15+
*/
16+
getUrlForNearbyPickupLocations: function () {
17+
var urls = {
18+
default: '/inventory/in-store-pickup/pickup-locations/'
19+
};
20+
21+
return resourceUrlManager.getUrl(urls, {});
22+
},
23+
24+
/**
25+
* Prepares search criteria for nearby pickup locations request.
1526
*
1627
* @param {String} salesChannelCode - Code of the sales channel.
1728
* @param {Object} searchCriteria
29+
* @returns {Object}
1830
*/
19-
getUrlForNearbyPickupLocations: function (
31+
getNearbyPickupLocationsRequestData: function (
2032
salesChannelCode,
2133
searchCriteria
2234
) {
23-
var urls = {
24-
default: '/inventory/in-store-pickup/pickup-locations/'
25-
},
26-
criteria = {
27-
searchRequest: {
28-
scopeCode: salesChannelCode
29-
}
30-
};
35+
var criteria = {
36+
searchRequest: {
37+
scopeCode: salesChannelCode
38+
}
39+
};
3140

3241
searchCriteria = {
3342
searchRequest: searchCriteria
3443
};
3544

36-
return (
37-
resourceUrlManager.getUrl(urls, {}) +
38-
'?' +
39-
$.param($.extend(true, criteria, searchCriteria))
40-
);
45+
return $.extend(true, criteria, searchCriteria);
4146
},
4247

4348
/**

0 commit comments

Comments
 (0)