@veritree/services 1.0.0-10 → 1.0.0-11
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/index.js +2 -0
- package/package.json +1 -1
- package/src/endpoints/notes.js +2 -4
- package/src/endpoints/tags.js +13 -0
- package/src/helpers/relations.js +32 -0
package/index.js
CHANGED
|
@@ -15,6 +15,7 @@ import { Stats } from './src/endpoints/stats';
|
|
|
15
15
|
import { Subdomains } from './src/endpoints/subdomains';
|
|
16
16
|
import { Subsites } from './src/endpoints/subsites';
|
|
17
17
|
import { SubsiteTypes } from './src/endpoints/subsite-types';
|
|
18
|
+
import { Tags } from './src/endpoints/tags';
|
|
18
19
|
import { TreeOrders } from './src/endpoints/trees-orders';
|
|
19
20
|
import { User } from './src/endpoints/user';
|
|
20
21
|
|
|
@@ -36,6 +37,7 @@ export {
|
|
|
36
37
|
Subdomains,
|
|
37
38
|
Subsites,
|
|
38
39
|
SubsiteTypes,
|
|
40
|
+
Tags,
|
|
39
41
|
TreeOrders,
|
|
40
42
|
User
|
|
41
43
|
}
|
package/package.json
CHANGED
package/src/endpoints/notes.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Api from "../helpers/api";
|
|
2
|
+
import Relations from "../helpers/relations";
|
|
2
3
|
|
|
3
4
|
class NotesApi extends Api {
|
|
4
5
|
constructor(resource) {
|
|
@@ -6,10 +7,7 @@ class NotesApi extends Api {
|
|
|
6
7
|
this.resource = "notes";
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
const url = `${this.baseUrl}/${prefix}/${id}/${this.resource}${this.getUrlParams(args)}`;
|
|
11
|
-
return await this.unWrap(url);
|
|
12
|
-
}
|
|
10
|
+
relation = (prefix, id, args) => new Relations(this, prefix, id, args);
|
|
13
11
|
}
|
|
14
12
|
|
|
15
13
|
export const Notes = new NotesApi();
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Api from "../helpers/api";
|
|
2
|
+
import Relations from "../helpers/relations";
|
|
3
|
+
|
|
4
|
+
class TagsApi extends Api {
|
|
5
|
+
constructor(resource) {
|
|
6
|
+
super(resource);
|
|
7
|
+
this.resource = "tags";
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
relation = (prefix, id, args) => new Relations(this, prefix, id, args);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const Tags = new TagsApi();
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const Relations = (api, prefix, id, args) => {
|
|
2
|
+
let url = `${api.baseUrl}/${prefix}/${id}/${api.resource}`;
|
|
3
|
+
|
|
4
|
+
const all = async () => {
|
|
5
|
+
url = `${url}${api.getUrlParams(args)}`;
|
|
6
|
+
return await api.unWrap(url);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const single = async(tagId) => {
|
|
10
|
+
url = `${url}/${tagId}${api.getUrlParams(args)}`;
|
|
11
|
+
return await api.unWrap(url);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const attach = async(tagId, data) => {
|
|
15
|
+
url = `${url}/${tagId}/attach${api.getUrlParams(args)}`;
|
|
16
|
+
return await api.post(url, data);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const detach = async(tagId, data) => {
|
|
20
|
+
url = `${url}/${tagId}/detach${api.getUrlParams(args)}`;
|
|
21
|
+
return await api.delete(url, data);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
all,
|
|
26
|
+
single,
|
|
27
|
+
attach,
|
|
28
|
+
detach
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default Relations;
|