@veritree/services 2.5.8 → 2.8.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veritree/services",
3
- "version": "2.5.8",
3
+ "version": "2.8.0",
4
4
  "description": "A collection of javascript functions/services to talk to veritree API",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -9,7 +9,9 @@ class SponsorsApi extends Api {
9
9
  async map() {
10
10
  this.setOrg();
11
11
 
12
- if(!this.orgId) throw new Error('No org id provided');
12
+ if (!this.orgId) {
13
+ throw new Error('No org id provided');
14
+ }
13
15
 
14
16
  const url = `${this.getUrl()}/${this.orgId}/map-data`;
15
17
  return await this.get(url);
@@ -18,7 +20,9 @@ class SponsorsApi extends Api {
18
20
  async profile() {
19
21
  this.setOrg();
20
22
 
21
- if(!this.orgId) throw new Error('No org id provided');
23
+ if (!this.orgId) {
24
+ throw new Error('No org id provided');
25
+ }
22
26
 
23
27
  const url = `${this.getUrl()}/${this.orgId}/profile`;
24
28
  return await this.get(url);
@@ -32,8 +36,19 @@ class SponsorsApi extends Api {
32
36
  async totalPlantingStats(args) {
33
37
  const url = `${this.getUrl()}/total-planting-stats${this.getUrlParams(args)}`;
34
38
  return await this.get(url);
35
- }
39
+ }
40
+
41
+ async cmsToken(args) {
42
+ const urlParams = this.getUrlParams(args);
43
+ const url = `${this.getUrl()}/${this.orgId}/cms/token${urlParams}`;
44
+ return await this.get(url);
45
+ }
36
46
 
47
+ async cmsImageUploadUrl(args) {
48
+ const urlParams = this.getUrlParams(args);
49
+ const url = `${this.getUrl()}/${this.orgId}/cms/image-upload-url${urlParams}`;
50
+ return await this.get(url);
51
+ }
37
52
  }
38
53
 
39
54
  export const Sponsors = new SponsorsApi();
@@ -1,5 +1,21 @@
1
- import Api from "../helpers/api";
1
+ import Api from '../helpers/api';
2
2
 
3
- const resource = "subsites";
3
+ class SubsitesApi extends Api {
4
+ constructor(resource) {
5
+ super(resource);
6
+ this.resource = 'subsites';
7
+ }
4
8
 
5
- export const Subsites = new Api(resource);
9
+ locationsByOrg() {
10
+ const get = async (args) => {
11
+ const url = `${this.getUrl()}/locations-by-org${this.getUrlParams(args)}`;
12
+ return await this.get(url);
13
+ };
14
+
15
+ return {
16
+ get,
17
+ };
18
+ }
19
+ }
20
+
21
+ export const Subsites = new SubsitesApi();
@@ -6,10 +6,22 @@ class UserApi extends Api {
6
6
  this.resource = 'me';
7
7
  }
8
8
 
9
- async me() {
10
- const url = `${this.getUrl()}${this.getUrlParams()}`;
11
- return await this.get(url);
9
+ me() {
10
+ const url = this.getUrl();
11
+
12
+ const get = async () => {
13
+ return await this.get(url);
14
+ };
15
+
16
+ const update = async (data) => {
17
+ return await this.post(url, data, 'patch');
18
+ };
19
+
20
+ return {
21
+ get,
22
+ update,
23
+ };
12
24
  }
13
25
  }
14
26
 
15
- export const User = new UserApi();
27
+ export const User = new UserApi();