@veritree/services 0.2.0 → 0.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
@@ -2,10 +2,12 @@ import { createSponsorsApiService } from './src/services/sponsors.js';
2
2
  import { createOrgsApiService } from './src/services/orgs.js';
3
3
  import { createForestTypesApiService } from './src/services/forestTypes.js';
4
4
  import { createSubdomainsApiService } from './src/services/subdomains.js';
5
+ import { createCountriesApiService } from './src/services/countries.js';
5
6
 
6
7
  export {
7
8
  createSponsorsApiService,
8
9
  createOrgsApiService,
9
10
  createForestTypesApiService,
10
- createSubdomainsApiService
11
+ createSubdomainsApiService,
12
+ createCountriesApiService
11
13
  }
package/package-lock.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@veritree/services",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "lockfileVersion": 1
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veritree/services",
3
- "version": "0.2.0",
3
+ "version": "0.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,23 @@
1
+ import Api from '../helpers/api';
2
+
3
+ export const createCountriesApiService = (countryId) => {
4
+
5
+ const resource = 'countries';
6
+
7
+ const stats = {
8
+ async get() {
9
+ // Look for a country ID if none provided global stats will be sent
10
+ const type = countryId ? `${countryId}` : 'global';
11
+ const url = _getUrl(type +'/stats');
12
+ return await Api.get(url);
13
+ }
14
+ }
15
+
16
+ const _getUrl = (endpoint) => {
17
+ return `${Api.baseUrl}/${resource}/${endpoint}`;
18
+ };
19
+
20
+ return {
21
+ stats
22
+ };
23
+ };