-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
83 lines (77 loc) · 3.01 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import adapter from './vendor/axiosApiAdapter';
import ApiInterface from "./vendor/ApiInterface";
import WrongApiImplementationException from "./exceptions/WrongApiImplementationException";
if (!(adapter instanceof ApiInterface)) {
throw new WrongApiImplementationException();
}
export default {
/**
* Use method GET to connect to a server
* Retrieve a resource or a collection.
* `GET` method and query parameters should not alter the state.
*
* @param {String} path
* @param {Function} successHandler
* @param {Function} errorHandler=null
* @param {Object} params={}
* @param {Object} config={}
*/
get: (path, successHandler, errorHandler = null, params = {}, config = {}) =>
adapter.get(path, successHandler, errorHandler, params, config),
/**
* Use method POST to connect to a server
* Create a resource.
* The `POST` method can be used to update a resource but it’s not recommended.
*
* @param {String} path
* @param {Object} data
* @param {Function} successHandler
* @param {Function} errorHandler=null
* @param {Object} config={}
*/
post: (path, data, successHandler, errorHandler = null, config = {}) =>
adapter.post(path, data, successHandler, errorHandler, config),
/**
* Use method PATCH to connect to a server
* Update a resource or a collection.
* A resource can be updated by sending a `PATCH` request to the URL that represents the resource.
*
* @param {String} path
* @param {Object} data
* @param {Function} successHandler
* @param {Function} errorHandler=null
* @param {Object} config={}
*/
patch: (path, data, successHandler, errorHandler = null, config = {}) =>
adapter.patch(path, data, successHandler, errorHandler, config),
/**
* Use method DELETE to connect to a server
* Remove a resource or a collection.
*
* @param {String} path
* @param {Function} successHandler
* @param {Function} errorHandler=null
* @param {Object} data={}
* @param {Object} config={}
*/
delete: (path, successHandler, errorHandler = null, data = {}, config = {}) =>
adapter.delete(path, data, successHandler, errorHandler, config),
/**
* Use method PUT to connect to a server
* Replace a resource or a collection.
* The `PUT` method can also be used to create a resource
* if we can choose the id in advance for example.
* The only constraint with the PUT method is
* that it must be idempotent. I.e. the number of
* times we send the same `PUT` request should not have
* any impact on the result.
*
* @param {String} path
* @param {Object} data
* @param {Function} successHandler
* @param {Function} errorHandler=null
* @param {Object} config={}
*/
put: (path, data, successHandler, errorHandler = null, config = {}) =>
adapter.put(path, data, successHandler, errorHandler, config),
};