emissions-api-sdk 1.0.1 → 1.0.3
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 +9 -0
- package/dist/Constants.js +2 -1
- package/dist/api/Calculation.js +4 -4
- package/dist/api/Factor.js +7 -7
- package/dist/api/FactorSets.js +1 -1
- package/dist/api/Fugitive.js +4 -4
- package/dist/api/Location.js +4 -4
- package/dist/api/Mobile.js +4 -6
- package/dist/api/Stationary.js +4 -4
- package/dist/api/TransportationAndDistribution.js +5 -5
- package/dist/api/Usage.js +26 -0
- package/dist/coverage/clover.xml +346 -0
- package/dist/coverage/coverage-final.json +20 -0
- package/dist/coverage/lcov-report/base.css +224 -0
- package/dist/coverage/lcov-report/block-navigation.js +87 -0
- package/dist/coverage/lcov-report/favicon.png +0 -0
- package/dist/coverage/lcov-report/index.html +161 -0
- package/dist/coverage/lcov-report/prettify.css +1 -0
- package/dist/coverage/lcov-report/prettify.js +2 -0
- package/dist/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/dist/coverage/lcov-report/sorter.js +210 -0
- package/dist/coverage/lcov-report/src/Client.ts.html +838 -0
- package/dist/coverage/lcov-report/src/Constants.ts.html +214 -0
- package/dist/coverage/lcov-report/src/api/Calculation.ts.html +436 -0
- package/dist/coverage/lcov-report/src/api/Factor.ts.html +622 -0
- package/dist/coverage/lcov-report/src/api/FactorSets.ts.html +157 -0
- package/dist/coverage/lcov-report/src/api/Fugitive.ts.html +436 -0
- package/dist/coverage/lcov-report/src/api/Location.ts.html +433 -0
- package/dist/coverage/lcov-report/src/api/Mobile.ts.html +448 -0
- package/dist/coverage/lcov-report/src/api/Stationary.ts.html +442 -0
- package/dist/coverage/lcov-report/src/api/TransportationAndDistribution.ts.html +436 -0
- package/dist/coverage/lcov-report/src/api/Usage.ts.html +160 -0
- package/dist/coverage/lcov-report/src/api/index.html +236 -0
- package/dist/coverage/lcov-report/src/index.html +161 -0
- package/dist/coverage/lcov-report/src/request.ts.html +235 -0
- package/dist/coverage/lcov-report/src/utils.ts.html +139 -0
- package/dist/coverage/lcov-report/test/index.html +116 -0
- package/dist/coverage/lcov-report/test/mocks/CommonRequest.ts.html +142 -0
- package/dist/coverage/lcov-report/test/mocks/FactorRequest.ts.html +133 -0
- package/dist/coverage/lcov-report/test/mocks/GenericCalculationRequest.ts.html +142 -0
- package/dist/coverage/lcov-report/test/mocks/LocationRequest.ts.html +139 -0
- package/dist/coverage/lcov-report/test/mocks/SearchRequest.ts.html +142 -0
- package/dist/coverage/lcov-report/test/mocks/index.html +176 -0
- package/dist/coverage/lcov-report/test/testUtils.ts.html +97 -0
- package/dist/coverage/lcov.info +578 -0
- package/dist/index.js +2 -1
- package/dist/interfaces/response/AreaResponse.js +2 -0
- package/dist/interfaces/response/EmissionResponse.js +2 -0
- package/dist/interfaces/response/EmissionResponseWithDetails.js +2 -0
- package/dist/interfaces/response/FactorResponse.js +2 -0
- package/dist/interfaces/response/FactorSetResponse.js +2 -0
- package/dist/interfaces/response/SearchResponse.js +2 -0
- package/dist/interfaces/response/TypeResponse.js +2 -0
- package/dist/interfaces/response/UnitResponse.js +2 -0
- package/dist/interfaces/response/UsageResponse.js +5 -0
- package/dist/types/Constants.d.ts +1 -0
- package/dist/types/api/Calculation.d.ts +13 -8
- package/dist/types/api/Factor.d.ts +18 -13
- package/dist/types/api/FactorSets.d.ts +3 -2
- package/dist/types/api/Fugitive.d.ts +13 -8
- package/dist/types/api/Location.d.ts +13 -8
- package/dist/types/api/Mobile.d.ts +13 -10
- package/dist/types/api/Stationary.d.ts +13 -8
- package/dist/types/api/TransportationAndDistribution.d.ts +14 -9
- package/dist/types/api/Usage.d.ts +13 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/interfaces/response/AreaResponse.d.ts +20 -0
- package/dist/types/interfaces/response/EmissionResponse.d.ts +31 -0
- package/dist/types/interfaces/response/EmissionResponseWithDetails.d.ts +144 -0
- package/dist/types/interfaces/response/FactorResponse.d.ts +53 -0
- package/dist/types/interfaces/response/FactorSetResponse.d.ts +38 -0
- package/dist/types/interfaces/response/SearchResponse.d.ts +41 -0
- package/dist/types/interfaces/response/TypeResponse.d.ts +7 -0
- package/dist/types/interfaces/response/UnitResponse.d.ts +16 -0
- package/dist/types/interfaces/response/UsageResponse.d.ts +17 -0
- package/docs/_sources/index.rst.txt +1 -0
- package/docs/_sources/reference.rst.txt +6 -0
- package/docs/_sources/troubleshooting.rst.txt +486 -0
- package/docs/authentication.html +1 -0
- package/docs/client.html +1 -0
- package/docs/genindex.html +5 -0
- package/docs/getting_started.html +1 -0
- package/docs/index.html +15 -0
- package/docs/objects.inv +0 -0
- package/docs/reference.html +71 -35
- package/docs/sdk.html +1 -0
- package/docs/search.html +1 -0
- package/docs/searchindex.js +1 -1
- package/docs/troubleshooting.html +777 -0
- package/package.json +1 -1
- package/sphinx-build/requirements.txt +5 -0
- package/sphinx-build/source/index.rst +1 -0
- package/sphinx-build/source/reference.rst +6 -0
- package/sphinx-build/source/troubleshooting.rst +486 -0
- package/src/Constants.ts +2 -0
- package/src/api/Calculation.ts +19 -14
- package/src/api/Factor.ts +27 -22
- package/src/api/FactorSets.ts +4 -3
- package/src/api/Fugitive.ts +19 -14
- package/src/api/Location.ts +20 -15
- package/src/api/Mobile.ts +19 -16
- package/src/api/Stationary.ts +19 -14
- package/src/api/TransportationAndDistribution.ts +21 -16
- package/src/api/Usage.ts +26 -0
- package/src/index.ts +35 -1
- package/src/interfaces/response/AreaResponse.ts +25 -0
- package/src/interfaces/response/EmissionResponse.ts +44 -0
- package/src/interfaces/response/EmissionResponseWithDetails.ts +183 -0
- package/src/interfaces/response/FactorResponse.ts +78 -0
- package/src/interfaces/response/FactorSetResponse.ts +52 -0
- package/src/interfaces/response/SearchResponse.ts +52 -0
- package/src/interfaces/response/TypeResponse.ts +7 -0
- package/src/interfaces/response/UnitResponse.ts +17 -0
- package/src/interfaces/response/UsageResponse.ts +23 -0
- package/test/apiTest.test.ts +35 -4
package/README.md
CHANGED
|
@@ -77,6 +77,15 @@ import { LocationEmission } from 'emissions-api-sdk';
|
|
|
77
77
|
const units = await LocationEmission.getUnits("electricity");
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
+
### Get Organization Usage
|
|
81
|
+
```javascript
|
|
82
|
+
import { Usage } from 'emissions-api-sdk';
|
|
83
|
+
|
|
84
|
+
// Retrieves current billing period or historical usage data for the Organization
|
|
85
|
+
// History Flag to retrieve current billing or historical usage data.
|
|
86
|
+
const units = await Usage.getUsage(true);
|
|
87
|
+
```
|
|
88
|
+
|
|
80
89
|
## Authentication
|
|
81
90
|
|
|
82
91
|
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.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;
|
|
3
|
+
exports.CLIENT_SOURCE_SDK = exports.CLIENT_SOURCE_EXCEL = exports.CLIENT_SOURCE_HEADER = exports.POST = exports.GET = exports.USAGE_API = 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";
|
|
@@ -34,6 +34,7 @@ exports.STATIONARY_API_UNITS = "/v3/carbon/stationary/units";
|
|
|
34
34
|
exports.GENERAL_API_UNITS = "/v3/carbon/calculation/units";
|
|
35
35
|
exports.FACTOR_API_UNITS = "/v3/carbon/factor/units";
|
|
36
36
|
exports.TRANSPORTATION_AND_DISTRIBUTION_API_UNITS = "/v3/carbon/transportation-and-distribution/units";
|
|
37
|
+
exports.USAGE_API = "/v3/carbon/usage";
|
|
37
38
|
exports.GET = "GET";
|
|
38
39
|
exports.POST = "POST";
|
|
39
40
|
exports.CLIENT_SOURCE_HEADER = "X-Client-Source";
|
package/dist/api/Calculation.js
CHANGED
|
@@ -12,7 +12,7 @@ const request_1 = require("../request");
|
|
|
12
12
|
*
|
|
13
13
|
* @export
|
|
14
14
|
* @param {CalculationRequest} payload - The calculation request data to be sent to the API
|
|
15
|
-
* @return {Promise<
|
|
15
|
+
* @return {Promise<EmissionResponse | EmissionResponseWithDetails>} A promise that resolves to the emission calculation result. Returns EmissionResponseWithDetails if includeDetails is true, otherwise EmissionResponse
|
|
16
16
|
* @throws {Error} May throw an error if the API request fails
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
@@ -46,7 +46,7 @@ async function calculate(payload) {
|
|
|
46
46
|
* Retrieves available calculation types by making a GET request to the calculation types API endpoint.
|
|
47
47
|
*
|
|
48
48
|
* @export
|
|
49
|
-
* @return {Promise<
|
|
49
|
+
* @return {Promise<TypeResponse>} A promise that resolves to a TypeResponse containing the available calculation types
|
|
50
50
|
* @throws {Error} May throw an error if the API request fails
|
|
51
51
|
*
|
|
52
52
|
* @example
|
|
@@ -64,7 +64,7 @@ async function getTypes() {
|
|
|
64
64
|
* Retrieves information about geographical areas supported by the calculation API.
|
|
65
65
|
*
|
|
66
66
|
* @export
|
|
67
|
-
* @return {Promise<
|
|
67
|
+
* @return {Promise<AreaResponse>} A promise that resolves to an AreaResponse containing the supported geographical areas
|
|
68
68
|
* @throws {Error} May throw an error if the API request fails
|
|
69
69
|
*
|
|
70
70
|
* @example
|
|
@@ -83,7 +83,7 @@ async function getArea() {
|
|
|
83
83
|
*
|
|
84
84
|
* @export
|
|
85
85
|
* @param {string} type - The calculation type to get units for
|
|
86
|
-
* @return {Promise<
|
|
86
|
+
* @return {Promise<UnitResponse>} A promise that resolves to a UnitResponse containing the available units
|
|
87
87
|
* @throws {Error} May throw an error if the API request fails
|
|
88
88
|
*
|
|
89
89
|
* @example
|
package/dist/api/Factor.js
CHANGED
|
@@ -14,7 +14,7 @@ const request_1 = require("../request");
|
|
|
14
14
|
*
|
|
15
15
|
* @export
|
|
16
16
|
* @param {FactorRequest} payload - The factor request data to be sent to the API
|
|
17
|
-
* @return {Promise<
|
|
17
|
+
* @return {Promise<FactorResponse>} A promise that resolves to the FactorResponse returned by the API
|
|
18
18
|
* @throws {Error} May throw an error if the API request fails
|
|
19
19
|
*
|
|
20
20
|
* @example
|
|
@@ -55,7 +55,7 @@ async function retrieveFactor(payload) {
|
|
|
55
55
|
*
|
|
56
56
|
* @export
|
|
57
57
|
* @param {SearchRequest} payload - The search request data to be sent to the API
|
|
58
|
-
* @return {Promise<
|
|
58
|
+
* @return {Promise<SearchResponse>} A promise that resolves to the search results returned by the API
|
|
59
59
|
* @throws {Error} May throw an error if the API request fails
|
|
60
60
|
*
|
|
61
61
|
* @example
|
|
@@ -84,7 +84,7 @@ async function search(payload) {
|
|
|
84
84
|
* Retrieves available emission factor types by making a GET request to the API endpoint.
|
|
85
85
|
*
|
|
86
86
|
* @export
|
|
87
|
-
* @return {Promise<
|
|
87
|
+
* @return {Promise<TypeResponse>} A promise that resolves to a TypeResponse containing the available emission factor types
|
|
88
88
|
* @throws {Error} May throw an error if the API request fails
|
|
89
89
|
*
|
|
90
90
|
* @example
|
|
@@ -102,11 +102,11 @@ async function getTypes() {
|
|
|
102
102
|
* Retrieves information about geographical areas supported by the factor search API.
|
|
103
103
|
*
|
|
104
104
|
* @export
|
|
105
|
-
* @return {Promise<
|
|
105
|
+
* @return {Promise<AreaResponse>} A promise that resolves to an AreaResponse containing the supported geographical areas
|
|
106
106
|
* @throws {Error} May throw an error if the API request fails
|
|
107
107
|
*
|
|
108
108
|
* @example
|
|
109
|
-
* const areas = await
|
|
109
|
+
* const areas = await getSearchArea();
|
|
110
110
|
*/
|
|
111
111
|
async function getSearchArea() {
|
|
112
112
|
const client = Client_1.Client.getInstance();
|
|
@@ -120,7 +120,7 @@ async function getSearchArea() {
|
|
|
120
120
|
* Retrieves information about geographical areas supported by the factor API.
|
|
121
121
|
*
|
|
122
122
|
* @export
|
|
123
|
-
* @return {Promise<
|
|
123
|
+
* @return {Promise<AreaResponse>} A promise that resolves to an AreaResponse containing the supported geographical areas
|
|
124
124
|
* @throws {Error} May throw an error if the API request fails
|
|
125
125
|
*
|
|
126
126
|
* @example
|
|
@@ -139,7 +139,7 @@ async function getArea() {
|
|
|
139
139
|
*
|
|
140
140
|
* @export
|
|
141
141
|
* @param {string} type - The emission factor type to get units for (e.g., "Natural Gas - Scope 3:AAA")
|
|
142
|
-
* @return {Promise<
|
|
142
|
+
* @return {Promise<UnitResponse>} A promise that resolves to a UnitResponse containing the available units
|
|
143
143
|
* @throws {Error} May throw an error if the API request fails
|
|
144
144
|
*
|
|
145
145
|
* @example
|
package/dist/api/FactorSets.js
CHANGED
|
@@ -8,7 +8,7 @@ const request_1 = require("../request");
|
|
|
8
8
|
* Retrieves factor sets by making a GET request to the factor set API endpoint.
|
|
9
9
|
*
|
|
10
10
|
* @export
|
|
11
|
-
* @return {Promise<
|
|
11
|
+
* @return {Promise<FactorSetResponse>} A promise that resolves to the FactorSetResponse returned by the API
|
|
12
12
|
* @throws {Error} May throw an error if the API request fails
|
|
13
13
|
*
|
|
14
14
|
* @example
|
package/dist/api/Fugitive.js
CHANGED
|
@@ -12,7 +12,7 @@ const request_1 = require("../request");
|
|
|
12
12
|
*
|
|
13
13
|
* @export
|
|
14
14
|
* @param {CommonRequest} payload - The request data to be sent to the API
|
|
15
|
-
* @return {Promise<
|
|
15
|
+
* @return {Promise<EmissionResponse | EmissionResponseWithDetails>} A promise that resolves to the emission calculation result. Returns EmissionResponseWithDetails if includeDetails is true, otherwise EmissionResponse
|
|
16
16
|
* @throws {Error} May throw an error if the API request fails
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
@@ -45,7 +45,7 @@ async function calculate(payload) {
|
|
|
45
45
|
* Retrieves available fugitive emission calculation types by making a GET request to the API endpoint.
|
|
46
46
|
*
|
|
47
47
|
* @export
|
|
48
|
-
* @return {Promise<
|
|
48
|
+
* @return {Promise<TypeResponse>} A promise that resolves to a TypeResponse containing the available fugitive emission types
|
|
49
49
|
* @throws {Error} May throw an error if the API request fails
|
|
50
50
|
*
|
|
51
51
|
* @example
|
|
@@ -63,7 +63,7 @@ async function getTypes() {
|
|
|
63
63
|
* Retrieves information about geographical areas supported by the fugitive emissions API.
|
|
64
64
|
*
|
|
65
65
|
* @export
|
|
66
|
-
* @return {Promise<
|
|
66
|
+
* @return {Promise<AreaResponse>} A promise that resolves to an AreaResponse containing the supported geographical areas
|
|
67
67
|
* @throws {Error} May throw an error if the API request fails
|
|
68
68
|
*
|
|
69
69
|
* @example
|
|
@@ -82,7 +82,7 @@ async function getArea() {
|
|
|
82
82
|
*
|
|
83
83
|
* @export
|
|
84
84
|
* @param {string} type - The fugitive emission type to get units for (e.g., "R134A")
|
|
85
|
-
* @return {Promise<
|
|
85
|
+
* @return {Promise<UnitResponse>} A promise that resolves to a UnitResponse containing the available units
|
|
86
86
|
* @throws {Error} May throw an error if the API request fails
|
|
87
87
|
*
|
|
88
88
|
* @example
|
package/dist/api/Location.js
CHANGED
|
@@ -12,7 +12,7 @@ const request_1 = require("../request");
|
|
|
12
12
|
*
|
|
13
13
|
* @export
|
|
14
14
|
* @param {LocationRequest} payload - The location request data to be sent to the API
|
|
15
|
-
* @return {Promise<
|
|
15
|
+
* @return {Promise<EmissionResponse | EmissionResponseWithDetails>} A promise that resolves to the emission calculation result. Returns EmissionResponseWithDetails if includeDetails is true, otherwise EmissionResponse
|
|
16
16
|
* @throws {Error} May throw an error if the API request fails
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
@@ -46,7 +46,7 @@ async function calculate(payload) {
|
|
|
46
46
|
* Retrieves available location-based calculation types by making a GET request to the location types API endpoint.
|
|
47
47
|
*
|
|
48
48
|
* @export
|
|
49
|
-
* @return {Promise<
|
|
49
|
+
* @return {Promise<TypeResponse>} A promise that resolves to a TypeResponse containing the available location-based calculation types
|
|
50
50
|
* @throws {Error} May throw an error if the API request fails
|
|
51
51
|
*
|
|
52
52
|
* @example
|
|
@@ -65,7 +65,7 @@ async function getTypes() {
|
|
|
65
65
|
* Retrieves information about geographical areas supported by the location-based calculation API.
|
|
66
66
|
*
|
|
67
67
|
* @export
|
|
68
|
-
* @return {Promise<
|
|
68
|
+
* @return {Promise<AreaResponse>} A promise that resolves to an AreaResponse containing the supported geographical areas
|
|
69
69
|
* @throws {Error} May throw an error if the API request fails
|
|
70
70
|
*
|
|
71
71
|
* @example
|
|
@@ -84,7 +84,7 @@ async function getArea() {
|
|
|
84
84
|
*
|
|
85
85
|
* @export
|
|
86
86
|
* @param {string} type - The location-based calculation type to get units for (e.g., "electricity")
|
|
87
|
-
* @return {Promise<
|
|
87
|
+
* @return {Promise<UnitResponse>} A promise that resolves to a UnitResponse containing the available units
|
|
88
88
|
* @throws {Error} May throw an error if the API request fails
|
|
89
89
|
*
|
|
90
90
|
* @example
|
package/dist/api/Mobile.js
CHANGED
|
@@ -12,7 +12,7 @@ const Client_1 = require("../Client");
|
|
|
12
12
|
*
|
|
13
13
|
* @export
|
|
14
14
|
* @param {CommonRequest} payload - The request data to be sent to the mobile API
|
|
15
|
-
* @return {Promise<
|
|
15
|
+
* @return {Promise<EmissionResponse | EmissionResponseWithDetails>} A promise that resolves to the emission calculation result. Returns EmissionResponseWithDetails if includeDetails is true, otherwise EmissionResponse
|
|
16
16
|
* @throws {Error} May throw an error if the API request fails
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
@@ -46,14 +46,12 @@ async function calculate(payload) {
|
|
|
46
46
|
* Retrieves available mobile emission calculation types by making a GET request to the API endpoint.
|
|
47
47
|
*
|
|
48
48
|
* @export
|
|
49
|
-
* @return {Promise<
|
|
49
|
+
* @return {Promise<TypeResponse>} A promise that resolves to a TypeResponse containing the available mobile emission types
|
|
50
50
|
* @throws {Error} May throw an error if the API request fails
|
|
51
51
|
*
|
|
52
52
|
* @example
|
|
53
53
|
* // Get all available mobile emission types
|
|
54
54
|
* const types = await getTypes();
|
|
55
|
-
* const typesData = JSON.parse(types);
|
|
56
|
-
* console.log("Available mobile emission types:", typesData);
|
|
57
55
|
*/
|
|
58
56
|
async function getTypes() {
|
|
59
57
|
const client = Client_1.Client.getInstance();
|
|
@@ -67,7 +65,7 @@ async function getTypes() {
|
|
|
67
65
|
* Retrieves information about geographical areas supported by the mobile emissions API.
|
|
68
66
|
*
|
|
69
67
|
* @export
|
|
70
|
-
* @return {Promise<
|
|
68
|
+
* @return {Promise<AreaResponse>} A promise that resolves to an AreaResponse containing the supported geographical areas
|
|
71
69
|
* @throws {Error} May throw an error if the API request fails
|
|
72
70
|
*
|
|
73
71
|
* @example
|
|
@@ -86,7 +84,7 @@ async function getArea() {
|
|
|
86
84
|
*
|
|
87
85
|
* @export
|
|
88
86
|
* @param {string} type - The mobile emission type to get units for (e.g., "Diesel Fuel")
|
|
89
|
-
* @return {Promise<
|
|
87
|
+
* @return {Promise<UnitResponse>} A promise that resolves to a UnitResponse containing the available units
|
|
90
88
|
* @throws {Error} May throw an error if the API request fails
|
|
91
89
|
*
|
|
92
90
|
* @example
|
package/dist/api/Stationary.js
CHANGED
|
@@ -12,7 +12,7 @@ const request_1 = require("../request");
|
|
|
12
12
|
*
|
|
13
13
|
* @export
|
|
14
14
|
* @param {CommonRequest} payload - The request data to be sent to the stationary API
|
|
15
|
-
* @return {Promise<
|
|
15
|
+
* @return {Promise<EmissionResponse | EmissionResponseWithDetails>} A promise that resolves to the emission calculation result. Returns EmissionResponseWithDetails if includeDetails is true, otherwise EmissionResponse
|
|
16
16
|
* @throws {Error} May throw an error if the API request fails
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
@@ -46,7 +46,7 @@ async function calculate(payload) {
|
|
|
46
46
|
* Retrieves available stationary emission calculation types by making a GET request to the API endpoint.
|
|
47
47
|
*
|
|
48
48
|
* @export
|
|
49
|
-
* @return {Promise<
|
|
49
|
+
* @return {Promise<TypeResponse>} A promise that resolves to a TypeResponse containing the available stationary emission types
|
|
50
50
|
* @throws {Error} May throw an error if the API request fails
|
|
51
51
|
*
|
|
52
52
|
* @example
|
|
@@ -64,7 +64,7 @@ async function getTypes() {
|
|
|
64
64
|
* Retrieves information about geographical areas supported by the stationary emissions API.
|
|
65
65
|
*
|
|
66
66
|
* @export
|
|
67
|
-
* @return {Promise<
|
|
67
|
+
* @return {Promise<AreaResponse>} A promise that resolves to an AreaResponse containing the supported geographical areas
|
|
68
68
|
* @throws {Error} May throw an error if the API request fails
|
|
69
69
|
*
|
|
70
70
|
* @example
|
|
@@ -83,7 +83,7 @@ async function getArea() {
|
|
|
83
83
|
*
|
|
84
84
|
* @export
|
|
85
85
|
* @param {string} type - The stationary emission type to get units for (e.g., "Coal - Lignite")
|
|
86
|
-
* @return {Promise<
|
|
86
|
+
* @return {Promise<UnitResponse>} A promise that resolves to a UnitResponse containing the available units
|
|
87
87
|
* @throws {Error} May throw an error if the API request fails
|
|
88
88
|
*
|
|
89
89
|
* @example
|
|
@@ -8,11 +8,11 @@ const Client_1 = require("../Client");
|
|
|
8
8
|
const Constants_1 = require("../Constants");
|
|
9
9
|
const request_1 = require("../request");
|
|
10
10
|
/**
|
|
11
|
-
* Performs Scope
|
|
11
|
+
* Performs Scope 3 transportation and distribution emission calculations by making a POST request to the transportation and distribution API endpoint.
|
|
12
12
|
*
|
|
13
13
|
* @export
|
|
14
14
|
* @param {CalculationRequest} payload - The calculation request data for transportation and distribution operations
|
|
15
|
-
* @return {Promise<
|
|
15
|
+
* @return {Promise<EmissionResponse | EmissionResponseWithDetails>} A promise that resolves to the emission calculation result. Returns EmissionResponseWithDetails if includeDetails is true, otherwise EmissionResponse
|
|
16
16
|
* @throws {Error} May throw an error if the API request fails
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
@@ -45,7 +45,7 @@ async function calculate(payload) {
|
|
|
45
45
|
* Retrieves available transportation and distribution calculation types by making a GET request to the API endpoint.
|
|
46
46
|
*
|
|
47
47
|
* @export
|
|
48
|
-
* @return {Promise<
|
|
48
|
+
* @return {Promise<TypeResponse>} A promise that resolves to a TypeResponse containing the available transportation and distribution calculation types
|
|
49
49
|
* @throws {Error} May throw an error if the API request fails
|
|
50
50
|
*
|
|
51
51
|
* @example
|
|
@@ -63,7 +63,7 @@ async function getTypes() {
|
|
|
63
63
|
* Retrieves information about geographical areas supported by the transportation and distribution API.
|
|
64
64
|
*
|
|
65
65
|
* @export
|
|
66
|
-
* @return {Promise<
|
|
66
|
+
* @return {Promise<AreaResponse>} A promise that resolves to an AreaResponse containing the supported geographical areas
|
|
67
67
|
* @throws {Error} May throw an error if the API request fails
|
|
68
68
|
*
|
|
69
69
|
* @example
|
|
@@ -82,7 +82,7 @@ async function getArea() {
|
|
|
82
82
|
*
|
|
83
83
|
* @export
|
|
84
84
|
* @param {string} type - The transportation and distribution calculation type to get units for (e.g., "Freight - Cargo Ship")
|
|
85
|
-
* @return {Promise<
|
|
85
|
+
* @return {Promise<UnitResponse>} A promise that resolves to a UnitResponse containing the available units
|
|
86
86
|
* @throws {Error} May throw an error if the API request fails
|
|
87
87
|
*
|
|
88
88
|
* @example
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getUsage = getUsage;
|
|
4
|
+
const Client_1 = require("../Client");
|
|
5
|
+
const Constants_1 = require("../Constants");
|
|
6
|
+
const request_1 = require("../request");
|
|
7
|
+
/**
|
|
8
|
+
* Retrieves current billing period or historical usage data for the user by making a GET request to the API endpoint.
|
|
9
|
+
*
|
|
10
|
+
* @export
|
|
11
|
+
* @param {boolean} history - Flag to retrieve current billing or historical usage data.
|
|
12
|
+
* @return {Promise<UsageResponse>} A promise that resolves to a UsageResponse containing the organization's usage data
|
|
13
|
+
* @throws {Error} May throw an error if the API request fails
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* const usage = await getUsage();
|
|
17
|
+
*/
|
|
18
|
+
async function getUsage(history = false) {
|
|
19
|
+
const client = Client_1.Client.getInstance();
|
|
20
|
+
const url = client.getDomain() + Constants_1.USAGE_API;
|
|
21
|
+
return (0, request_1.makeApiRequest)({
|
|
22
|
+
method: Constants_1.GET,
|
|
23
|
+
url,
|
|
24
|
+
params: { history }
|
|
25
|
+
});
|
|
26
|
+
}
|