@@ -43,103 +43,34 @@ class BaseProxy {
4343 return BaseProxy . $parsedQs
4444 }
4545
46- /**
47- * Get all or by pagination
48- */
4946 all < T > ( ) {
5047 return this . submit < T > ( 'get' )
5148 }
5249
53- /**
54- * Alternative of all method
55- */
56- getMany < T > ( ) {
57- return this . all < T > ( )
58- }
59-
60- /**
61- * Find a record by id
62- * @param {string|number } id
63- */
6450 find < T > ( id : number | string ) {
6551 return this . submit < T > ( 'get' , id )
6652 }
6753
68- /**
69- * Alternative of find method
70- * @param {string | number } id
71- */
72- getOne < T > ( id : number | string ) {
73- return this . find < T > ( id )
74- }
75-
76- /**
77- * Create record
78- * @param {Object|string } payload
79- * @param {AxiosRequestConfig } config
80- */
8154 post < T > ( payload : any , config ?: AxiosRequestConfig ) {
8255 return this . submit < T > ( 'post' , '' , payload , config )
8356 }
8457
85- /**
86- * Alternative of post method
87- * @param payload
88- * @param {AxiosRequestConfig } config
89- */
9058 store < T > ( payload : any , config ?: AxiosRequestConfig ) {
9159 return this . post < T > ( payload , config )
9260 }
9361
94- /**
95- * Alternative of store method
96- * @param payload
97- * @param {AxiosRequestConfig } config
98- */
9962 create < T > ( payload : any , config ?: AxiosRequestConfig ) {
10063 return this . store < T > ( payload , config )
10164 }
10265
103- /**
104- * Create many items
105- * @param {Object } payload
106- */
107- createMany < T > ( payload : T ) {
108- return this . submit < T > ( 'post' , 'bulk' , payload )
109- }
110-
111- /**
112- * Update record by id using PUT method
113- * @param {string|number } id
114- * @param {Object|string } payload
115- */
11666 put < T > ( id : string | number , payload : any ) {
11767 return this . submit < T > ( 'put' , `/${ id } ` , payload )
11868 }
11969
120- /**
121- * Update record without ID parameter by using PUT method
122- * @param {Object|string } payload
123- */
12470 putWithoutId < T > ( payload : any ) {
12571 return this . submit < T > ( 'put' , '' , payload )
12672 }
12773
128- /**
129- * Alternative of put method
130- * @param {string|number } id
131- * @param {Object|string } payload
132- */
133- replace < T > ( id : string | number , payload : any ) {
134- return this . put < T > ( id , payload )
135- }
136-
137- /**
138- * This method helpful for laravel developer
139- * @param {string|number } id
140- * @param {Object } payload
141- * @param config
142- */
14374 putWithFile < T > (
14475 id : string | number ,
14576 payload : any ,
@@ -149,47 +80,35 @@ class BaseProxy {
14980 return this . submit < T > ( 'post' , `/${ id } ` , payload , config )
15081 }
15182
152- /**
153- * Update record by id
154- * @param id
155- * @param payload
156- */
15783 patch < T > ( id : string | number , payload : any ) {
15884 return this . submit < T > ( 'patch' , `/${ id } ` , payload )
15985 }
16086
161- /**
162- * Alternative of path method
163- * @param {string|number } id
164- * @param {Object|string } payload
165- */
16687 update < T > ( id : string | number , payload : any ) {
16788 return this . patch < T > ( id , payload )
16889 }
16990
170- /**
171- * Delete record by id
172- * @param {string|number } id
173- */
17491 delete < T > ( id : string | number ) {
17592 return this . submit < T > ( 'delete' , `/${ id } ` )
17693 }
17794
178- /**
179- * Alternative of delete method
180- * @param {string|number } id
181- */
18295 remove < T > ( id : string | number ) {
18396 return this . delete < T > ( id )
18497 }
18598
186- /**
187- * Main endpoint method to handle requests
188- * @param requestType
189- * @param {string } parameter
190- * @param {Object|string } form
191- * @param {AxiosRequestConfig } config
192- */
99+ submit < T = any > ( requestType : Method ) : Promise < T >
100+ submit < T = any > ( requestType : Method , parameter ?: string | number ) : Promise < T >
101+ submit < T = any > (
102+ requestType : Method ,
103+ parameter ?: string | number ,
104+ form ?: T ,
105+ ) : Promise < T >
106+ submit < T = any > (
107+ requestType : Method ,
108+ parameter ?: string | number ,
109+ form ?: T ,
110+ config ?: AxiosRequestConfig ,
111+ ) : Promise < T >
193112 submit < T = any > (
194113 requestType : Method ,
195114 parameter ?: string | number ,
@@ -260,22 +179,13 @@ class BaseProxy {
260179 return requestType
261180 }
262181
263- /**
264- * Set parameters by keys
265- * @param {Object } parameters
266- */
267182 setParameters ( parameters : Record < string , any > ) : this {
268183 Object . keys ( parameters ) . forEach ( ( key ) => {
269184 this . parameters [ key ] = parameters [ key ]
270185 } )
271186 return this
272187 }
273188
274- /**
275- * Set parameters by key
276- * @param {string } parameter
277- * @param {Object|string|Array } value
278- */
279189 setParameter ( parameter : string , value ?: any ) : this {
280190 if ( ! value ) {
281191 const options : IParseOptions = Object . assign ( { } , this . $parsedQs , {
@@ -290,10 +200,6 @@ class BaseProxy {
290200 return this
291201 }
292202
293- /**
294- * Remove parameters by keys
295- * @param {Array<Object>> } parameters
296- */
297203 removeParameters ( parameters = [ ] as any [ ] ) : this {
298204 if ( ! parameters . length ) {
299205 this . parameters = [ ]
@@ -305,27 +211,16 @@ class BaseProxy {
305211 return this
306212 }
307213
308- /**
309- * Remove parameters
310- * @param {string } parameter
311- */
312214 removeParameter ( parameter : string ) : this {
313215 delete this . parameters [ parameter ]
314216 return this
315217 }
316218
317- /**
318- * Fill errors on fails passed
319- * @param {Object } errors
320- */
321219 onFail ( errors : Record < string , any > ) {
322220 this . errors . fill ( errors )
323221 validator . fill ( errors )
324222 }
325223
326- /**
327- * Clean up errors and set processing
328- */
329224 beforeSubmit ( ) {
330225 if ( ! this . $http ) {
331226 throw new Error ( 'Vue Axios Http, No http library provided.' )
@@ -338,9 +233,6 @@ class BaseProxy {
338233 validator . successful = false
339234 }
340235
341- /**
342- * Clean up errors and set success on after request
343- */
344236 onSuccess ( ) {
345237 this . errors . processing = false
346238 this . errors . successful = true
0 commit comments