laravel-request 1.2.25 → 1.2.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@types/Api.d.ts +6 -0
- package/package.json +1 -1
- package/src/Api.js +46 -0
package/@types/Api.d.ts
CHANGED
|
@@ -12,18 +12,24 @@ declare module 'laravel-request' {
|
|
|
12
12
|
|
|
13
13
|
static putArg(controller: string, action: string, arg: any, data?: Record<string, any>): ApiRequest;
|
|
14
14
|
|
|
15
|
+
static patchArg(controller: string, action: string, arg: any, data?: Record<string, any>): ApiRequest;
|
|
16
|
+
|
|
15
17
|
static getUrl(url: string, data?: Record<string, any>): ApiRequest;
|
|
16
18
|
|
|
17
19
|
static postUrl(url: string, data?: Record<string, any>): ApiRequest;
|
|
18
20
|
|
|
19
21
|
static putUrl(url: string, data?: Record<string, any>): ApiRequest;
|
|
20
22
|
|
|
23
|
+
static patchUrl(url: string, data?: Record<string, any>): ApiRequest;
|
|
24
|
+
|
|
21
25
|
static get(controller: string, action: string, data?: Record<string, any>): ApiRequest;
|
|
22
26
|
|
|
23
27
|
static post(controller: string, action: string, data?: Record<string, any>): ApiRequest;
|
|
24
28
|
|
|
25
29
|
static put(controller: string, action: string, data?: Record<string, any>): ApiRequest;
|
|
26
30
|
|
|
31
|
+
static patch(controller: string, action: string, data?: Record<string, any>): ApiRequest;
|
|
32
|
+
|
|
27
33
|
static delete(controller: string, action: string, id: any, data?: Record<string, any>): ApiRequest;
|
|
28
34
|
|
|
29
35
|
static encodeQueryString(params: Record<string, any>): string;
|
package/package.json
CHANGED
package/src/Api.js
CHANGED
|
@@ -91,6 +91,18 @@ export default class Api {
|
|
|
91
91
|
return this.put(controller, action, data).addArg(arg);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
/**
|
|
95
|
+
*
|
|
96
|
+
* @param controller
|
|
97
|
+
* @param action
|
|
98
|
+
* @param arg
|
|
99
|
+
* @param data
|
|
100
|
+
* @return {ApiRequest}
|
|
101
|
+
*/
|
|
102
|
+
static patchArg(controller, action, arg, data = {}) {
|
|
103
|
+
return this.patch(controller, action, data).addArg(arg);
|
|
104
|
+
}
|
|
105
|
+
|
|
94
106
|
/**
|
|
95
107
|
*
|
|
96
108
|
* @param url
|
|
@@ -124,6 +136,28 @@ export default class Api {
|
|
|
124
136
|
return (new this.requestClass('', '', data, 'PUT')).setUrl(url);
|
|
125
137
|
}
|
|
126
138
|
|
|
139
|
+
/**
|
|
140
|
+
*
|
|
141
|
+
* @param url
|
|
142
|
+
* @param data
|
|
143
|
+
* @return {ApiRequest}
|
|
144
|
+
*/
|
|
145
|
+
static patchUrl(url, data = {})
|
|
146
|
+
{
|
|
147
|
+
return (new this.requestClass('', '', data, 'PATCH')).setUrl(url);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
*
|
|
152
|
+
* @param url
|
|
153
|
+
* @param data
|
|
154
|
+
* @return {ApiRequest}
|
|
155
|
+
*/
|
|
156
|
+
static patchUrl(url, data = {})
|
|
157
|
+
{
|
|
158
|
+
return (new this.requestClass('', '', data, 'PATCH')).setUrl(url);
|
|
159
|
+
}
|
|
160
|
+
|
|
127
161
|
/**
|
|
128
162
|
*
|
|
129
163
|
* @param controller
|
|
@@ -155,6 +189,17 @@ export default class Api {
|
|
|
155
189
|
return new this.requestClass(controller, action, data, 'PUT');
|
|
156
190
|
}
|
|
157
191
|
|
|
192
|
+
/**
|
|
193
|
+
*
|
|
194
|
+
* @param controller
|
|
195
|
+
* @param action
|
|
196
|
+
* @param data
|
|
197
|
+
* @returns {ApiRequest}
|
|
198
|
+
*/
|
|
199
|
+
static patch(controller, action, data = {}) {
|
|
200
|
+
return new this.requestClass(controller, action, data, 'PATCH');
|
|
201
|
+
}
|
|
202
|
+
|
|
158
203
|
/**
|
|
159
204
|
*
|
|
160
205
|
* @param controller
|
|
@@ -257,6 +302,7 @@ export default class Api {
|
|
|
257
302
|
} else {
|
|
258
303
|
// Неизвестный формат
|
|
259
304
|
console.warn(`Unsupported Content-Type: ${contentType}`);
|
|
305
|
+
console.warn(response.data);
|
|
260
306
|
return response.data; // Возвращаем данные "как есть"
|
|
261
307
|
}
|
|
262
308
|
} catch (error) {
|