@@ -25,7 +25,7 @@ export const guzzle: Client<GuzzleOptions> = {
2525 key : 'guzzle' ,
2626 title : 'Guzzle v7' ,
2727 link : 'http://docs.guzzlephp.org/en/stable/' ,
28- description : 'PHP with guzzle v7'
28+ description : 'PHP with guzzle v7' ,
2929 } ,
3030 convert : ( { postData, fullUrl, method, cookies, headersObj } , options ) => {
3131 const opts = {
@@ -37,7 +37,11 @@ export const guzzle: Client<GuzzleOptions> = {
3737 } ;
3838
3939 const { push, blank, join } = new CodeBuilder ( { indent : opts . indent } ) ;
40- const { code : requestCode , push : requestPush , join : requestJoin } = new CodeBuilder ( { indent : opts . indent } ) ;
40+ const {
41+ code : requestCode ,
42+ push : requestPush ,
43+ join : requestJoin ,
44+ } = new CodeBuilder ( { indent : opts . indent } ) ;
4145
4246 if ( ! opts . noTags ) {
4347 push ( opts . shortTags ? '<?' : '<?php' ) ;
@@ -47,10 +51,14 @@ export const guzzle: Client<GuzzleOptions> = {
4751 switch ( postData . mimeType ) {
4852 case 'application/x-www-form-urlencoded' :
4953 requestPush (
50- `'form_params' => ${ convertType ( postData . paramsObj , opts . indent + opts . indent , opts . indent ) } ,` ,
54+ `'form_params' => ${ convertType (
55+ postData . paramsObj ,
56+ opts . indent + opts . indent ,
57+ opts . indent ,
58+ ) } ,`,
5159 1 ,
52- )
53- break
60+ ) ;
61+ break ;
5462
5563 case 'multipart/form-data' : {
5664 type MultipartField = {
@@ -60,36 +68,36 @@ export const guzzle: Client<GuzzleOptions> = {
6068 headers ?: Record < string , string > ;
6169 } ;
6270
63- const fields : MultipartField [ ] = [ ]
71+ const fields : MultipartField [ ] = [ ] ;
6472
6573 if ( postData . params ) {
6674 postData . params . forEach ( function ( param ) {
6775 if ( param . fileName ) {
6876 const field : MultipartField = {
6977 name : param . name ,
7078 filename : param . fileName ,
71- contents : param . value
72- }
79+ contents : param . value ,
80+ } ;
7381
7482 if ( param . contentType ) {
75- field . headers = { 'Content-Type' : param . contentType }
83+ field . headers = { 'Content-Type' : param . contentType } ;
7684 }
7785
78- fields . push ( field )
86+ fields . push ( field ) ;
7987 } else if ( param . value ) {
8088 fields . push ( {
8189 name : param . name ,
82- contents : param . value
83- } )
90+ contents : param . value ,
91+ } ) ;
8492 }
85- } )
93+ } ) ;
8694 }
8795
8896 if ( fields . length ) {
8997 requestPush (
9098 `'multipart' => ${ convertType ( fields , opts . indent + opts . indent , opts . indent ) } ` ,
9199 1 ,
92- )
100+ ) ;
93101 }
94102
95103 // Guzzle adds its own boundary for multipart requests.
@@ -101,22 +109,26 @@ export const guzzle: Client<GuzzleOptions> = {
101109 }
102110 }
103111 }
104- break
112+ break ;
105113 }
106114
107115 default :
108116 if ( postData . text ) {
109- requestPush ( `'body' => ${ convertType ( postData . text ) } ,` , 1 )
117+ requestPush ( `'body' => ${ convertType ( postData . text ) } ,` , 1 ) ;
110118 }
111119 }
112120
113121 // construct headers
114- const headers = Object . keys ( headersObj ) . sort ( ) . map ( function ( key ) {
115- return `${ opts . indent } ${ opts . indent } '${ key } ' => '${ headersObj [ key ] } ',` ;
116- } )
122+ const headers = Object . keys ( headersObj )
123+ . sort ( )
124+ . map ( function ( key ) {
125+ return `${ opts . indent } ${ opts . indent } '${ key } ' => '${ headersObj [ key ] } ',` ;
126+ } ) ;
117127
118128 // construct cookies
119- const cookieString = cookies . map ( cookie => `${ encodeURIComponent ( cookie . name ) } =${ encodeURIComponent ( cookie . value ) } ` ) . join ( '; ' )
129+ const cookieString = cookies
130+ . map ( cookie => `${ encodeURIComponent ( cookie . name ) } =${ encodeURIComponent ( cookie . value ) } ` )
131+ . join ( '; ' ) ;
120132 if ( cookieString . length ) {
121133 headers . push ( `${ opts . indent } ${ opts . indent } 'cookie' => '${ cookieString } ',` ) ;
122134 }
0 commit comments