@veritree/services 1.0.0 → 1.3.0

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 CHANGED
@@ -1,3 +1,4 @@
1
+ import { BulkUploads } from './src/endpoints/bulk-uploads';
1
2
  import { Countries } from './src/endpoints/countries';
2
3
  import { FieldUpdates } from './src/endpoints/field-updates';
3
4
  import { FieldUpdateVerifications } from './src/endpoints/field-udpate-verifications';
@@ -20,6 +21,7 @@ import { TreeOrders } from './src/endpoints/trees-orders';
20
21
  import { User } from './src/endpoints/user';
21
22
 
22
23
  export {
24
+ BulkUploads,
23
25
  Countries,
24
26
  FieldUpdates,
25
27
  FieldUpdateVerifications,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veritree/services",
3
- "version": "1.0.0",
3
+ "version": "1.3.0",
4
4
  "description": "A collection of javascript functions/services to talk to veritree API",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -0,0 +1,5 @@
1
+ import Api from "../helpers/api";
2
+
3
+ const resource = "bulk-uploads";
4
+
5
+ export const BulkUploads = new Api(resource);
@@ -1,5 +1,14 @@
1
1
  import Api from "../helpers/api";
2
+ import Relations from "../helpers/relations";
3
+ class ImagesApi extends Api {
4
+ constructor(resource) {
5
+ super(resource);
6
+ this.resource = "images";
7
+ }
2
8
 
3
- const resource = "images";
9
+ relation(prefix, id) {
10
+ return Relations(this, prefix, id);
11
+ }
12
+ }
4
13
 
5
- export const Images = new Api(resource);
14
+ export const Images = new ImagesApi();
@@ -29,8 +29,8 @@ class SponsorsApi extends Api {
29
29
  return await this.get(url);
30
30
  }
31
31
 
32
- async totalPlantingStats() {
33
- const url = `${this.getUrl()}/total-planting-stats`;
32
+ async totalPlantingStats(args) {
33
+ const url = `${this.getUrl()}/total-planting-stats${this.getUrlParams(args)}`;
34
34
  return await this.get(url);
35
35
  }
36
36
 
@@ -7,8 +7,8 @@ class TagsApi extends Api {
7
7
  this.resource = "tags";
8
8
  }
9
9
 
10
- relation(prefix, id, args) {
11
- return Relations(this, prefix, id, args);
10
+ relation(prefix, id) {
11
+ return Relations(this, prefix, id);
12
12
  }
13
13
  }
14
14
 
@@ -1,32 +1,32 @@
1
- const Relations = (api, prefix, id, args) => {
1
+ const Relations = (api, prefix, id) => {
2
2
  let url = `${api.baseUrl}/${prefix}/${id}/${api.resource}`;
3
-
4
- const all = async () => {
3
+
4
+ const all = async (args) => {
5
5
  url = `${url}${api.getUrlParams(args)}`;
6
6
  return await api.get(url);
7
- }
7
+ };
8
8
 
9
- const single = async(tagId) => {
9
+ const single = async (tagId, args) => {
10
10
  url = `${url}/${tagId}${api.getUrlParams(args)}`;
11
11
  return await api.get(url);
12
- }
12
+ };
13
13
 
14
- const attach = async(tagId, data) => {
14
+ const attach = async (tagId, data, args) => {
15
15
  url = `${url}/${tagId}/attach${api.getUrlParams(args)}`;
16
16
  return await api.post(url, data);
17
- }
17
+ };
18
18
 
19
- const detach = async(tagId, data) => {
19
+ const detach = async (tagId, args) => {
20
20
  url = `${url}/${tagId}/detach${api.getUrlParams(args)}`;
21
- return await api.delete(url, data);
22
- }
21
+ return await api.post(url, null, "delete");
22
+ };
23
23
 
24
24
  return {
25
25
  all,
26
26
  single,
27
27
  attach,
28
- detach
29
- }
30
- }
28
+ detach,
29
+ };
30
+ };
31
31
 
32
- export default Relations;
32
+ export default Relations;