@@ -21,7 +21,7 @@ class MagentoAsync
2121
2222 protected ?Model $ subject = null ;
2323
24- /** @var array<int, Model> */
24+ /** @var array<int, ? Model> */
2525 protected array $ subjects = [];
2626
2727 public function __construct (
@@ -70,68 +70,69 @@ public function subject(Model $subject): static
7070 return $ this ;
7171 }
7272
73- /** @param array<int, Model> $subjects */
73+ /** @param array<int, ? Model> $subjects */
7474 public function subjects (array $ subjects ): static
7575 {
7676 $ this ->subjects = $ subjects ;
7777
7878 return $ this ;
7979 }
8080
81- /** @param array<mixed, mixed> $data */
81+ /** @param array<mixed, mixed> $data */
8282 public function post (string $ path , array $ data = []): BulkRequest
8383 {
8484 $ response = $ this ->magento ->postAsync ($ path , $ data );
8585
86- return $ this ->processResponse ($ response , $ path , $ data );
86+ return $ this ->processResponse ($ response , ' POST ' , $ path , $ data );
8787 }
8888
89- /** @param array<mixed, mixed> $data */
89+ /** @param array<mixed, mixed> $data */
9090 public function postBulk (string $ path , array $ data = []): BulkRequest
9191 {
9292 $ response = $ this ->magento ->postBulk ($ path , $ data );
9393
94- return $ this ->processResponse ($ response , $ path , $ data , true );
94+ return $ this ->processResponse ($ response , ' POST ' , $ path , $ data , true );
9595 }
9696
97- /** @param array<mixed, mixed> $data */
97+ /** @param array<mixed, mixed> $data */
9898 public function put (string $ path , array $ data = []): BulkRequest
9999 {
100100 $ response = $ this ->magento ->putAsync ($ path , $ data );
101101
102- return $ this ->processResponse ($ response , $ path , $ data );
102+ return $ this ->processResponse ($ response , ' PUT ' , $ path , $ data );
103103 }
104104
105- /** @param array<mixed, mixed> $data */
105+ /** @param array<mixed, mixed> $data */
106106 public function putBulk (string $ path , array $ data = []): BulkRequest
107107 {
108108 $ response = $ this ->magento ->putBulk ($ path , $ data );
109109
110- return $ this ->processResponse ($ response , $ path , $ data , true );
110+ return $ this ->processResponse ($ response , ' PUT ' , $ path , $ data , true );
111111 }
112112
113- /** @param array<mixed, mixed> $data */
113+ /** @param array<mixed, mixed> $data */
114114 public function delete (string $ path , array $ data = []): BulkRequest
115115 {
116116 $ response = $ this ->magento ->deleteAsync ($ path , $ data );
117117
118- return $ this ->processResponse ($ response , $ path , $ data );
118+ return $ this ->processResponse ($ response , ' DELETE ' , $ path , $ data );
119119 }
120120
121- /** @param array<mixed, mixed> $data */
121+ /** @param array<mixed, mixed> $data */
122122 public function deleteBulk (string $ path , array $ data = []): BulkRequest
123123 {
124124 $ response = $ this ->magento ->deleteBulk ($ path , $ data );
125125
126- return $ this ->processResponse ($ response , $ path , $ data , true );
126+ return $ this ->processResponse ($ response , ' DELETE ' , $ path , $ data , true );
127127 }
128128
129- /** @param array<mixed, mixed> $data */
129+ /** @param array<mixed, mixed> $data */
130130 public function processResponse (
131131 Response $ response ,
132+ string $ method ,
132133 string $ path ,
133134 array $ data = [],
134- bool $ bulk = false
135+ bool $ bulk = false ,
135136 ): BulkRequest {
136137 $ response ->throw ();
137138
@@ -141,16 +142,17 @@ public function processResponse(
141142 /** @var array<int, array<string, mixed>> $requestItems */
142143 $ requestItems = $ response ->json ('request_items ' , []);
143144
144- $ response = $ response ->json (null , []);
145+ $ responseData = $ response ->json (null , []);
145146
146147 /** @var BulkRequest $bulkRequest */
147148 $ bulkRequest = BulkRequest::query ()->create ([
148149 'magento_connection ' => $ this ->magento ->connection ,
149150 'store_code ' => $ this ->magento ->storeCode ?? 'all ' ,
151+ 'method ' => $ method ,
150152 'path ' => $ path ,
151153 'bulk_uuid ' => $ bulkUuid ,
152154 'request ' => $ data ,
153- 'response ' => $ response ,
155+ 'response ' => $ responseData ,
154156 ]);
155157
156158 foreach ($ requestItems as $ index => $ requestItem ) {
0 commit comments