@@ -99,14 +99,18 @@ public function delete($url, $payload)
9999 * Maps $files array to object for removal
100100 * @param Array $files full URLs to paths for removal
101101 */
102- public function purge_files ($ fileList )
102+ public function purge_files ($ fileList, $ opts = [] )
103103 {
104104 $ stack_id = $ this ->creds ["stack_id " ];
105105
106106 $ files = [];
107107
108+ $ opts = array_merge ([
109+ "recursive " => true ,
110+ ], $ opts );
111+
108112 foreach ($ fileList as $ file ) {
109- $ files [] = ["url " => $ file ];
113+ $ files [] = array_merge ( $ opts , ["url " => $ file ]) ;
110114 }
111115
112116 $ purge_id = $ this ->post ("cdn/v1/stacks/ {$ stack_id }/purge " , ["json " => [
@@ -198,16 +202,23 @@ public function request($opts = [])
198202 try {
199203 /** Fires the request */
200204 $ res = $ this ->client ->request ($ method , $ url , $ payload );
201- // $response = json_decode($res->getBody()->getContents());
202205 } catch (\Exception $ e ) {
203206 $ success = false ;
204207 $ res = $ e ->getResponse ();
208+ if ($ this ->debug ) {
209+ error_log ("Request failed " );
210+ error_log (print_r ($ res ->getBody ()->getContents (), true ));
211+ }
205212 }
206213
207214 try {
208215 $ response = json_decode ($ res ->getBody ()->getContents ());
209216 } catch (\Exception $ e ) {
210217 $ response = $ res ->getBody ()->getContents ();
218+ if ($ this ->debug ) {
219+ error_log ("JSON decode failed " );
220+ error_log (print_r ($ response , true ));
221+ }
211222 }
212223 return $ response ;
213224 }
0 commit comments