@@ -51,6 +51,13 @@ class CurlHandler
5151 */
5252 private $ dependentEntities = [];
5353
54+ /**
55+ * Persisted data array.
56+ *
57+ * @var array
58+ */
59+ private $ persistedDataArray ;
60+
5461 /**
5562 * The array of entity name and number of objects being created,
5663 * we don't need to track objects in update and delete operations.
@@ -79,25 +86,11 @@ class CurlHandler
7986 ];
8087
8188 /**
82- * Persisted entity.
83- *
84- * @var EntityDataObject
85- */
86- private $ persistedEntity ;
87-
88- /**
89- * Persisted dependent entities.
90- *
91- * @var array
92- */
93- private $ persistedDependentEntities = [];
94-
95- /**
96- * If it's a REST request.
89+ * If it's a web api request.
9790 *
9891 * @var bool
9992 */
100- private $ isRestRequest ;
93+ private $ isWebApiRequest ;
10194
10295 /**
10396 * ApiSubObject constructor.
@@ -111,7 +104,7 @@ public function __construct($operation, $entityObject, $dependentEntities = null
111104 $ this ->operation = $ operation ;
112105 $ this ->entityObject = $ entityObject ;
113106 $ this ->storeCode = $ storeCode ;
114- $ this ->isRestRequest = true ;
107+ $ this ->isWebApiRequest = true ;
115108 if ($ dependentEntities != null ) {
116109 foreach ($ dependentEntities as $ entity ) {
117110 $ this ->dependentEntities [$ entity ->getName ()] = $ entity ;
@@ -150,23 +143,33 @@ public function executeRequest()
150143 $ successRegex = null ;
151144 $ returnRegex = null ;
152145 $ headers = $ this ->dataDefinition ->getHeaders ();
153- $ params = $ this ->convertDataArray ($ this ->entityObject , $ this ->dataDefinition ->getMetaData ());
146+ $ this -> persistedDataArray = $ this ->convertDataArray ($ this ->entityObject , $ this ->dataDefinition ->getMetaData ());
154147
155148 $ authorization = $ this ->dataDefinition ->getAuth ();
156149 switch ($ authorization ) {
157150 case 'adminOauth ' :
158151 $ executor = new WebapiExecutor ($ this ->storeCode );
159- $ executor ->write ($ apiUrl , $ params , self ::$ curlMethodMapping [$ this ->operation ], $ headers );
152+ $ executor ->write (
153+ $ apiUrl ,
154+ $ this ->persistedDataArray ,
155+ self ::$ curlMethodMapping [$ this ->operation ],
156+ $ headers
157+ );
160158 break ;
161159 case 'adminFormkey ' :
162- $ this ->isRestRequest = false ;
160+ $ this ->isWebApiRequest = false ;
163161 $ executor = new AdminExecutor ();
164- $ executor ->write ($ apiUrl , $ params , self ::$ curlMethodMapping [$ this ->operation ], $ headers );
162+ $ executor ->write (
163+ $ apiUrl ,
164+ $ this ->persistedDataArray ,
165+ self ::$ curlMethodMapping [$ this ->operation ],
166+ $ headers
167+ );
165168 $ successRegex = $ this ->dataDefinition ->getSuccessRegex ();
166169 $ returnRegex = $ this ->dataDefinition ->getReturnRegex ();
167170 break ;
168171 case 'customFromkey ' :
169- $ this ->isRestRequest = false ;
172+ $ this ->isWebApiRequest = false ;
170173 // TODO: add frontend request executor.
171174 break ;
172175 }
@@ -176,13 +179,23 @@ public function executeRequest()
176179 }
177180
178181 /**
179- * If the request is a Rest .
182+ * If it's a web api request .
180183 *
181184 * @return bool
182185 */
183- public function isRestRequest ()
186+ public function isWebApiRequest ()
187+ {
188+ return $ this ->isWebApiRequest ;
189+ }
190+
191+ /**
192+ * Get persisted data array.
193+ *
194+ * @return array
195+ */
196+ public function getPersistedDataArray ()
184197 {
185- return $ this ->isRestRequest ;
198+ return $ this ->persistedDataArray ;
186199 }
187200
188201 /**
0 commit comments