emissions-api-sdk 1.0.0 → 1.0.1
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/README.md +33 -2
- package/dist/Constants.js +23 -1
- package/dist/api/Calculation.js +77 -14
- package/dist/api/Factor.js +97 -16
- package/dist/api/Fugitive.js +75 -12
- package/dist/api/Location.js +75 -14
- package/dist/api/Mobile.js +66 -0
- package/dist/api/Stationary.js +77 -14
- package/dist/api/TransportationAndDistribution.js +75 -12
- package/dist/types/Constants.d.ts +22 -0
- package/dist/types/api/Calculation.d.ts +52 -14
- package/dist/types/api/Factor.d.ts +64 -16
- package/dist/types/api/Fugitive.d.ts +50 -12
- package/dist/types/api/Location.d.ts +50 -14
- package/dist/types/api/Mobile.d.ts +41 -0
- package/dist/types/api/Stationary.d.ts +52 -14
- package/dist/types/api/TransportationAndDistribution.d.ts +50 -12
- package/docs/.nojekyll +0 -0
- package/docs/_sources/authentication.rst.txt +164 -0
- package/docs/_sources/client.rst.txt +137 -0
- package/docs/_sources/getting_started.rst.txt +164 -0
- package/docs/_sources/index.rst.txt +29 -0
- package/docs/_sources/reference.rst.txt +129 -0
- package/docs/_sources/sdk.rst.txt +13 -0
- package/docs/_static/basic.css +906 -0
- package/docs/_static/custom.css +16 -0
- package/docs/_static/debug.css +69 -0
- package/docs/_static/doctools.js +149 -0
- package/docs/_static/documentation_options.js +13 -0
- package/docs/_static/file.png +0 -0
- package/docs/_static/language_data.js +192 -0
- package/docs/_static/minus.png +0 -0
- package/docs/_static/plus.png +0 -0
- package/docs/_static/pygments.css +250 -0
- package/docs/_static/scripts/furo-extensions.js +0 -0
- package/docs/_static/scripts/furo.js +3 -0
- package/docs/_static/scripts/furo.js.LICENSE.txt +7 -0
- package/docs/_static/scripts/furo.js.map +1 -0
- package/docs/_static/searchtools.js +635 -0
- package/docs/_static/skeleton.css +296 -0
- package/docs/_static/sphinx_highlight.js +154 -0
- package/docs/_static/sphinx_js.css +0 -0
- package/docs/_static/styles/furo-extensions.css +2 -0
- package/docs/_static/styles/furo-extensions.css.map +1 -0
- package/docs/_static/styles/furo.css +2 -0
- package/docs/_static/styles/furo.css.map +1 -0
- package/docs/authentication.html +513 -0
- package/docs/client.html +467 -0
- package/docs/genindex.html +482 -0
- package/docs/getting_started.html +481 -0
- package/docs/index.html +334 -0
- package/docs/objects.inv +0 -0
- package/docs/reference.html +1568 -0
- package/docs/sdk.html +324 -0
- package/docs/search.html +287 -0
- package/docs/searchindex.js +1 -0
- package/package.json +1 -1
- package/sphinx-build/Makefile +49 -0
- package/sphinx-build/source/_static/custom.css +16 -0
- package/sphinx-build/source/authentication.rst +164 -0
- package/sphinx-build/source/client.rst +137 -0
- package/sphinx-build/source/conf.py +56 -0
- package/sphinx-build/source/getting_started.rst +164 -0
- package/sphinx-build/source/index.rst +29 -0
- package/sphinx-build/source/reference.rst +129 -0
- package/sphinx-build/source/sdk.rst +13 -0
- package/src/Constants.ts +26 -0
- package/src/api/Calculation.ts +84 -15
- package/src/api/Factor.ts +108 -19
- package/src/api/Fugitive.ts +83 -13
- package/src/api/Location.ts +84 -15
- package/src/api/Mobile.ts +75 -1
- package/src/api/Stationary.ts +85 -15
- package/src/api/TransportationAndDistribution.ts +84 -13
- package/test/apiTest.test.ts +172 -5
- package/dist/api/Factors.js +0 -98
- package/dist/api/FugitiveEmission.js +0 -40
- package/dist/api/GenericCalculation.js +0 -41
- package/dist/api/LocationEmission.js +0 -41
- package/dist/api/MobileEmission.js +0 -41
- package/dist/api/StationaryEmission.js +0 -41
- package/dist/api/TransportationDistributionEmission.js +0 -40
- package/dist/coverage/clover.xml +0 -225
- package/dist/coverage/coverage-final.json +0 -19
- package/dist/coverage/lcov-report/base.css +0 -224
- package/dist/coverage/lcov-report/block-navigation.js +0 -87
- package/dist/coverage/lcov-report/favicon.png +0 -0
- package/dist/coverage/lcov-report/index.html +0 -161
- package/dist/coverage/lcov-report/prettify.css +0 -1
- package/dist/coverage/lcov-report/prettify.js +0 -2
- package/dist/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/dist/coverage/lcov-report/sorter.js +0 -210
- package/dist/coverage/lcov-report/src/Client.ts.html +0 -838
- package/dist/coverage/lcov-report/src/Constants.ts.html +0 -130
- package/dist/coverage/lcov-report/src/api/Calculation.ts.html +0 -217
- package/dist/coverage/lcov-report/src/api/Factor.ts.html +0 -343
- package/dist/coverage/lcov-report/src/api/FactorSets.ts.html +0 -154
- package/dist/coverage/lcov-report/src/api/Factors.ts.html +0 -403
- package/dist/coverage/lcov-report/src/api/Fugitive.ts.html +0 -214
- package/dist/coverage/lcov-report/src/api/FugitiveEmission.ts.html +0 -214
- package/dist/coverage/lcov-report/src/api/GenericCalculation.ts.html +0 -217
- package/dist/coverage/lcov-report/src/api/Location.ts.html +0 -214
- package/dist/coverage/lcov-report/src/api/LocationEmission.ts.html +0 -214
- package/dist/coverage/lcov-report/src/api/Mobile.ts.html +0 -220
- package/dist/coverage/lcov-report/src/api/MobileEmission.ts.html +0 -220
- package/dist/coverage/lcov-report/src/api/Stationary.ts.html +0 -220
- package/dist/coverage/lcov-report/src/api/StationaryEmission.ts.html +0 -220
- package/dist/coverage/lcov-report/src/api/TransportationAndDistribution.ts.html +0 -211
- package/dist/coverage/lcov-report/src/api/TransportationDistributionEmission.ts.html +0 -211
- package/dist/coverage/lcov-report/src/api/index.html +0 -221
- package/dist/coverage/lcov-report/src/index.html +0 -161
- package/dist/coverage/lcov-report/src/request.ts.html +0 -235
- package/dist/coverage/lcov-report/src/utils.ts.html +0 -139
- package/dist/coverage/lcov-report/test/index.html +0 -116
- package/dist/coverage/lcov-report/test/mocks/CommonRequest.ts.html +0 -142
- package/dist/coverage/lcov-report/test/mocks/FactorRequest.ts.html +0 -133
- package/dist/coverage/lcov-report/test/mocks/GenericCalculationRequest.ts.html +0 -142
- package/dist/coverage/lcov-report/test/mocks/LocationRequest.ts.html +0 -139
- package/dist/coverage/lcov-report/test/mocks/SearchRequest.ts.html +0 -142
- package/dist/coverage/lcov-report/test/mocks/index.html +0 -176
- package/dist/coverage/lcov-report/test/testUtils.ts.html +0 -97
- package/dist/coverage/lcov.info +0 -404
- package/dist/types/api/Factors.d.ts +0 -68
- package/dist/types/api/FugitiveEmission.d.ts +0 -27
- package/dist/types/api/GenericCalculation.d.ts +0 -28
- package/dist/types/api/LocationEmission.d.ts +0 -28
- package/dist/types/api/MobileEmission.d.ts +0 -28
- package/dist/types/api/StationaryEmission.d.ts +0 -28
- package/dist/types/api/TransportationDistributionEmission.d.ts +0 -27
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ yarn install emissions-api-sdk
|
|
|
23
23
|
## Quick Start
|
|
24
24
|
|
|
25
25
|
```javascript
|
|
26
|
-
import { Client,
|
|
26
|
+
import { Client, LocationEmission } from 'emissions-api-sdk';
|
|
27
27
|
|
|
28
28
|
// Initialize client
|
|
29
29
|
await Client.getClient({
|
|
@@ -33,7 +33,7 @@ await Client.getClient({
|
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
// Calculate emissions
|
|
36
|
-
const result = await
|
|
36
|
+
const result = await LocationEmission.calculate({
|
|
37
37
|
"location": {
|
|
38
38
|
"country": "USA",
|
|
39
39
|
"stateProvince": "california"
|
|
@@ -46,6 +46,37 @@ const result = await Location.calculate({
|
|
|
46
46
|
});
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
+
## Metadata APIs
|
|
50
|
+
|
|
51
|
+
The SDK provides Metadata APIs to discover available emission types, geographical areas, and units:
|
|
52
|
+
|
|
53
|
+
### Get Available Types
|
|
54
|
+
|
|
55
|
+
```javascript
|
|
56
|
+
import { LocationEmission } from 'emissions-api-sdk';
|
|
57
|
+
|
|
58
|
+
// Get all available Location emission types
|
|
59
|
+
const types = await LocationEmission.getTypes();
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Get Supported Areas
|
|
63
|
+
|
|
64
|
+
```javascript
|
|
65
|
+
import { LocationEmission } from 'emissions-api-sdk';
|
|
66
|
+
|
|
67
|
+
// Get supported geographical areas
|
|
68
|
+
const areas = await LocationEmission.getArea();
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Get Valid Units
|
|
72
|
+
|
|
73
|
+
```javascript
|
|
74
|
+
import { LocationEmission } from 'emissions-api-sdk';
|
|
75
|
+
|
|
76
|
+
// Get valid units for a specific emission type
|
|
77
|
+
const units = await LocationEmission.getUnits("electricity");
|
|
78
|
+
```
|
|
79
|
+
|
|
49
80
|
## Authentication
|
|
50
81
|
|
|
51
82
|
The SDK supports two authentication methods:
|
package/dist/Constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CLIENT_SOURCE_SDK = exports.CLIENT_SOURCE_EXCEL = exports.CLIENT_SOURCE_HEADER = exports.POST = exports.GET = exports.SEARCH_API_PATH = exports.FACTOR_SET_API_PATH = exports.FACTOR_API_PATH = exports.TRANSPORTATION_AND_DISTRIBUTION_API_PATH = exports.GENERIC_CALCULATION_API_PATH = exports.STATIONARY_API_PATH = exports.FUGITIVE_API_PATH = exports.LOCATION_API_PATH = exports.MOBILE_API_PATH = exports.TOKEN_GENERATION_API = exports.API_DOMAIN = void 0;
|
|
3
|
+
exports.CLIENT_SOURCE_SDK = exports.CLIENT_SOURCE_EXCEL = exports.CLIENT_SOURCE_HEADER = exports.POST = exports.GET = exports.TRANSPORTATION_AND_DISTRIBUTION_API_UNITS = exports.FACTOR_API_UNITS = exports.GENERAL_API_UNITS = exports.STATIONARY_API_UNITS = exports.MOBILE_API_UNITS = exports.LOCATION_API_UNITS = exports.FUGITIVE_API_UNITS = exports.FACTOR_API_AREA = exports.SEARCH_API_AREA = exports.TRANSPORTATION_AND_DISTRIBUTION_API_AREA = exports.STATIONARY_API_AREA = exports.MOBILE_API_AREA = exports.LOCATION_API_AREA = exports.GENERAL_API_AREA = exports.FUGITIVE_API_AREA = exports.TRANSPORTATION_AND_DISTRIBUTION_API_TYPES = exports.FACTOR_API_TYPES = exports.STATIONARY_API_TYPES = exports.MOBILE_API_TYPES = exports.FUGITIVE_API_TYPES = exports.LOCATION_TYPES = exports.CALCULATION_TYPES = exports.SEARCH_API_PATH = exports.FACTOR_SET_API_PATH = exports.FACTOR_API_PATH = exports.TRANSPORTATION_AND_DISTRIBUTION_API_PATH = exports.GENERIC_CALCULATION_API_PATH = exports.STATIONARY_API_PATH = exports.FUGITIVE_API_PATH = exports.LOCATION_API_PATH = exports.MOBILE_API_PATH = exports.TOKEN_GENERATION_API = exports.API_DOMAIN = void 0;
|
|
4
4
|
exports.API_DOMAIN = "https://api.ibm.com/ghgemissions/run";
|
|
5
5
|
exports.TOKEN_GENERATION_API = "https://api.ibm.com/saascore/run/authentication-retrieve/api-key";
|
|
6
6
|
exports.MOBILE_API_PATH = "/v3/carbon/mobile";
|
|
@@ -12,6 +12,28 @@ exports.TRANSPORTATION_AND_DISTRIBUTION_API_PATH = "/v3/carbon/transportation-an
|
|
|
12
12
|
exports.FACTOR_API_PATH = "/v3/carbon/factor";
|
|
13
13
|
exports.FACTOR_SET_API_PATH = "/v3/carbon/factorset";
|
|
14
14
|
exports.SEARCH_API_PATH = "/v3/carbon/factor/search";
|
|
15
|
+
exports.CALCULATION_TYPES = "/v3/carbon/calculation/types";
|
|
16
|
+
exports.LOCATION_TYPES = "/v3/carbon/location/types";
|
|
17
|
+
exports.FUGITIVE_API_TYPES = "/v3/carbon/fugitive/types";
|
|
18
|
+
exports.MOBILE_API_TYPES = "/v3/carbon/mobile/types";
|
|
19
|
+
exports.STATIONARY_API_TYPES = "/v3/carbon/stationary/types";
|
|
20
|
+
exports.FACTOR_API_TYPES = "/v3/carbon/factor/types";
|
|
21
|
+
exports.TRANSPORTATION_AND_DISTRIBUTION_API_TYPES = "/v3/carbon/transportation-and-distribution/types";
|
|
22
|
+
exports.FUGITIVE_API_AREA = "/v3/carbon/fugitive/area";
|
|
23
|
+
exports.GENERAL_API_AREA = "/v3/carbon/calculation/area";
|
|
24
|
+
exports.LOCATION_API_AREA = "/v3/carbon/location/area";
|
|
25
|
+
exports.MOBILE_API_AREA = "/v3/carbon/mobile/area";
|
|
26
|
+
exports.STATIONARY_API_AREA = "/v3/carbon/stationary/area";
|
|
27
|
+
exports.TRANSPORTATION_AND_DISTRIBUTION_API_AREA = "/v3/carbon/transportation-and-distribution/area";
|
|
28
|
+
exports.SEARCH_API_AREA = "/v3/carbon/factor/search/area";
|
|
29
|
+
exports.FACTOR_API_AREA = "/v3/carbon/factor/area";
|
|
30
|
+
exports.FUGITIVE_API_UNITS = "/v3/carbon/fugitive/units";
|
|
31
|
+
exports.LOCATION_API_UNITS = "/v3/carbon/location/units";
|
|
32
|
+
exports.MOBILE_API_UNITS = "/v3/carbon/mobile/units";
|
|
33
|
+
exports.STATIONARY_API_UNITS = "/v3/carbon/stationary/units";
|
|
34
|
+
exports.GENERAL_API_UNITS = "/v3/carbon/calculation/units";
|
|
35
|
+
exports.FACTOR_API_UNITS = "/v3/carbon/factor/units";
|
|
36
|
+
exports.TRANSPORTATION_AND_DISTRIBUTION_API_UNITS = "/v3/carbon/transportation-and-distribution/units";
|
|
15
37
|
exports.GET = "GET";
|
|
16
38
|
exports.POST = "POST";
|
|
17
39
|
exports.CLIENT_SOURCE_HEADER = "X-Client-Source";
|
package/dist/api/Calculation.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.calculate = calculate;
|
|
4
|
+
exports.getTypes = getTypes;
|
|
5
|
+
exports.getArea = getArea;
|
|
6
|
+
exports.getUnits = getUnits;
|
|
4
7
|
const Client_1 = require("../Client");
|
|
5
8
|
const Constants_1 = require("../Constants");
|
|
6
9
|
const request_1 = require("../request");
|
|
@@ -14,20 +17,20 @@ const request_1 = require("../request");
|
|
|
14
17
|
*
|
|
15
18
|
* @example
|
|
16
19
|
* const calculationRequest = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
"time" : {
|
|
21
|
+
"date": "2025-01-04"
|
|
22
|
+
},
|
|
23
|
+
"location": {
|
|
24
|
+
"country": "usa",
|
|
25
|
+
"stateProvince": "new york"
|
|
26
|
+
},
|
|
27
|
+
"activity": {
|
|
28
|
+
"type":"Waste Combusted - Steel Cans:Default factor",
|
|
29
|
+
"unit": "kg",
|
|
30
|
+
"value": 1223123.121
|
|
31
|
+
},
|
|
32
|
+
"includeDetails": true
|
|
33
|
+
};
|
|
31
34
|
* const result = await calculate(calculationRequest);
|
|
32
35
|
*/
|
|
33
36
|
async function calculate(payload) {
|
|
@@ -39,3 +42,63 @@ async function calculate(payload) {
|
|
|
39
42
|
data: payload,
|
|
40
43
|
});
|
|
41
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Retrieves available calculation types by making a GET request to the calculation types API endpoint.
|
|
47
|
+
*
|
|
48
|
+
* @export
|
|
49
|
+
* @return {Promise<string>} A promise that resolves to a string containing the available calculation types
|
|
50
|
+
* @throws {Error} May throw an error if the API request fails
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* const types = await getTypes();
|
|
54
|
+
*/
|
|
55
|
+
async function getTypes() {
|
|
56
|
+
const client = Client_1.Client.getInstance();
|
|
57
|
+
const url = client.getDomain() + Constants_1.CALCULATION_TYPES;
|
|
58
|
+
return (0, request_1.makeApiRequest)({
|
|
59
|
+
method: Constants_1.GET,
|
|
60
|
+
url
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Retrieves information about geographical areas supported by the calculation API.
|
|
65
|
+
*
|
|
66
|
+
* @export
|
|
67
|
+
* @return {Promise<string>} A promise that resolves to a string containing the supported geographical areas
|
|
68
|
+
* @throws {Error} May throw an error if the API request fails
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* const areas = await getArea();
|
|
72
|
+
*/
|
|
73
|
+
async function getArea() {
|
|
74
|
+
const client = Client_1.Client.getInstance();
|
|
75
|
+
const url = client.getDomain() + Constants_1.GENERAL_API_AREA;
|
|
76
|
+
return (0, request_1.makeApiRequest)({
|
|
77
|
+
method: Constants_1.GET,
|
|
78
|
+
url
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Retrieves available units for a specific calculation type.
|
|
83
|
+
*
|
|
84
|
+
* @export
|
|
85
|
+
* @param {string} type - The calculation type to get units for
|
|
86
|
+
* @return {Promise<string>} A promise that resolves to a string containing the available units
|
|
87
|
+
* @throws {Error} May throw an error if the API request fails
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* // Get units for the "Natural Gas - Scope 3:AAA" emission calculation type with subtype
|
|
91
|
+
* const units = await getUnits("Natural Gas - Scope 3:AAA");
|
|
92
|
+
|
|
93
|
+
* // Get units for the "HFC-263fb" emission calculation type without subtype
|
|
94
|
+
* const units = await getUnits("HFC-263fb");
|
|
95
|
+
*/
|
|
96
|
+
async function getUnits(type) {
|
|
97
|
+
const client = Client_1.Client.getInstance();
|
|
98
|
+
const url = client.getDomain() + Constants_1.GENERAL_API_UNITS;
|
|
99
|
+
return (0, request_1.makeApiRequest)({
|
|
100
|
+
method: Constants_1.GET,
|
|
101
|
+
url,
|
|
102
|
+
params: { type }
|
|
103
|
+
});
|
|
104
|
+
}
|
package/dist/api/Factor.js
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.retrieveFactor = retrieveFactor;
|
|
4
4
|
exports.search = search;
|
|
5
|
+
exports.getTypes = getTypes;
|
|
6
|
+
exports.getSearchArea = getSearchArea;
|
|
7
|
+
exports.getArea = getArea;
|
|
8
|
+
exports.getUnits = getUnits;
|
|
5
9
|
const Client_1 = require("../Client");
|
|
6
10
|
const Constants_1 = require("../Constants");
|
|
7
11
|
const request_1 = require("../request");
|
|
@@ -15,27 +19,26 @@ const request_1 = require("../request");
|
|
|
15
19
|
*
|
|
16
20
|
* @example
|
|
17
21
|
* const factorRequest = {
|
|
18
|
-
|
|
19
22
|
"activity": {
|
|
20
|
-
|
|
23
|
+
"factorId": 12345
|
|
21
24
|
}
|
|
22
25
|
};
|
|
23
26
|
|
|
24
|
-
|
|
27
|
+
OR
|
|
25
28
|
|
|
26
29
|
const factorRequest = {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
"time" : {
|
|
31
|
+
"date": "2025-01-04"
|
|
32
|
+
},
|
|
33
|
+
"location": {
|
|
34
|
+
"country": "usa",
|
|
35
|
+
"stateProvince": "new york"
|
|
36
|
+
},
|
|
37
|
+
"activity": {
|
|
38
|
+
"type":"natural gas"
|
|
39
|
+
},
|
|
40
|
+
"includeDetails": true
|
|
41
|
+
};
|
|
39
42
|
* const factor = await retrieveFactor(factorRequest);
|
|
40
43
|
*/
|
|
41
44
|
async function retrieveFactor(payload) {
|
|
@@ -62,7 +65,7 @@ async function retrieveFactor(payload) {
|
|
|
62
65
|
},
|
|
63
66
|
"activity": {
|
|
64
67
|
"search" : "travel"},
|
|
65
|
-
|
|
68
|
+
"location": {
|
|
66
69
|
"country": "USA"
|
|
67
70
|
}
|
|
68
71
|
};
|
|
@@ -77,3 +80,81 @@ async function search(payload) {
|
|
|
77
80
|
data: payload,
|
|
78
81
|
});
|
|
79
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Retrieves available emission factor types by making a GET request to the API endpoint.
|
|
85
|
+
*
|
|
86
|
+
* @export
|
|
87
|
+
* @return {Promise<string>} A promise that resolves to a string containing the available emission factor types
|
|
88
|
+
* @throws {Error} May throw an error if the API request fails
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* const types = await getTypes();
|
|
92
|
+
*/
|
|
93
|
+
async function getTypes() {
|
|
94
|
+
const client = Client_1.Client.getInstance();
|
|
95
|
+
const url = client.getDomain() + Constants_1.FACTOR_API_TYPES;
|
|
96
|
+
return (0, request_1.makeApiRequest)({
|
|
97
|
+
method: Constants_1.GET,
|
|
98
|
+
url
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Retrieves information about geographical areas supported by the factor search API.
|
|
103
|
+
*
|
|
104
|
+
* @export
|
|
105
|
+
* @return {Promise<string>} A promise that resolves to a string containing the supported geographical areas
|
|
106
|
+
* @throws {Error} May throw an error if the API request fails
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* const areas = await getArea();
|
|
110
|
+
*/
|
|
111
|
+
async function getSearchArea() {
|
|
112
|
+
const client = Client_1.Client.getInstance();
|
|
113
|
+
const url = client.getDomain() + Constants_1.SEARCH_API_AREA;
|
|
114
|
+
return (0, request_1.makeApiRequest)({
|
|
115
|
+
method: Constants_1.GET,
|
|
116
|
+
url
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Retrieves information about geographical areas supported by the factor API.
|
|
121
|
+
*
|
|
122
|
+
* @export
|
|
123
|
+
* @return {Promise<string>} A promise that resolves to a string containing the supported geographical areas
|
|
124
|
+
* @throws {Error} May throw an error if the API request fails
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* const areas = await getArea();
|
|
128
|
+
*/
|
|
129
|
+
async function getArea() {
|
|
130
|
+
const client = Client_1.Client.getInstance();
|
|
131
|
+
const url = client.getDomain() + Constants_1.FACTOR_API_AREA;
|
|
132
|
+
return (0, request_1.makeApiRequest)({
|
|
133
|
+
method: Constants_1.GET,
|
|
134
|
+
url
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Retrieves available units for a specific emission factor type.
|
|
139
|
+
*
|
|
140
|
+
* @export
|
|
141
|
+
* @param {string} type - The emission factor type to get units for (e.g., "Natural Gas - Scope 3:AAA")
|
|
142
|
+
* @return {Promise<string>} A promise that resolves to a string containing the available units
|
|
143
|
+
* @throws {Error} May throw an error if the API request fails
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* // Get units for the "Natural Gas - Scope 3:AAA" emission factor type with subtype
|
|
147
|
+
* const units = await getUnits("Natural Gas - Scope 3:AAA");
|
|
148
|
+
|
|
149
|
+
* // Get units for the "HFC-263fb" emission factor type without subtype
|
|
150
|
+
* const units = await getUnits("HFC-263fb");
|
|
151
|
+
*/
|
|
152
|
+
async function getUnits(type) {
|
|
153
|
+
const client = Client_1.Client.getInstance();
|
|
154
|
+
const url = client.getDomain() + Constants_1.FACTOR_API_UNITS;
|
|
155
|
+
return (0, request_1.makeApiRequest)({
|
|
156
|
+
method: Constants_1.GET,
|
|
157
|
+
url,
|
|
158
|
+
params: { type }
|
|
159
|
+
});
|
|
160
|
+
}
|
package/dist/api/Fugitive.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.calculate = calculate;
|
|
4
|
+
exports.getTypes = getTypes;
|
|
5
|
+
exports.getArea = getArea;
|
|
6
|
+
exports.getUnits = getUnits;
|
|
4
7
|
const Client_1 = require("../Client");
|
|
5
8
|
const Constants_1 = require("../Constants");
|
|
6
9
|
const request_1 = require("../request");
|
|
@@ -14,18 +17,18 @@ const request_1 = require("../request");
|
|
|
14
17
|
*
|
|
15
18
|
* @example
|
|
16
19
|
* const request = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
"time": {
|
|
21
|
+
"date": "2025-01-04"
|
|
22
|
+
},
|
|
23
|
+
"location": {
|
|
24
|
+
"country": "usa"
|
|
25
|
+
},
|
|
26
|
+
"activity": {
|
|
27
|
+
"type": "R134A",
|
|
28
|
+
"value": 150,
|
|
29
|
+
"unit": "kg"
|
|
30
|
+
},
|
|
31
|
+
"includeDetails": false
|
|
29
32
|
};
|
|
30
33
|
* const result = await calculate(request);
|
|
31
34
|
*/
|
|
@@ -38,3 +41,63 @@ async function calculate(payload) {
|
|
|
38
41
|
data: payload,
|
|
39
42
|
});
|
|
40
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Retrieves available fugitive emission calculation types by making a GET request to the API endpoint.
|
|
46
|
+
*
|
|
47
|
+
* @export
|
|
48
|
+
* @return {Promise<string>} A promise that resolves to a string containing the available fugitive emission types
|
|
49
|
+
* @throws {Error} May throw an error if the API request fails
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* const types = await getTypes();
|
|
53
|
+
*/
|
|
54
|
+
async function getTypes() {
|
|
55
|
+
const client = Client_1.Client.getInstance();
|
|
56
|
+
const url = client.getDomain() + Constants_1.FUGITIVE_API_TYPES;
|
|
57
|
+
return (0, request_1.makeApiRequest)({
|
|
58
|
+
method: Constants_1.GET,
|
|
59
|
+
url
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Retrieves information about geographical areas supported by the fugitive emissions API.
|
|
64
|
+
*
|
|
65
|
+
* @export
|
|
66
|
+
* @return {Promise<string>} A promise that resolves to a string containing the supported geographical areas
|
|
67
|
+
* @throws {Error} May throw an error if the API request fails
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* const areas = await getArea();
|
|
71
|
+
*/
|
|
72
|
+
async function getArea() {
|
|
73
|
+
const client = Client_1.Client.getInstance();
|
|
74
|
+
const url = client.getDomain() + Constants_1.FUGITIVE_API_AREA;
|
|
75
|
+
return (0, request_1.makeApiRequest)({
|
|
76
|
+
method: Constants_1.GET,
|
|
77
|
+
url
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Retrieves available units for a specific fugitive emission type.
|
|
82
|
+
*
|
|
83
|
+
* @export
|
|
84
|
+
* @param {string} type - The fugitive emission type to get units for (e.g., "R134A")
|
|
85
|
+
* @return {Promise<string>} A promise that resolves to a string containing the available units
|
|
86
|
+
* @throws {Error} May throw an error if the API request fails
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* // Get units for the "Natural Gas - Scope 3:AAA" emission fugitive type with subtype
|
|
90
|
+
* const units = await getUnits("Natural Gas - Scope 3:AAA");
|
|
91
|
+
|
|
92
|
+
* // Get units for the "R-426A" emission fugitive type without subtype
|
|
93
|
+
* const units = await getUnits("R-426A");
|
|
94
|
+
*/
|
|
95
|
+
async function getUnits(type) {
|
|
96
|
+
const client = Client_1.Client.getInstance();
|
|
97
|
+
const url = client.getDomain() + Constants_1.FUGITIVE_API_UNITS;
|
|
98
|
+
return (0, request_1.makeApiRequest)({
|
|
99
|
+
method: Constants_1.GET,
|
|
100
|
+
url,
|
|
101
|
+
params: { type }
|
|
102
|
+
});
|
|
103
|
+
}
|
package/dist/api/Location.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.calculate = calculate;
|
|
4
|
+
exports.getTypes = getTypes;
|
|
5
|
+
exports.getArea = getArea;
|
|
6
|
+
exports.getUnits = getUnits;
|
|
4
7
|
const Client_1 = require("../Client");
|
|
5
8
|
const Constants_1 = require("../Constants");
|
|
6
9
|
const request_1 = require("../request");
|
|
@@ -14,20 +17,20 @@ const request_1 = require("../request");
|
|
|
14
17
|
*
|
|
15
18
|
* @example
|
|
16
19
|
* const calculationRequest = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
"time" : {
|
|
21
|
+
"date": "2025-01-04"
|
|
22
|
+
},
|
|
23
|
+
"location": {
|
|
24
|
+
"country": "usa",
|
|
25
|
+
"stateProvince": "new york"
|
|
26
|
+
},
|
|
27
|
+
"activity": {
|
|
28
|
+
"type":"electricity",
|
|
29
|
+
"unit": "kwh",
|
|
30
|
+
"value": 14123143
|
|
31
|
+
},
|
|
32
|
+
"includeDetails": true
|
|
33
|
+
};
|
|
31
34
|
* const result = await calculate(calculationRequest);
|
|
32
35
|
*/
|
|
33
36
|
async function calculate(payload) {
|
|
@@ -39,3 +42,61 @@ async function calculate(payload) {
|
|
|
39
42
|
data: payload,
|
|
40
43
|
});
|
|
41
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Retrieves available location-based calculation types by making a GET request to the location types API endpoint.
|
|
47
|
+
*
|
|
48
|
+
* @export
|
|
49
|
+
* @return {Promise<string>} A promise that resolves to a string containing the available location-based calculation types
|
|
50
|
+
* @throws {Error} May throw an error if the API request fails
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
*
|
|
54
|
+
* const types = await getTypes();
|
|
55
|
+
*/
|
|
56
|
+
async function getTypes() {
|
|
57
|
+
const client = Client_1.Client.getInstance();
|
|
58
|
+
const url = client.getDomain() + Constants_1.LOCATION_TYPES;
|
|
59
|
+
return (0, request_1.makeApiRequest)({
|
|
60
|
+
method: Constants_1.GET,
|
|
61
|
+
url
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Retrieves information about geographical areas supported by the location-based calculation API.
|
|
66
|
+
*
|
|
67
|
+
* @export
|
|
68
|
+
* @return {Promise<string>} A promise that resolves to a string containing the supported geographical areas
|
|
69
|
+
* @throws {Error} May throw an error if the API request fails
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* const areas = await getArea();
|
|
73
|
+
*/
|
|
74
|
+
async function getArea() {
|
|
75
|
+
const client = Client_1.Client.getInstance();
|
|
76
|
+
const url = client.getDomain() + Constants_1.LOCATION_API_AREA;
|
|
77
|
+
return (0, request_1.makeApiRequest)({
|
|
78
|
+
method: Constants_1.GET,
|
|
79
|
+
url
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Retrieves available units for a specific location-based calculation type.
|
|
84
|
+
*
|
|
85
|
+
* @export
|
|
86
|
+
* @param {string} type - The location-based calculation type to get units for (e.g., "electricity")
|
|
87
|
+
* @return {Promise<string>} A promise that resolves to a string containing the available units
|
|
88
|
+
* @throws {Error} May throw an error if the API request fails
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* // Get units for the "electricity" location type
|
|
92
|
+
* const units = await getUnits("electricity");
|
|
93
|
+
*/
|
|
94
|
+
async function getUnits(type) {
|
|
95
|
+
const client = Client_1.Client.getInstance();
|
|
96
|
+
const url = client.getDomain() + Constants_1.LOCATION_API_UNITS;
|
|
97
|
+
return (0, request_1.makeApiRequest)({
|
|
98
|
+
method: Constants_1.GET,
|
|
99
|
+
url,
|
|
100
|
+
params: { type }
|
|
101
|
+
});
|
|
102
|
+
}
|
package/dist/api/Mobile.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.calculate = calculate;
|
|
4
|
+
exports.getTypes = getTypes;
|
|
5
|
+
exports.getArea = getArea;
|
|
6
|
+
exports.getUnits = getUnits;
|
|
4
7
|
const request_1 = require("../request");
|
|
5
8
|
const Constants_1 = require("../Constants");
|
|
6
9
|
const Client_1 = require("../Client");
|
|
@@ -39,3 +42,66 @@ async function calculate(payload) {
|
|
|
39
42
|
data: payload,
|
|
40
43
|
});
|
|
41
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Retrieves available mobile emission calculation types by making a GET request to the API endpoint.
|
|
47
|
+
*
|
|
48
|
+
* @export
|
|
49
|
+
* @return {Promise<string>} A promise that resolves to a string containing the available mobile emission types
|
|
50
|
+
* @throws {Error} May throw an error if the API request fails
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* // Get all available mobile emission types
|
|
54
|
+
* const types = await getTypes();
|
|
55
|
+
* const typesData = JSON.parse(types);
|
|
56
|
+
* console.log("Available mobile emission types:", typesData);
|
|
57
|
+
*/
|
|
58
|
+
async function getTypes() {
|
|
59
|
+
const client = Client_1.Client.getInstance();
|
|
60
|
+
const url = client.getDomain() + Constants_1.MOBILE_API_TYPES;
|
|
61
|
+
return (0, request_1.makeApiRequest)({
|
|
62
|
+
method: Constants_1.GET,
|
|
63
|
+
url
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Retrieves information about geographical areas supported by the mobile emissions API.
|
|
68
|
+
*
|
|
69
|
+
* @export
|
|
70
|
+
* @return {Promise<string>} A promise that resolves to a string containing the supported geographical areas
|
|
71
|
+
* @throws {Error} May throw an error if the API request fails
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* const areas = await getArea();
|
|
75
|
+
*/
|
|
76
|
+
async function getArea() {
|
|
77
|
+
const client = Client_1.Client.getInstance();
|
|
78
|
+
const url = client.getDomain() + Constants_1.MOBILE_API_AREA;
|
|
79
|
+
return (0, request_1.makeApiRequest)({
|
|
80
|
+
method: Constants_1.GET,
|
|
81
|
+
url
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Retrieves available units for a specific mobile emission type.
|
|
86
|
+
*
|
|
87
|
+
* @export
|
|
88
|
+
* @param {string} type - The mobile emission type to get units for (e.g., "Diesel Fuel")
|
|
89
|
+
* @return {Promise<string>} A promise that resolves to a string containing the available units
|
|
90
|
+
* @throws {Error} May throw an error if the API request fails
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* Get units for the "Cars:B20:(NE)" emission mobile type with subtype
|
|
94
|
+
* const units = await getUnits("Cars:B20:(NE)");
|
|
95
|
+
|
|
96
|
+
* Get units for the "Cars by Size - Large Car - Hybrid" emission mobile type without subtype
|
|
97
|
+
* const units = await getUnits("Cars by Size - Large Car - Hybrid");
|
|
98
|
+
*/
|
|
99
|
+
async function getUnits(type) {
|
|
100
|
+
const client = Client_1.Client.getInstance();
|
|
101
|
+
const url = client.getDomain() + Constants_1.MOBILE_API_UNITS;
|
|
102
|
+
return (0, request_1.makeApiRequest)({
|
|
103
|
+
method: Constants_1.GET,
|
|
104
|
+
url,
|
|
105
|
+
params: { type }
|
|
106
|
+
});
|
|
107
|
+
}
|