@veritree/services 2.18.1-2 → 2.18.1-4
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 +4 -2
- package/package.json +1 -1
- package/src/endpoints/resellers.js +37 -0
- package/src/endpoints/subsites.js +14 -8
- package/src/helpers/api.js +1 -1
package/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import { Images } from './src/endpoints/images';
|
|
|
10
10
|
import { Orgs } from './src/endpoints/orgs';
|
|
11
11
|
import { Notes } from './src/endpoints/notes';
|
|
12
12
|
import { Regions } from './src/endpoints/regions';
|
|
13
|
+
import { Resellers } from './src/endpoints/resellers';
|
|
13
14
|
import { SDGs } from './src/endpoints/sdgs';
|
|
14
15
|
import { Sponsors } from './src/endpoints/sponsors';
|
|
15
16
|
import { Standards } from './src/endpoints/standards';
|
|
@@ -26,7 +27,7 @@ import { FieldReports } from './src/endpoints/field-reports';
|
|
|
26
27
|
import { ExternalReports } from './src/endpoints/external-reports';
|
|
27
28
|
import { Evidence } from './src/endpoints/evidence';
|
|
28
29
|
import { Crumbs } from './src/endpoints/crumbs';
|
|
29
|
-
import { Verifications } from './src/endpoints/verifications';
|
|
30
|
+
import { Verifications } from './src/endpoints/verifications';
|
|
30
31
|
import { ImagesAggregated } from './src/endpoints/images-aggregated';
|
|
31
32
|
import { ssoToken } from './src/endpoints/sso-token';
|
|
32
33
|
|
|
@@ -43,6 +44,7 @@ export {
|
|
|
43
44
|
Orgs,
|
|
44
45
|
Notes,
|
|
45
46
|
Regions,
|
|
47
|
+
Resellers,
|
|
46
48
|
SDGs,
|
|
47
49
|
Sponsors,
|
|
48
50
|
Standards,
|
|
@@ -61,5 +63,5 @@ export {
|
|
|
61
63
|
Crumbs,
|
|
62
64
|
Verifications,
|
|
63
65
|
ImagesAggregated,
|
|
64
|
-
ssoToken
|
|
66
|
+
ssoToken,
|
|
65
67
|
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import Api from '../helpers/api';
|
|
2
|
+
|
|
3
|
+
class ResellersApi extends Api {
|
|
4
|
+
constructor(resource) {
|
|
5
|
+
super(resource);
|
|
6
|
+
this.resource = 'resellers';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
statsSold() {
|
|
10
|
+
const all = async () => {
|
|
11
|
+
const url = `${this.getUrl()}/1/pstats/sold?pretty=1`;
|
|
12
|
+
let response;
|
|
13
|
+
try {
|
|
14
|
+
response = await this.get(url);
|
|
15
|
+
} catch (e) {
|
|
16
|
+
console.log('error ', e);
|
|
17
|
+
}
|
|
18
|
+
return response;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
all,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
statsPurchased() {
|
|
27
|
+
const all = async () => {
|
|
28
|
+
const url = `${this.getUrl()}/1/pstats/purchased?pretty=1`;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
all,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const Resellers = new ResellersApi();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import Api from
|
|
2
|
-
import { createParamsStringFromArgs } from
|
|
1
|
+
import Api from "../helpers/api";
|
|
2
|
+
import { createParamsStringFromArgs } from "../utils/args";
|
|
3
3
|
|
|
4
4
|
class SubsitesApi extends Api {
|
|
5
5
|
constructor(resource) {
|
|
6
6
|
super(resource);
|
|
7
|
-
this.resource =
|
|
7
|
+
this.resource = "subsites";
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
locationsByOrg() {
|
|
@@ -33,7 +33,7 @@ class SubsitesApi extends Api {
|
|
|
33
33
|
|
|
34
34
|
const remove = async (subsite, indicator) => {
|
|
35
35
|
const url = `${this.getUrl()}/${subsite}/indicators/${indicator}`;
|
|
36
|
-
return await this.post(url, null,
|
|
36
|
+
return await this.post(url, null, "delete");
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
return {
|
|
@@ -54,16 +54,22 @@ class SubsitesApi extends Api {
|
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
evidence(subsiteId) {
|
|
57
|
+
evidence(subsiteId, params) {
|
|
58
|
+
const url = `${this.getUrl()}/${subsiteId}/evidence${this.getUrlParams(
|
|
59
|
+
params
|
|
60
|
+
)}`;
|
|
61
|
+
|
|
58
62
|
const all = async () => {
|
|
59
|
-
const url = `${this.getUrl()}/${subsiteId}/evidence${this.getUrlParams(
|
|
60
|
-
args
|
|
61
|
-
)}`;
|
|
62
63
|
return await this.get(url);
|
|
63
64
|
};
|
|
64
65
|
|
|
66
|
+
const attach = async (formData) => {
|
|
67
|
+
return await this.post(url, formData);
|
|
68
|
+
};
|
|
69
|
+
|
|
65
70
|
return {
|
|
66
71
|
all,
|
|
72
|
+
attach,
|
|
67
73
|
};
|
|
68
74
|
}
|
|
69
75
|
}
|
package/src/helpers/api.js
CHANGED
|
@@ -11,7 +11,7 @@ import { getSession } from './session';
|
|
|
11
11
|
function addVersionArg(url) {
|
|
12
12
|
if (!url || url.includes('_result=1')) return url;
|
|
13
13
|
|
|
14
|
-
const version = process.env ? process.env.API_VERITREE_VERSION :
|
|
14
|
+
const version = process.env ? process.env.API_VERITREE_VERSION ? process.env.API_VERITREE_VERSION : '5.0.0' : '5.0.0' || '5.0.0';
|
|
15
15
|
const urlHasArgs = url.includes('?');
|
|
16
16
|
const urlVersionArg = urlHasArgs ? `&_v=${version}` : `?_v=${version}`;
|
|
17
17
|
|