@@ -51,6 +51,13 @@ class CurlHandler
51
51
*/
52
52
private $ dependentEntities = [];
53
53
54
+ /**
55
+ * Persisted data array.
56
+ *
57
+ * @var array
58
+ */
59
+ private $ persistedDataArray ;
60
+
54
61
/**
55
62
* The array of entity name and number of objects being created,
56
63
* we don't need to track objects in update and delete operations.
@@ -79,25 +86,11 @@ class CurlHandler
79
86
];
80
87
81
88
/**
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.
97
90
*
98
91
* @var bool
99
92
*/
100
- private $ isRestRequest ;
93
+ private $ isWebApiRequest ;
101
94
102
95
/**
103
96
* ApiSubObject constructor.
@@ -111,7 +104,7 @@ public function __construct($operation, $entityObject, $dependentEntities = null
111
104
$ this ->operation = $ operation ;
112
105
$ this ->entityObject = $ entityObject ;
113
106
$ this ->storeCode = $ storeCode ;
114
- $ this ->isRestRequest = true ;
107
+ $ this ->isWebApiRequest = true ;
115
108
if ($ dependentEntities != null ) {
116
109
foreach ($ dependentEntities as $ entity ) {
117
110
$ this ->dependentEntities [$ entity ->getName ()] = $ entity ;
@@ -150,23 +143,33 @@ public function executeRequest()
150
143
$ successRegex = null ;
151
144
$ returnRegex = null ;
152
145
$ headers = $ this ->dataDefinition ->getHeaders ();
153
- $ params = $ this ->convertDataArray ($ this ->entityObject , $ this ->dataDefinition ->getMetaData ());
146
+ $ this -> persistedDataArray = $ this ->convertDataArray ($ this ->entityObject , $ this ->dataDefinition ->getMetaData ());
154
147
155
148
$ authorization = $ this ->dataDefinition ->getAuth ();
156
149
switch ($ authorization ) {
157
150
case 'adminOauth ' :
158
151
$ 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
+ );
160
158
break ;
161
159
case 'adminFormkey ' :
162
- $ this ->isRestRequest = false ;
160
+ $ this ->isWebApiRequest = false ;
163
161
$ 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
+ );
165
168
$ successRegex = $ this ->dataDefinition ->getSuccessRegex ();
166
169
$ returnRegex = $ this ->dataDefinition ->getReturnRegex ();
167
170
break ;
168
171
case 'customFromkey ' :
169
- $ this ->isRestRequest = false ;
172
+ $ this ->isWebApiRequest = false ;
170
173
// TODO: add frontend request executor.
171
174
break ;
172
175
}
@@ -176,13 +179,23 @@ public function executeRequest()
176
179
}
177
180
178
181
/**
179
- * If the request is a Rest .
182
+ * If it's a web api request .
180
183
*
181
184
* @return bool
182
185
*/
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 ()
184
197
{
185
- return $ this ->isRestRequest ;
198
+ return $ this ->persistedDataArray ;
186
199
}
187
200
188
201
/**
0 commit comments