You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* @param {string} options.baseURL Set the API endpoint (default `https://kitsu.io/api/edge`)
10
-
* @param {Object} options.headers Additional headers to send with requests
10
+
* @param {Object} options.headers Additional headers to send with the requests
11
11
* @param {boolean} options.camelCaseTypes If true, the `type` value will be camelCased, e.g `library-entries` and `library_entries` become `libraryEntries` (default `true`)
12
12
* @param {string} options.resourceCase `kebab`, `snake` or `none`. If `kebab`, `/libraryEntries` will become `/library-entries`. If `snake`, `/libraryEntries` will become `/library_entries`, If `none`, `/libraryEntries` will be unchanged (default `kebab`)
13
13
* @param {boolean} options.pluralize If `true`, `/user` will become `/users` in the URL request and `type` will be pluralized in POST, PATCH and DELETE requests (default `true`)
* @param {string} params.sort Sort dataset by one or more comma separated attributes (prepend `-` for descending order) - [JSON:API Sorting](http://jsonapi.org/format/#fetching-sorting)
126
126
* @param {string} params.include Include relationship data - [JSON:API Includes](http://jsonapi.org/format/#fetching-includes)
127
-
* @param {Object} headers Additional headers to send with request
127
+
* @param {Object} headers Additional headers to send with the request
128
128
* @returns {Object} JSON-parsed response
129
129
* @example <caption>Getting a resource with JSON:API parameters</caption>
130
130
* api.get('users', {
@@ -208,7 +208,7 @@ export default class Kitsu {
208
208
* @memberof Kitsu
209
209
* @param {string} model Model to update data in
210
210
* @param {Object} body Data to send in the request
211
-
* @param {Object} headers Additional headers to send with request
211
+
* @param {Object} headers Additional headers to send with the request
212
212
* @returns {Object} JSON-parsed response
213
213
* @example <caption>Update a post</caption>
214
214
* api.update('posts', {
@@ -249,7 +249,7 @@ export default class Kitsu {
249
249
* @memberof Kitsu
250
250
* @param {string} model Model to create a resource under
251
251
* @param {Object} body Data to send in the request
252
-
* @param {Object} headers Additional headers to send with request
252
+
* @param {Object} headers Additional headers to send with the request
253
253
* @returns {Object} JSON-parsed response
254
254
* @example <caption>Create a post on a user's profile feed</caption>
255
255
* api.create('posts', {
@@ -296,7 +296,7 @@ export default class Kitsu {
296
296
* @memberof Kitsu
297
297
* @param {string} model Model to remove data from
298
298
* @param {string|number|Array} id Resource ID to remove. Pass an array of IDs to delete multiple resources (Bulk Extension)
299
-
* @param {Object} headers Additional headers to send with request
299
+
* @param {Object} headers Additional headers to send with the request
300
300
* @returns {Object} JSON-parsed response
301
301
* @example <caption>Remove a single resource</caption>
302
302
* api.delete('posts', 123)
@@ -343,7 +343,7 @@ export default class Kitsu {
343
343
* @param {Object} params JSON-API request queries
344
344
* @param {Object} params.fields Return a sparse fieldset with only the included attributes/relationships - [JSON:API Sparse Fieldsets](http://jsonapi.org/format/#fetching-sparse-fieldsets)
345
345
* @param {string} params.include Include relationship data - [JSON:API Includes](http://jsonapi.org/format/#fetching-includes)
346
-
* @param {Object} headers Additional headers to send with request
346
+
* @param {Object} headers Additional headers to send with the request
347
347
* @returns {Object} JSON-parsed response
348
348
* @example <caption>Get the authenticated user's resource</caption>
349
349
* api.self()
@@ -362,4 +362,83 @@ export default class Kitsu {
362
362
throwerror(E)
363
363
}
364
364
}
365
+
366
+
/**
367
+
* Send arbitrary requests
368
+
*
369
+
* **Note** Planned changes to the `get`, `patch`, `post` and `delete` methods in a future major release may make this method redundent. See https://github.com/wopian/kitsu/issues/415 for details.
370
+
*
371
+
* @memberof Kitsu
372
+
* @param {Object|Array} config.body Data to send in the request
373
+
* @param {string} config.method Request method - `GET`, `PATCH`, `POST` or `DELETE` (defaults to `GET`, case-insensitive)
* @param {number} config.params.page.limit Number of resources to return in request (Max `20` for Kitsu.io except on `libraryEntries` which has a max of `500`)
377
+
* @param {number} config.params.page.offset Number of resources to offset the dataset by
378
+
* @param {Object} config.params.fields Return a sparse fieldset with only the included attributes/relationships - [JSON:API Sparse Fieldsets](http://jsonapi.org/format/#fetching-sparse-fieldsets)
* @param {string} config.params.sort Sort dataset by one or more comma separated attributes (prepend `-` for descending order) - [JSON:API Sorting](http://jsonapi.org/format/#fetching-sorting)
381
+
* @param {string} config.params.include Include relationship data - [JSON:API Includes](http://jsonapi.org/format/#fetching-includes)
382
+
* @param {string} config.type The resource type
383
+
* @param {string} config.url The URL path of the resource
384
+
* @param {Object} headers Additional headers to send with the request
385
+
* @returns {Object} JSON-parsed response
386
+
* @example <caption>Raw GET request</caption>
387
+
* api.request({
388
+
* url: 'anime/1/mappings',
389
+
* type: 'mappings',
390
+
* params: { filter: { externalSite: 'aozora' }}
391
+
* })
392
+
* @example <caption>Raw PATCH request</caption>
393
+
* api.request({
394
+
* method: 'PATCH',
395
+
* url: 'anime',
396
+
* type: 'anime',
397
+
* body: { id: '1', subtype: 'tv' }
398
+
* })
399
+
* @example <caption>Raw POST request</caption>
400
+
* api.request({
401
+
* method: 'PATCH',
402
+
* url: 'anime',
403
+
* type: 'anime',
404
+
* body: { subtype: 'tv' }
405
+
* })
406
+
* @example <caption>Raw DELETE request</caption>
407
+
* api.request({
408
+
* method: 'DELETE',
409
+
* url: 'anime/1',
410
+
* type: 'anime',
411
+
* body: { id: '1' }
412
+
* })
413
+
* @example <caption>Bulk Extension support (`PATCH`, `POST` & `DELETE`)</caption>
0 commit comments