@@ -122,48 +122,125 @@ function addQueryParams(
122122async function getRequest < T > (
123123 accountId : number ,
124124 options : HttpOptions
125- ) : Promise < T > {
125+ ) : Promise < T > ;
126+ async function getRequest < T > (
127+ accountId : number ,
128+ options : HttpOptions ,
129+ withFullResponse : true
130+ ) : Promise < AxiosResponse < T > > ;
131+ async function getRequest < T > (
132+ accountId : number ,
133+ options : HttpOptions ,
134+ withFullResponse ?: true
135+ ) {
126136 const { params, ...rest } = options ;
127137 const axiosConfig = addQueryParams ( rest , params ) ;
128138 const configWithAuth = await withAuth ( accountId , axiosConfig ) ;
129- const { data } = await axios < T > ( configWithAuth ) ;
130- return data ;
139+
140+ const response = await axios < T > ( configWithAuth ) ;
141+
142+ if ( withFullResponse ) {
143+ return response ;
144+ }
145+
146+ return response . data ;
131147}
132148
133149async function postRequest < T > (
134150 accountId : number ,
135151 options : HttpOptions
136- ) : Promise < T > {
152+ ) : Promise < T > ;
153+ async function postRequest < T > (
154+ accountId : number ,
155+ options : HttpOptions ,
156+ withFullResponse : true
157+ ) : Promise < AxiosResponse < T > > ;
158+ async function postRequest (
159+ accountId : number ,
160+ options : HttpOptions ,
161+ withFullResponse ?: true
162+ ) {
137163 const configWithAuth = await withAuth ( accountId , options ) ;
138- const { data } = await axios ( { ...configWithAuth , method : 'post' } ) ;
139- return data ;
164+
165+ const response = await axios ( { ...configWithAuth , method : 'post' } ) ;
166+
167+ if ( withFullResponse ) {
168+ return response ;
169+ }
170+
171+ return response . data ;
140172}
141173
142174async function putRequest < T > (
143175 accountId : number ,
144176 options : HttpOptions
145- ) : Promise < T > {
177+ ) : Promise < T > ;
178+ async function putRequest < T > (
179+ accountId : number ,
180+ options : HttpOptions ,
181+ withFullResponse : true
182+ ) : Promise < AxiosResponse < T > > ;
183+ async function putRequest (
184+ accountId : number ,
185+ options : HttpOptions ,
186+ withFullResponse ?: true
187+ ) {
146188 const configWithAuth = await withAuth ( accountId , options ) ;
147- const { data } = await axios ( { ...configWithAuth , method : 'put' } ) ;
148- return data ;
189+ const response = await axios ( { ...configWithAuth , method : 'put' } ) ;
190+
191+ if ( withFullResponse ) {
192+ return response ;
193+ }
194+
195+ return response . data ;
149196}
150197
151198async function patchRequest < T > (
152199 accountId : number ,
153200 options : HttpOptions
154- ) : Promise < T > {
201+ ) : Promise < T > ;
202+ async function patchRequest < T > (
203+ accountId : number ,
204+ options : HttpOptions ,
205+ withFullResponse : true
206+ ) : Promise < AxiosResponse < T > > ;
207+ async function patchRequest (
208+ accountId : number ,
209+ options : HttpOptions ,
210+ withFullResponse ?: true
211+ ) {
155212 const configWithAuth = await withAuth ( accountId , options ) ;
156- const { data } = await axios ( { ...configWithAuth , method : 'patch' } ) ;
157- return data ;
213+ const response = await axios ( { ...configWithAuth , method : 'patch' } ) ;
214+
215+ if ( withFullResponse ) {
216+ return response ;
217+ }
218+
219+ return response . data ;
158220}
159221
160222async function deleteRequest < T > (
161223 accountId : number ,
162224 options : HttpOptions
163- ) : Promise < T > {
225+ ) : Promise < T > ;
226+ async function deleteRequest < T > (
227+ accountId : number ,
228+ options : HttpOptions ,
229+ withFullResponse : true
230+ ) : Promise < AxiosResponse < T > > ;
231+ async function deleteRequest (
232+ accountId : number ,
233+ options : HttpOptions ,
234+ withFullResponse = false
235+ ) {
164236 const configWithAuth = await withAuth ( accountId , options ) ;
165- const { data } = await axios ( { ...configWithAuth , method : 'delete' } ) ;
166- return data ;
237+ const response = await axios ( { ...configWithAuth , method : 'delete' } ) ;
238+
239+ if ( withFullResponse ) {
240+ return response ;
241+ }
242+
243+ return response . data ;
167244}
168245
169246function createGetRequestStream ( contentType : string ) {
0 commit comments