emissions-api-sdk 1.0.4 → 1.0.6
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 +19 -26
- package/dist/Constants.js +6 -23
- package/dist/api/Calculation.js +0 -63
- package/dist/api/EconomicActivity.js +40 -0
- package/dist/api/Factor.js +0 -82
- package/dist/api/Fugitive.js +0 -63
- package/dist/api/Location.js +0 -61
- package/dist/api/Metadata.js +155 -0
- package/dist/api/Mobile.js +0 -64
- package/dist/api/RealEstate.js +40 -0
- package/dist/api/Stationary.js +0 -63
- package/dist/api/TransportationAndDistribution.js +0 -63
- package/dist/coverage/clover.xml +144 -199
- package/dist/coverage/coverage-final.json +14 -11
- package/dist/coverage/lcov-report/index.html +20 -20
- package/dist/coverage/lcov-report/src/Client.ts.html +28 -28
- package/dist/coverage/lcov-report/src/Constants.ts.html +31 -88
- package/dist/coverage/lcov-report/src/api/Calculation.ts.html +7 -217
- package/dist/coverage/lcov-report/src/api/EconomicActivity.ts.html +220 -0
- package/dist/coverage/lcov-report/src/api/Factor.ts.html +6 -285
- package/dist/coverage/lcov-report/src/api/FactorSets.ts.html +1 -1
- package/dist/coverage/lcov-report/src/api/Fugitive.ts.html +7 -223
- package/dist/coverage/lcov-report/src/api/Location.ts.html +6 -222
- package/dist/coverage/lcov-report/src/api/Metadata.ts.html +604 -0
- package/dist/coverage/lcov-report/src/api/Mobile.ts.html +6 -231
- package/dist/coverage/lcov-report/src/api/RealEstate.ts.html +217 -0
- package/dist/coverage/lcov-report/src/api/Stationary.ts.html +6 -225
- package/dist/coverage/lcov-report/src/api/TransportationAndDistribution.ts.html +7 -223
- package/dist/coverage/lcov-report/src/api/Usage.ts.html +1 -1
- package/dist/coverage/lcov-report/src/api/index.html +72 -27
- package/dist/coverage/lcov-report/src/index.html +7 -7
- package/dist/coverage/lcov-report/src/request.ts.html +5 -5
- package/dist/coverage/lcov-report/src/utils.ts.html +6 -6
- package/dist/coverage/lcov-report/test/index.html +1 -1
- package/dist/coverage/lcov-report/test/mocks/CommonRequest.ts.html +1 -1
- package/dist/coverage/lcov-report/test/mocks/FactorRequest.ts.html +1 -1
- package/dist/coverage/lcov-report/test/mocks/GenericCalculationRequest.ts.html +1 -1
- package/dist/coverage/lcov-report/test/mocks/LocationRequest.ts.html +1 -1
- package/dist/coverage/lcov-report/test/mocks/SearchRequest.ts.html +1 -1
- package/dist/coverage/lcov-report/test/mocks/index.html +1 -1
- package/dist/coverage/lcov-report/test/testUtils.ts.html +1 -1
- package/dist/coverage/lcov.info +241 -294
- package/dist/index.js +4 -1
- package/dist/types/Constants.d.ts +5 -22
- package/dist/types/api/Calculation.d.ts +0 -41
- package/dist/types/api/EconomicActivity.d.ts +29 -0
- package/dist/types/api/Factor.d.ts +0 -52
- package/dist/types/api/Fugitive.d.ts +0 -41
- package/dist/types/api/Location.d.ts +0 -39
- package/dist/types/api/Metadata.d.ts +99 -0
- package/dist/types/api/Mobile.d.ts +0 -42
- package/dist/types/api/RealEstate.d.ts +29 -0
- package/dist/types/api/Stationary.d.ts +0 -41
- package/dist/types/api/TransportationAndDistribution.d.ts +0 -41
- package/dist/types/index.d.ts +3 -0
- package/dist/types/interfaces/response/FactorResponse.d.ts +0 -4
- package/docs/_sources/index.rst.txt +8 -6
- package/docs/_sources/reference.rst.txt +17 -37
- package/docs/_static/basic.css +8 -0
- package/docs/_static/pygments.css +146 -164
- package/docs/_static/searchtools.js +5 -8
- package/docs/_static/styles/furo.css +1 -1
- package/docs/_static/styles/furo.css.map +1 -1
- package/docs/authentication.html +28 -19
- package/docs/client.html +28 -19
- package/docs/genindex.html +56 -71
- package/docs/getting_started.html +28 -19
- package/docs/index.html +31 -20
- package/docs/objects.inv +0 -0
- package/docs/reference.html +151 -357
- package/docs/sdk.html +28 -19
- package/docs/search.html +28 -19
- package/docs/searchindex.js +1 -1
- package/docs/troubleshooting.html +28 -19
- package/package.json +7 -2
- package/sphinx-build/source/index.rst +8 -6
- package/sphinx-build/source/reference.rst +17 -37
- package/src/Constants.ts +6 -25
- package/src/api/Calculation.ts +1 -72
- package/src/api/EconomicActivity.ts +45 -0
- package/src/api/Factor.ts +1 -94
- package/src/api/Fugitive.ts +1 -74
- package/src/api/Location.ts +1 -73
- package/src/api/Metadata.ts +174 -0
- package/src/api/Mobile.ts +1 -76
- package/src/api/RealEstate.ts +45 -0
- package/src/api/Stationary.ts +1 -74
- package/src/api/TransportationAndDistribution.ts +1 -74
- package/src/index.ts +3 -0
- package/src/interfaces/response/FactorResponse.ts +0 -7
- package/test/apiTest.test.ts +19 -162
- package/test/metadata.test.ts +224 -0
- package/test/request.test.ts +0 -1
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { Client } from "../Client";
|
|
2
|
+
import { GET, METADATA_AREA_ENDPOINT, METADATA_TYPES_ENDPOINT, METADATA_UNITS_ENDPOINT, POST } from "../Constants";
|
|
3
|
+
import { AreaResponse } from "../interfaces/response/AreaResponse";
|
|
4
|
+
import { TypeResponse } from "../interfaces/response/TypeResponse";
|
|
5
|
+
import { UnitResponse } from "../interfaces/response/UnitResponse";
|
|
6
|
+
import { makeApiRequest } from "../request";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves available emission source types for a specific endpoint using GET request.
|
|
10
|
+
*
|
|
11
|
+
* @export
|
|
12
|
+
* @param {string} [endpoint] - The endpoint name to retrieve types for. Defaults to 'calculation' if not provided.
|
|
13
|
+
* @return {Promise<TypeResponse>} A promise that resolves to a TypeResponse containing the available types
|
|
14
|
+
* @throws {Error} May throw an error if the API request fails
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Get types for calculation endpoint (default)
|
|
18
|
+
* const types = await getTypes();
|
|
19
|
+
*
|
|
20
|
+
* // Get types for a specific endpoint
|
|
21
|
+
* const locationTypes = await getTypes('location');
|
|
22
|
+
*/
|
|
23
|
+
export async function getTypes(
|
|
24
|
+
endpoint?: string
|
|
25
|
+
): Promise<TypeResponse> {
|
|
26
|
+
const client = Client.getInstance();
|
|
27
|
+
const url = client.getDomain() + METADATA_TYPES_ENDPOINT;
|
|
28
|
+
|
|
29
|
+
return makeApiRequest<TypeResponse>({
|
|
30
|
+
method: GET,
|
|
31
|
+
url,
|
|
32
|
+
params: endpoint ? { endpoint } : undefined,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Retrieves available emission source types for a specific endpoint using POST request.
|
|
38
|
+
*
|
|
39
|
+
* @export
|
|
40
|
+
* @param {string} [endpoint] - The endpoint name to retrieve types for. Defaults to 'calculation' if not provided.
|
|
41
|
+
* @return {Promise<TypeResponse>} A promise that resolves to a TypeResponse containing the available types
|
|
42
|
+
* @throws {Error} May throw an error if the API request fails
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* // Get types for calculation endpoint (default)
|
|
46
|
+
* const types = await postTypes();
|
|
47
|
+
*
|
|
48
|
+
* // Get types for a specific endpoint
|
|
49
|
+
* const stationaryTypes = await postTypes('stationary');
|
|
50
|
+
*/
|
|
51
|
+
export async function postTypes(
|
|
52
|
+
endpoint?: string
|
|
53
|
+
): Promise<TypeResponse> {
|
|
54
|
+
const client = Client.getInstance();
|
|
55
|
+
const url = client.getDomain() + METADATA_TYPES_ENDPOINT;
|
|
56
|
+
|
|
57
|
+
return makeApiRequest<TypeResponse>({
|
|
58
|
+
method: POST,
|
|
59
|
+
url,
|
|
60
|
+
data: endpoint ? { endpoint } : {},
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Retrieves available geographic locations for a specific endpoint using GET request.
|
|
66
|
+
*
|
|
67
|
+
* @export
|
|
68
|
+
* @param {string} [endpoint] - The endpoint name to retrieve locations for. Defaults to 'calculation' if not provided.
|
|
69
|
+
* @return {Promise<AreaResponse>} A promise that resolves to an AreaResponse containing the available locations
|
|
70
|
+
* @throws {Error} May throw an error if the API request fails
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* // Get areas for calculation endpoint (default)
|
|
74
|
+
* const areas = await getArea();
|
|
75
|
+
*
|
|
76
|
+
* // Get areas for a specific endpoint
|
|
77
|
+
* const mobileAreas = await getArea('mobile');
|
|
78
|
+
*/
|
|
79
|
+
export async function getArea(
|
|
80
|
+
endpoint?: string
|
|
81
|
+
): Promise<AreaResponse> {
|
|
82
|
+
const client = Client.getInstance();
|
|
83
|
+
const url = client.getDomain() + METADATA_AREA_ENDPOINT;
|
|
84
|
+
|
|
85
|
+
return makeApiRequest<AreaResponse>({
|
|
86
|
+
method: GET,
|
|
87
|
+
url,
|
|
88
|
+
params: endpoint ? { endpoint } : undefined,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Retrieves available geographic locations for a specific endpoint using POST request.
|
|
94
|
+
*
|
|
95
|
+
* @export
|
|
96
|
+
* @param {string} [endpoint] - The endpoint name to retrieve locations for. Defaults to 'calculation' if not provided.
|
|
97
|
+
* @return {Promise<AreaResponse>} A promise that resolves to an AreaResponse containing the available locations
|
|
98
|
+
* @throws {Error} May throw an error if the API request fails
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* // Get areas for calculation endpoint (default)
|
|
102
|
+
* const areas = await postArea();
|
|
103
|
+
*
|
|
104
|
+
* // Get areas for a specific endpoint
|
|
105
|
+
* const fugitiveAreas = await postArea('fugitive');
|
|
106
|
+
*/
|
|
107
|
+
export async function postArea(
|
|
108
|
+
endpoint?: string
|
|
109
|
+
): Promise<AreaResponse> {
|
|
110
|
+
const client = Client.getInstance();
|
|
111
|
+
const url = client.getDomain() + METADATA_AREA_ENDPOINT;
|
|
112
|
+
|
|
113
|
+
return makeApiRequest<AreaResponse>({
|
|
114
|
+
method: POST,
|
|
115
|
+
url,
|
|
116
|
+
data: endpoint ? { endpoint } : {},
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Retrieves available measurement units for a specific type using GET request.
|
|
122
|
+
*
|
|
123
|
+
* @export
|
|
124
|
+
* @param {string} [type] - The emission source type to retrieve units for. If not provided, returns the full UOM table.
|
|
125
|
+
* @return {Promise<UnitResponse>} A promise that resolves to a UnitResponse containing the available units
|
|
126
|
+
* @throws {Error} May throw an error if the API request fails
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* // Get all units
|
|
130
|
+
* const allUnits = await getUnits();
|
|
131
|
+
*
|
|
132
|
+
* // Get units for a specific type
|
|
133
|
+
* const naturalGasUnits = await getUnits('Natural Gas');
|
|
134
|
+
*/
|
|
135
|
+
export async function getUnits(
|
|
136
|
+
type?: string
|
|
137
|
+
): Promise<UnitResponse> {
|
|
138
|
+
const client = Client.getInstance();
|
|
139
|
+
const url = client.getDomain() + METADATA_UNITS_ENDPOINT;
|
|
140
|
+
|
|
141
|
+
return makeApiRequest<UnitResponse>({
|
|
142
|
+
method: GET,
|
|
143
|
+
url,
|
|
144
|
+
params: type ? { type } : undefined,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Retrieves available measurement units for a specific type using POST request.
|
|
150
|
+
*
|
|
151
|
+
* @export
|
|
152
|
+
* @param {string} [type] - The emission source type to retrieve units for. If not provided, returns the full UOM table.
|
|
153
|
+
* @return {Promise<UnitResponse>} A promise that resolves to a UnitResponse containing the available units
|
|
154
|
+
* @throws {Error} May throw an error if the API request fails
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* // Get all units
|
|
158
|
+
* const allUnits = await postUnits();
|
|
159
|
+
*
|
|
160
|
+
* // Get units for a specific type
|
|
161
|
+
* const jetKeroseneUnits = await postUnits('Jet Kerosene');
|
|
162
|
+
*/
|
|
163
|
+
export async function postUnits(
|
|
164
|
+
type?: string
|
|
165
|
+
): Promise<UnitResponse> {
|
|
166
|
+
const client = Client.getInstance();
|
|
167
|
+
const url = client.getDomain() + METADATA_UNITS_ENDPOINT;
|
|
168
|
+
|
|
169
|
+
return makeApiRequest<UnitResponse>({
|
|
170
|
+
method: POST,
|
|
171
|
+
url,
|
|
172
|
+
data: type ? { type } : {},
|
|
173
|
+
});
|
|
174
|
+
}
|
package/src/api/Mobile.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { makeApiRequest } from "../request";
|
|
2
|
-
import {
|
|
2
|
+
import { MOBILE_API_PATH, POST } from "../Constants";
|
|
3
3
|
import { CommonRequest } from "../interfaces/Api";
|
|
4
|
-
import { AreaResponse } from "../interfaces/response/AreaResponse";
|
|
5
4
|
import { EmissionResponse } from "../interfaces/response/EmissionResponse";
|
|
6
5
|
import { EmissionResponseWithDetails } from "../interfaces/response/EmissionResponseWithDetails";
|
|
7
|
-
import { TypeResponse } from "../interfaces/response/TypeResponse";
|
|
8
|
-
import { UnitResponse } from "../interfaces/response/UnitResponse";
|
|
9
6
|
import { Client } from "../Client";
|
|
10
7
|
|
|
11
8
|
|
|
@@ -47,76 +44,4 @@ export async function calculate(
|
|
|
47
44
|
url,
|
|
48
45
|
data: payload,
|
|
49
46
|
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Retrieves available mobile emission calculation types by making a GET request to the API endpoint.
|
|
55
|
-
*
|
|
56
|
-
* @export
|
|
57
|
-
* @return {Promise<TypeResponse>} A promise that resolves to a TypeResponse containing the available mobile emission types
|
|
58
|
-
* @throws {Error} May throw an error if the API request fails
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* // Get all available mobile emission types
|
|
62
|
-
* const types = await getTypes();
|
|
63
|
-
*/
|
|
64
|
-
export async function getTypes(
|
|
65
|
-
): Promise<TypeResponse> {
|
|
66
|
-
const client = Client.getInstance();
|
|
67
|
-
const url = client.getDomain() + MOBILE_API_TYPES;
|
|
68
|
-
|
|
69
|
-
return makeApiRequest<TypeResponse>({
|
|
70
|
-
method: GET,
|
|
71
|
-
url
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Retrieves information about geographical areas supported by the mobile emissions API.
|
|
77
|
-
*
|
|
78
|
-
* @export
|
|
79
|
-
* @return {Promise<AreaResponse>} A promise that resolves to an AreaResponse containing the supported geographical areas
|
|
80
|
-
* @throws {Error} May throw an error if the API request fails
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
* const areas = await getArea();
|
|
84
|
-
*/
|
|
85
|
-
export async function getArea(
|
|
86
|
-
): Promise<AreaResponse> {
|
|
87
|
-
const client = Client.getInstance();
|
|
88
|
-
const url = client.getDomain() + MOBILE_API_AREA;
|
|
89
|
-
|
|
90
|
-
return makeApiRequest<AreaResponse>({
|
|
91
|
-
method: GET,
|
|
92
|
-
url
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Retrieves available units for a specific mobile emission type.
|
|
98
|
-
*
|
|
99
|
-
* @export
|
|
100
|
-
* @param {string} type - The mobile emission type to get units for (e.g., "Diesel Fuel")
|
|
101
|
-
* @return {Promise<UnitResponse>} A promise that resolves to a UnitResponse containing the available units
|
|
102
|
-
* @throws {Error} May throw an error if the API request fails
|
|
103
|
-
*
|
|
104
|
-
* @example
|
|
105
|
-
* Get units for the "Cars:B20:(NE)" emission mobile type with subtype
|
|
106
|
-
* const units = await getUnits("Cars:B20:(NE)");
|
|
107
|
-
|
|
108
|
-
* Get units for the "Cars by Size - Large Car - Hybrid" emission mobile type without subtype
|
|
109
|
-
* const units = await getUnits("Cars by Size - Large Car - Hybrid");
|
|
110
|
-
*/
|
|
111
|
-
export async function getUnits(
|
|
112
|
-
type : string
|
|
113
|
-
): Promise<UnitResponse> {
|
|
114
|
-
const client = Client.getInstance();
|
|
115
|
-
const url = client.getDomain() + MOBILE_API_UNITS;
|
|
116
|
-
|
|
117
|
-
return makeApiRequest<UnitResponse>({
|
|
118
|
-
method: GET,
|
|
119
|
-
url,
|
|
120
|
-
params : { type }
|
|
121
|
-
});
|
|
122
47
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Client } from "../Client";
|
|
2
|
+
import { REAL_ESTATE_API_PATH, POST } from "../Constants";
|
|
3
|
+
import { CommonRequest } from "../interfaces/Api";
|
|
4
|
+
import { EmissionResponse } from "../interfaces/response/EmissionResponse";
|
|
5
|
+
import { EmissionResponseWithDetails } from "../interfaces/response/EmissionResponseWithDetails";
|
|
6
|
+
import { makeApiRequest } from "../request";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Performs scope 3 Real estate emission calculations by making a POST request to the real estate API endpoint.
|
|
10
|
+
*
|
|
11
|
+
* @export
|
|
12
|
+
* @param {CommonRequest} payload - The request data to be sent to the API
|
|
13
|
+
* @return {Promise<EmissionResponse | EmissionResponseWithDetails>} A promise that resolves to the emission calculation result. Returns EmissionResponseWithDetails if includeDetails is true, otherwise EmissionResponse
|
|
14
|
+
* @throws {Error} May throw an error if the API request fails
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* const request = {
|
|
18
|
+
"time": {
|
|
19
|
+
"date": "2025-01-04"
|
|
20
|
+
},
|
|
21
|
+
"location": {
|
|
22
|
+
"country": "usa"
|
|
23
|
+
},
|
|
24
|
+
"activity": {
|
|
25
|
+
"type": "Commercial Real Estate:Industrial distribution warehouse",
|
|
26
|
+
"value": 17000.123,
|
|
27
|
+
"unit": "m2"
|
|
28
|
+
},
|
|
29
|
+
"includeDetails": false
|
|
30
|
+
};
|
|
31
|
+
* const result = await calculate(request);
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
export async function calculate(
|
|
35
|
+
payload: CommonRequest
|
|
36
|
+
): Promise<EmissionResponse | EmissionResponseWithDetails> {
|
|
37
|
+
const client = Client.getInstance();
|
|
38
|
+
const url = client.getDomain() + REAL_ESTATE_API_PATH;
|
|
39
|
+
|
|
40
|
+
return makeApiRequest<EmissionResponse | EmissionResponseWithDetails>({
|
|
41
|
+
method: POST,
|
|
42
|
+
url,
|
|
43
|
+
data: payload,
|
|
44
|
+
});
|
|
45
|
+
}
|
package/src/api/Stationary.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { Client } from "../Client";
|
|
2
|
-
import {
|
|
2
|
+
import { POST, STATIONARY_API_PATH } from "../Constants";
|
|
3
3
|
import { CommonRequest } from "../interfaces/Api";
|
|
4
|
-
import { AreaResponse } from "../interfaces/response/AreaResponse";
|
|
5
4
|
import { EmissionResponse } from "../interfaces/response/EmissionResponse";
|
|
6
5
|
import { EmissionResponseWithDetails } from "../interfaces/response/EmissionResponseWithDetails";
|
|
7
|
-
import { TypeResponse } from "../interfaces/response/TypeResponse";
|
|
8
|
-
import { UnitResponse } from "../interfaces/response/UnitResponse";
|
|
9
6
|
import { makeApiRequest } from "../request";
|
|
10
7
|
|
|
11
8
|
|
|
@@ -47,74 +44,4 @@ export async function calculate(
|
|
|
47
44
|
url,
|
|
48
45
|
data: payload,
|
|
49
46
|
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Retrieves available stationary emission calculation types by making a GET request to the API endpoint.
|
|
54
|
-
*
|
|
55
|
-
* @export
|
|
56
|
-
* @return {Promise<TypeResponse>} A promise that resolves to a TypeResponse containing the available stationary emission types
|
|
57
|
-
* @throws {Error} May throw an error if the API request fails
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* const types = await getTypes();
|
|
61
|
-
*/
|
|
62
|
-
export async function getTypes(
|
|
63
|
-
): Promise<TypeResponse> {
|
|
64
|
-
const client = Client.getInstance();
|
|
65
|
-
const url = client.getDomain() + STATIONARY_API_TYPES;
|
|
66
|
-
|
|
67
|
-
return makeApiRequest<TypeResponse>({
|
|
68
|
-
method: GET,
|
|
69
|
-
url
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Retrieves information about geographical areas supported by the stationary emissions API.
|
|
75
|
-
*
|
|
76
|
-
* @export
|
|
77
|
-
* @return {Promise<AreaResponse>} A promise that resolves to an AreaResponse containing the supported geographical areas
|
|
78
|
-
* @throws {Error} May throw an error if the API request fails
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
81
|
-
* const areas = await getArea();
|
|
82
|
-
*/
|
|
83
|
-
export async function getArea(
|
|
84
|
-
): Promise<AreaResponse> {
|
|
85
|
-
const client = Client.getInstance();
|
|
86
|
-
const url = client.getDomain() + STATIONARY_API_AREA;
|
|
87
|
-
|
|
88
|
-
return makeApiRequest<AreaResponse>({
|
|
89
|
-
method: GET,
|
|
90
|
-
url
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Retrieves available units for a specific stationary emission type.
|
|
96
|
-
*
|
|
97
|
-
* @export
|
|
98
|
-
* @param {string} type - The stationary emission type to get units for (e.g., "Coal - Lignite")
|
|
99
|
-
* @return {Promise<UnitResponse>} A promise that resolves to a UnitResponse containing the available units
|
|
100
|
-
* @throws {Error} May throw an error if the API request fails
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
* Get units for the "Petroleum Based Greases - NC:A" emission stationary type with subtype
|
|
104
|
-
* const units = await getUnits("Petroleum Based Greases - NC:A");
|
|
105
|
-
|
|
106
|
-
* Get units for the "Jet Kerosene" emission stationary type without subtype
|
|
107
|
-
* const units = await getUnits("Jet Kerosene");
|
|
108
|
-
*/
|
|
109
|
-
export async function getUnits(
|
|
110
|
-
type : string
|
|
111
|
-
): Promise<UnitResponse> {
|
|
112
|
-
const client = Client.getInstance();
|
|
113
|
-
const url = client.getDomain() + STATIONARY_API_UNITS;
|
|
114
|
-
|
|
115
|
-
return makeApiRequest<UnitResponse>({
|
|
116
|
-
method: GET,
|
|
117
|
-
url,
|
|
118
|
-
params : { type }
|
|
119
|
-
});
|
|
120
47
|
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { Client } from "../Client";
|
|
2
|
-
import { TRANSPORTATION_AND_DISTRIBUTION_API_PATH, POST
|
|
2
|
+
import { TRANSPORTATION_AND_DISTRIBUTION_API_PATH, POST } from "../Constants";
|
|
3
3
|
import { CalculationRequest } from "../interfaces/Api";
|
|
4
|
-
import { AreaResponse } from "../interfaces/response/AreaResponse";
|
|
5
4
|
import { EmissionResponse } from "../interfaces/response/EmissionResponse";
|
|
6
5
|
import { EmissionResponseWithDetails } from "../interfaces/response/EmissionResponseWithDetails";
|
|
7
|
-
import { TypeResponse } from "../interfaces/response/TypeResponse";
|
|
8
|
-
import { UnitResponse } from "../interfaces/response/UnitResponse";
|
|
9
6
|
import { makeApiRequest } from "../request";
|
|
10
7
|
|
|
11
8
|
/**
|
|
@@ -46,73 +43,3 @@ export async function calculate(
|
|
|
46
43
|
});
|
|
47
44
|
}
|
|
48
45
|
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Retrieves available transportation and distribution calculation types by making a GET request to the API endpoint.
|
|
52
|
-
*
|
|
53
|
-
* @export
|
|
54
|
-
* @return {Promise<TypeResponse>} A promise that resolves to a TypeResponse containing the available transportation and distribution calculation types
|
|
55
|
-
* @throws {Error} May throw an error if the API request fails
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* const types = await getTypes();
|
|
59
|
-
*/
|
|
60
|
-
export async function getTypes(
|
|
61
|
-
): Promise<TypeResponse> {
|
|
62
|
-
const client = Client.getInstance();
|
|
63
|
-
const url = client.getDomain() + TRANSPORTATION_AND_DISTRIBUTION_API_TYPES;
|
|
64
|
-
|
|
65
|
-
return makeApiRequest<TypeResponse>({
|
|
66
|
-
method: GET,
|
|
67
|
-
url
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Retrieves information about geographical areas supported by the transportation and distribution API.
|
|
73
|
-
*
|
|
74
|
-
* @export
|
|
75
|
-
* @return {Promise<AreaResponse>} A promise that resolves to an AreaResponse containing the supported geographical areas
|
|
76
|
-
* @throws {Error} May throw an error if the API request fails
|
|
77
|
-
*
|
|
78
|
-
* @example
|
|
79
|
-
* const areas = await getArea();
|
|
80
|
-
*/
|
|
81
|
-
export async function getArea(
|
|
82
|
-
): Promise<AreaResponse> {
|
|
83
|
-
const client = Client.getInstance();
|
|
84
|
-
const url = client.getDomain() + TRANSPORTATION_AND_DISTRIBUTION_API_AREA;
|
|
85
|
-
|
|
86
|
-
return makeApiRequest<AreaResponse>({
|
|
87
|
-
method: GET,
|
|
88
|
-
url
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Retrieves available units for a specific transportation and distribution calculation type.
|
|
94
|
-
*
|
|
95
|
-
* @export
|
|
96
|
-
* @param {string} type - The transportation and distribution calculation type to get units for (e.g., "Freight - Cargo Ship")
|
|
97
|
-
* @return {Promise<UnitResponse>} A promise that resolves to a UnitResponse containing the available units
|
|
98
|
-
* @throws {Error} May throw an error if the API request fails
|
|
99
|
-
*
|
|
100
|
-
* @example
|
|
101
|
-
* // Get units for the "Business Travel - Cars:Diesel - Small" transportation and distribution type without subtype
|
|
102
|
-
* const units = await getUnits("Business Travel - Cars:Diesel - Small");
|
|
103
|
-
*
|
|
104
|
-
* // Get units for the "Business Travel - Cars" transportation and distribution type with subtype
|
|
105
|
-
* const units = await getUnits("Business Travel - Cars");
|
|
106
|
-
*/
|
|
107
|
-
export async function getUnits(
|
|
108
|
-
type : string
|
|
109
|
-
): Promise<UnitResponse> {
|
|
110
|
-
const client = Client.getInstance();
|
|
111
|
-
const url = client.getDomain() + TRANSPORTATION_AND_DISTRIBUTION_API_UNITS;
|
|
112
|
-
|
|
113
|
-
return makeApiRequest<UnitResponse>({
|
|
114
|
-
method: GET,
|
|
115
|
-
url,
|
|
116
|
-
params : { type }
|
|
117
|
-
});
|
|
118
|
-
}
|
package/src/index.ts
CHANGED
|
@@ -8,6 +8,9 @@ export * as TransportationAndDistribution from './api/TransportationAndDistribut
|
|
|
8
8
|
export * as Usage from './api/Usage'
|
|
9
9
|
export * as Factor from './api/Factor';
|
|
10
10
|
export * as FactorSets from './api/FactorSets'
|
|
11
|
+
export * as EconomicActivity from './api/EconomicActivity';
|
|
12
|
+
export * as RealEstate from './api/RealEstate';
|
|
13
|
+
export * as Metadata from './api/Metadata';
|
|
11
14
|
export { ClientConfig } from './interfaces/Config';
|
|
12
15
|
|
|
13
16
|
// Response interfaces
|
|
@@ -62,13 +62,6 @@ export interface FactorResponse {
|
|
|
62
62
|
|
|
63
63
|
/** Publication end date in ISO format (optional) */
|
|
64
64
|
publishedTo?: string;
|
|
65
|
-
|
|
66
|
-
/** Effective start date in ISO format (optional) */
|
|
67
|
-
effectiveFrom?: string;
|
|
68
|
-
|
|
69
|
-
/** Effective end date in ISO format (optional) */
|
|
70
|
-
effectiveTo?: string;
|
|
71
|
-
|
|
72
65
|
|
|
73
66
|
/** Geographic region (e.g., "Earth", "India") */
|
|
74
67
|
region: string;
|