diff --git a/README.md b/README.md
index da79751..92ca6b8 100755
--- a/README.md
+++ b/README.md
@@ -19,7 +19,7 @@ bin/magento setup:upgrade
1. Declare your service in di.xml by implementing `Zepgram\Rest\Service\ApiProvider` as VirtualClass, you can configure it by following the [ApiProviderConfig](#xml-config)
2. Declare your VirtualClass in dedicated Pool `Zepgram\Rest\Service\ApiPoolInterface`, the key used will be your `service_name`
-3. To create your dedicated **ApiRequest** use the **ApiFactory** `$this->apiFactory->create('service_name', $rawData)->sendRequest()` where:
+3. To create your dedicated **ApiRequest** use the **ApiFactory** `$this->apiFactory->get('service_name', $rawData)->sendRequest()` where:
- **service_name** represents the service name declared previously in `apiProviders[]`
- **$rawData** is an array of dynamic data that you will receive in `dispatch()` method
4. Create a system.xml, and a config.xml that must use the **configName** injected previously, see [Rest api store config](#store-config):
@@ -247,7 +247,7 @@ class OrderDataExample
// load raw data
$order = $this->orderRepository->get($orderId);
// prepare request
- $foxtrotApiRequest = $this->apiFactory->create('foxtrot_order', ['order' => $order]);
+ $foxtrotApiRequest = $this->apiFactory->get('foxtrot_order', ['order' => $order]);
// send request
$result = $foxtrotApiRequest->sendRequest();
// handle result
diff --git a/Service/ApiFactory.php b/Service/ApiFactory.php
index 94ae849..a2de7ff 100755
--- a/Service/ApiFactory.php
+++ b/Service/ApiFactory.php
@@ -68,12 +68,21 @@ public function get(string $serviceName, array $rawData = []): ApiRequestInterfa
return $this->apiRequestRegistry[$registryKey];
}
- $apiRequest = $this->objectManager->create(ApiRequestInterface::class, [
+ return $this->apiRequestRegistry[$registryKey] = $this->create($serviceName, $rawData);
+ }
+
+ /**
+ * @param string $serviceName
+ * @param mixed $rawData
+ * @return ApiRequestInterface
+ * @throws LogicException
+ */
+ private function create(string $serviceName, array $rawData = []): ApiRequestInterface
+ {
+ return $this->objectManager->create(ApiRequestInterface::class, [
'apiProvider' => $this->apiPool->getApiProvider($serviceName),
'rawData' => $this->dataObjectFactory->create($rawData),
'serviceName' => $serviceName
]);
-
- return $this->apiRequestRegistry[$registryKey] = $apiRequest;
}
}
diff --git a/composer.json b/composer.json
index 441e973..362a507 100755
--- a/composer.json
+++ b/composer.json
@@ -2,7 +2,7 @@
"name": "zepgram/module-rest",
"description": "Technical module to industrialize API REST call with dependency injection pattern using Guzzle library in Magento 2",
"type": "magento2-module",
- "version": "1.0.0",
+ "version": "1.0.1",
"authors": [
{
"name": "Benjamin Calef",
diff --git a/etc/di.xml b/etc/di.xml
index d32c647..126fd21 100755
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -36,4 +36,9 @@
+
+
+ Zepgram\Rest\Service\ApiPoolInterface\Proxy
+
+