emissions-api-sdk 1.0.5 → 1.0.7
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/.secrets.baseline +314 -0
- package/README.md +20 -27
- package/dist/Constants.js +5 -29
- package/dist/api/Calculation.js +0 -63
- package/dist/api/EconomicActivity.js +0 -60
- 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 +0 -61
- package/dist/api/Stationary.js +0 -63
- package/dist/api/TransportationAndDistribution.js +0 -63
- package/dist/api/TypeRecommender.js +62 -0
- package/dist/coverage/clover.xml +142 -238
- package/dist/coverage/coverage-final.json +15 -13
- 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 -106
- package/dist/coverage/lcov-report/src/api/Calculation.ts.html +7 -217
- package/dist/coverage/lcov-report/src/api/EconomicActivity.ts.html +7 -214
- 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 +6 -219
- 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/TypeRecommender.ts.html +277 -0
- package/dist/coverage/lcov-report/src/api/Usage.ts.html +1 -1
- package/dist/coverage/lcov-report/src/api/index.html +63 -33
- 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 +239 -353
- package/dist/index.js +3 -1
- package/dist/interfaces/response/TypeRecommenderResponse.js +2 -0
- package/dist/types/Constants.d.ts +4 -28
- package/dist/types/api/Calculation.d.ts +0 -41
- package/dist/types/api/EconomicActivity.d.ts +0 -38
- 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 +0 -39
- package/dist/types/api/Stationary.d.ts +0 -41
- package/dist/types/api/TransportationAndDistribution.d.ts +0 -41
- package/dist/types/api/TypeRecommender.d.ts +50 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/interfaces/response/TypeRecommenderResponse.d.ts +14 -0
- package/docs/_sources/reference.rst.txt +14 -50
- 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 +41 -84
- package/docs/getting_started.html +28 -19
- package/docs/index.html +29 -20
- package/docs/objects.inv +0 -0
- package/docs/reference.html +102 -502
- 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 +10 -7
- package/sphinx-build/requirements.txt +1 -0
- package/sphinx-build/source/reference.rst +14 -50
- package/src/Constants.ts +5 -30
- package/src/api/Calculation.ts +1 -72
- package/src/api/EconomicActivity.ts +1 -71
- 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 +1 -72
- package/src/api/Stationary.ts +1 -74
- package/src/api/TransportationAndDistribution.ts +1 -74
- package/src/api/TypeRecommender.ts +65 -0
- package/src/index.ts +4 -1
- package/src/interfaces/response/TypeRecommenderResponse.ts +18 -0
- package/test/apiTest.test.ts +9 -205
- package/test/metadata.test.ts +224 -0
- package/test/request.test.ts +0 -1
- package/sphinx-build/.secrets.baseline +0 -150
|
@@ -31,73 +31,37 @@ API
|
|
|
31
31
|
|
|
32
32
|
.. js:autofunction:: EconomicActivity.calculate
|
|
33
33
|
|
|
34
|
-
Metadata APIs
|
|
35
|
-
===========
|
|
36
|
-
|
|
37
|
-
getTypes
|
|
38
|
-
--------
|
|
39
|
-
|
|
40
|
-
.. js:autofunction:: Factor.getTypes
|
|
41
|
-
|
|
42
|
-
.. js:autofunction:: Calculation.getTypes
|
|
43
34
|
|
|
44
|
-
|
|
35
|
+
Global Metadata API
|
|
36
|
+
====================
|
|
45
37
|
|
|
46
|
-
|
|
38
|
+
The global Metadata API provides a unified way to query metadata across different endpoints without calling endpoint-specific methods.
|
|
47
39
|
|
|
48
|
-
|
|
40
|
+
- **getTypes/postTypes** and **getArea/postArea**: Accept an optional ``endpoint`` parameter to query metadata for specific endpoints
|
|
41
|
+
- **getUnits/postUnits**: Accept an optional ``type`` parameter to query units for specific emission types
|
|
49
42
|
|
|
50
|
-
|
|
43
|
+
**Supported endpoints** (for getTypes/postTypes and getArea/postArea): ``calculation``, ``location``, ``stationary``, ``mobile``, ``fugitive``, ``factor``, ``search``, ``transportation-and-distribution``, ``economic-activity``, ``real-estate``
|
|
51
44
|
|
|
52
|
-
|
|
45
|
+
getTypes
|
|
46
|
+
--------
|
|
53
47
|
|
|
54
|
-
.. js:autofunction::
|
|
48
|
+
.. js:autofunction:: Metadata.getTypes
|
|
55
49
|
|
|
56
|
-
.. js:autofunction::
|
|
50
|
+
.. js:autofunction:: Metadata.postTypes
|
|
57
51
|
|
|
58
52
|
getArea
|
|
59
53
|
-------
|
|
60
54
|
|
|
61
|
-
.. js:autofunction::
|
|
62
|
-
|
|
63
|
-
.. js:autofunction:: Factor.getSearchArea
|
|
64
|
-
|
|
65
|
-
.. js:autofunction:: Calculation.getArea
|
|
66
|
-
|
|
67
|
-
.. js:autofunction:: Location.getArea
|
|
68
|
-
|
|
69
|
-
.. js:autofunction:: Mobile.getArea
|
|
55
|
+
.. js:autofunction:: Metadata.getArea
|
|
70
56
|
|
|
71
|
-
.. js:autofunction::
|
|
72
|
-
|
|
73
|
-
.. js:autofunction:: TransportationAndDistribution.getArea
|
|
74
|
-
|
|
75
|
-
.. js:autofunction:: Fugitive.getArea
|
|
76
|
-
|
|
77
|
-
.. js:autofunction:: RealEstate.getArea
|
|
78
|
-
|
|
79
|
-
.. js:autofunction:: EconomicActivity.getArea
|
|
57
|
+
.. js:autofunction:: Metadata.postArea
|
|
80
58
|
|
|
81
59
|
getUnits
|
|
82
60
|
--------
|
|
83
61
|
|
|
84
|
-
.. js:autofunction::
|
|
85
|
-
|
|
86
|
-
.. js:autofunction:: Calculation.getUnits
|
|
87
|
-
|
|
88
|
-
.. js:autofunction:: Location.getUnits
|
|
89
|
-
|
|
90
|
-
.. js:autofunction:: Mobile.getUnits
|
|
91
|
-
|
|
92
|
-
.. js:autofunction:: Stationary.getUnits
|
|
93
|
-
|
|
94
|
-
.. js:autofunction:: TransportationAndDistribution.getUnits
|
|
95
|
-
|
|
96
|
-
.. js:autofunction:: Fugitive.getUnits
|
|
97
|
-
|
|
98
|
-
.. js:autofunction:: RealEstate.getUnits
|
|
62
|
+
.. js:autofunction:: Metadata.getUnits
|
|
99
63
|
|
|
100
|
-
.. js:autofunction::
|
|
64
|
+
.. js:autofunction:: Metadata.postUnits
|
|
101
65
|
|
|
102
66
|
|
|
103
67
|
Usage API
|
package/src/Constants.ts
CHANGED
|
@@ -12,39 +12,14 @@ export const SEARCH_API_PATH = "/v3/carbon/factor/search";
|
|
|
12
12
|
export const ECONOMIC_ACTIVITY_API_PATH = "/v3/carbon/economic-activity";
|
|
13
13
|
export const REAL_ESTATE_API_PATH = "/v3/carbon/real-estate";
|
|
14
14
|
|
|
15
|
-
export const
|
|
16
|
-
export const LOCATION_TYPES = "/v3/carbon/location/types";
|
|
17
|
-
export const FUGITIVE_API_TYPES = "/v3/carbon/fugitive/types";
|
|
18
|
-
export const MOBILE_API_TYPES = "/v3/carbon/mobile/types";
|
|
19
|
-
export const STATIONARY_API_TYPES = "/v3/carbon/stationary/types";
|
|
20
|
-
export const FACTOR_API_TYPES = "/v3/carbon/factor/types";
|
|
21
|
-
export const TRANSPORTATION_AND_DISTRIBUTION_API_TYPES = "/v3/carbon/transportation-and-distribution/types";
|
|
22
|
-
export const REAL_ESTATE_API_TYPES = "/v3/carbon/real-estate/types";
|
|
23
|
-
export const ECONOMIC_ACTIVITY_API_TYPES = "/v3/carbon/economic-activity/types";
|
|
24
|
-
|
|
25
|
-
export const FUGITIVE_API_AREA = "/v3/carbon/fugitive/area";
|
|
26
|
-
export const GENERAL_API_AREA = "/v3/carbon/calculation/area";
|
|
27
|
-
export const LOCATION_API_AREA = "/v3/carbon/location/area";
|
|
28
|
-
export const MOBILE_API_AREA = "/v3/carbon/mobile/area";
|
|
29
|
-
export const STATIONARY_API_AREA = "/v3/carbon/stationary/area";
|
|
30
|
-
export const TRANSPORTATION_AND_DISTRIBUTION_API_AREA = "/v3/carbon/transportation-and-distribution/area";
|
|
31
|
-
export const SEARCH_API_AREA = "/v3/carbon/factor/search/area";
|
|
32
|
-
export const FACTOR_API_AREA = "/v3/carbon/factor/area";
|
|
33
|
-
export const REAL_ESTATE_API_AREA = "/v3/carbon/real-estate/area";
|
|
34
|
-
export const ECONOMIC_ACTIVITY_API_AREA = "/v3/carbon/economic-activity/area";
|
|
35
|
-
|
|
36
|
-
export const FUGITIVE_API_UNITS = "/v3/carbon/fugitive/units";
|
|
37
|
-
export const LOCATION_API_UNITS = "/v3/carbon/location/units";
|
|
38
|
-
export const MOBILE_API_UNITS = "/v3/carbon/mobile/units";
|
|
39
|
-
export const STATIONARY_API_UNITS = "/v3/carbon/stationary/units";
|
|
40
|
-
export const GENERAL_API_UNITS = "/v3/carbon/calculation/units";
|
|
41
|
-
export const FACTOR_API_UNITS = "/v3/carbon/factor/units";
|
|
42
|
-
export const TRANSPORTATION_AND_DISTRIBUTION_API_UNITS = "/v3/carbon/transportation-and-distribution/units";
|
|
43
|
-
export const REAL_ESTATE_API_UNITS = "/v3/carbon/real-estate/units";
|
|
44
|
-
export const ECONOMIC_ACTIVITY_API_UNITS = "/v3/carbon/economic-activity/units";
|
|
15
|
+
export const TYPE_RECOMMENDER_API_PATH = "/v3/carbon/recommender/type/search";
|
|
45
16
|
|
|
46
17
|
export const USAGE_API = "/v3/carbon/usage";
|
|
47
18
|
|
|
19
|
+
export const METADATA_TYPES_ENDPOINT = "/v3/carbon/metadata/types";
|
|
20
|
+
export const METADATA_AREA_ENDPOINT = "/v3/carbon/metadata/area";
|
|
21
|
+
export const METADATA_UNITS_ENDPOINT = "/v3/carbon/metadata/units";
|
|
22
|
+
|
|
48
23
|
export const GET = "GET";
|
|
49
24
|
export const POST = "POST";
|
|
50
25
|
export const CLIENT_SOURCE_HEADER = "X-Client-Source";
|
package/src/api/Calculation.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { Client } from "../Client";
|
|
2
|
-
import { GENERIC_CALCULATION_API_PATH,
|
|
2
|
+
import { GENERIC_CALCULATION_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
|
|
|
@@ -48,71 +45,3 @@ export async function calculate(
|
|
|
48
45
|
});
|
|
49
46
|
}
|
|
50
47
|
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Retrieves available calculation types by making a GET request to the calculation types API endpoint.
|
|
54
|
-
*
|
|
55
|
-
* @export
|
|
56
|
-
* @return {Promise<TypeResponse>} A promise that resolves to a TypeResponse containing the available calculation 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(): Promise<TypeResponse> {
|
|
63
|
-
const client = Client.getInstance();
|
|
64
|
-
const url = client.getDomain() + CALCULATION_TYPES;
|
|
65
|
-
|
|
66
|
-
return makeApiRequest<TypeResponse>({
|
|
67
|
-
method: GET,
|
|
68
|
-
url
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Retrieves information about geographical areas supported by the calculation API.
|
|
74
|
-
*
|
|
75
|
-
* @export
|
|
76
|
-
* @return {Promise<AreaResponse>} A promise that resolves to an AreaResponse containing the supported geographical areas
|
|
77
|
-
* @throws {Error} May throw an error if the API request fails
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
* const areas = await getArea();
|
|
81
|
-
*/
|
|
82
|
-
export async function getArea(): Promise<AreaResponse> {
|
|
83
|
-
const client = Client.getInstance();
|
|
84
|
-
const url = client.getDomain() + GENERAL_API_AREA;
|
|
85
|
-
|
|
86
|
-
return makeApiRequest<AreaResponse>({
|
|
87
|
-
method: GET,
|
|
88
|
-
url
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Retrieves available units for a specific calculation type.
|
|
94
|
-
*
|
|
95
|
-
* @export
|
|
96
|
-
* @param {string} type - The calculation type to get units for
|
|
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 "Natural Gas - Scope 3:AAA" emission calculation type with subtype
|
|
102
|
-
* const units = await getUnits("Natural Gas - Scope 3:AAA");
|
|
103
|
-
|
|
104
|
-
* // Get units for the "HFC-263fb" emission calculation type without subtype
|
|
105
|
-
* const units = await getUnits("HFC-263fb");
|
|
106
|
-
*/
|
|
107
|
-
export async function getUnits(
|
|
108
|
-
type: string
|
|
109
|
-
): Promise<UnitResponse> {
|
|
110
|
-
const client = Client.getInstance();
|
|
111
|
-
const url = client.getDomain() + GENERAL_API_UNITS;
|
|
112
|
-
|
|
113
|
-
return makeApiRequest<UnitResponse>({
|
|
114
|
-
method: GET,
|
|
115
|
-
url,
|
|
116
|
-
params : { type }
|
|
117
|
-
});
|
|
118
|
-
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { Client } from "../Client";
|
|
2
|
-
import { ECONOMIC_ACTIVITY_API_PATH,
|
|
2
|
+
import { ECONOMIC_ACTIVITY_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 { makeApiRequest } from "../request";
|
|
10
7
|
|
|
11
8
|
/**
|
|
@@ -46,70 +43,3 @@ export async function calculate(
|
|
|
46
43
|
data: payload,
|
|
47
44
|
});
|
|
48
45
|
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Retrieves available economic activity emission 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 economic activity emission 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() + ECONOMIC_ACTIVITY_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 economic activity emissions 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() + ECONOMIC_ACTIVITY_API_AREA;
|
|
85
|
-
|
|
86
|
-
return makeApiRequest<AreaResponse>({
|
|
87
|
-
method: GET,
|
|
88
|
-
url
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Retrieves available units for a specific economic activity emission type.
|
|
94
|
-
*
|
|
95
|
-
* @export
|
|
96
|
-
* @param {string} type - The economic activity emission type to get units for (e.g., "accomodation")
|
|
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 "accomodation" emission economic activity type without subtype
|
|
102
|
-
* const units = await getUnits("accomodation");
|
|
103
|
-
*/
|
|
104
|
-
export async function getUnits(
|
|
105
|
-
type : string
|
|
106
|
-
): Promise<UnitResponse> {
|
|
107
|
-
const client = Client.getInstance();
|
|
108
|
-
const url = client.getDomain() + ECONOMIC_ACTIVITY_API_UNITS;
|
|
109
|
-
|
|
110
|
-
return makeApiRequest<UnitResponse>({
|
|
111
|
-
method: GET,
|
|
112
|
-
url,
|
|
113
|
-
params : { type }
|
|
114
|
-
});
|
|
115
|
-
}
|
package/src/api/Factor.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { Client } from "../Client";
|
|
2
|
-
import {
|
|
2
|
+
import { FACTOR_API_PATH, POST, SEARCH_API_PATH } from "../Constants";
|
|
3
3
|
import { FactorRequest, SearchRequest } from "../interfaces/Api";
|
|
4
|
-
import { AreaResponse } from "../interfaces/response/AreaResponse";
|
|
5
4
|
import { FactorResponse } from "../interfaces/response/FactorResponse";
|
|
6
5
|
import { SearchResponse } from "../interfaces/response/SearchResponse";
|
|
7
|
-
import { TypeResponse } from "../interfaces/response/TypeResponse";
|
|
8
|
-
import { UnitResponse } from "../interfaces/response/UnitResponse";
|
|
9
6
|
import { makeApiRequest } from "../request";
|
|
10
7
|
|
|
11
8
|
/**
|
|
@@ -87,94 +84,4 @@ export async function search(
|
|
|
87
84
|
url,
|
|
88
85
|
data: payload,
|
|
89
86
|
});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Retrieves available emission factor types by making a GET request to the API endpoint.
|
|
94
|
-
*
|
|
95
|
-
* @export
|
|
96
|
-
* @return {Promise<TypeResponse>} A promise that resolves to a TypeResponse containing the available emission factor types
|
|
97
|
-
* @throws {Error} May throw an error if the API request fails
|
|
98
|
-
*
|
|
99
|
-
* @example
|
|
100
|
-
* const types = await getTypes();
|
|
101
|
-
*/
|
|
102
|
-
export async function getTypes(
|
|
103
|
-
): Promise<TypeResponse> {
|
|
104
|
-
const client = Client.getInstance();
|
|
105
|
-
const url = client.getDomain() + FACTOR_API_TYPES;
|
|
106
|
-
|
|
107
|
-
return makeApiRequest<TypeResponse>({
|
|
108
|
-
method: GET,
|
|
109
|
-
url
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Retrieves information about geographical areas supported by the factor search API.
|
|
115
|
-
*
|
|
116
|
-
* @export
|
|
117
|
-
* @return {Promise<AreaResponse>} A promise that resolves to an AreaResponse containing the supported geographical areas
|
|
118
|
-
* @throws {Error} May throw an error if the API request fails
|
|
119
|
-
*
|
|
120
|
-
* @example
|
|
121
|
-
* const areas = await getSearchArea();
|
|
122
|
-
*/
|
|
123
|
-
export async function getSearchArea(
|
|
124
|
-
): Promise<AreaResponse> {
|
|
125
|
-
const client = Client.getInstance();
|
|
126
|
-
const url = client.getDomain() + SEARCH_API_AREA;
|
|
127
|
-
|
|
128
|
-
return makeApiRequest<AreaResponse>({
|
|
129
|
-
method: GET,
|
|
130
|
-
url
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Retrieves information about geographical areas supported by the factor API.
|
|
136
|
-
*
|
|
137
|
-
* @export
|
|
138
|
-
* @return {Promise<AreaResponse>} A promise that resolves to an AreaResponse containing the supported geographical areas
|
|
139
|
-
* @throws {Error} May throw an error if the API request fails
|
|
140
|
-
*
|
|
141
|
-
* @example
|
|
142
|
-
* const areas = await getArea();
|
|
143
|
-
*/
|
|
144
|
-
export async function getArea(): Promise<AreaResponse> {
|
|
145
|
-
const client = Client.getInstance();
|
|
146
|
-
const url = client.getDomain() + FACTOR_API_AREA;
|
|
147
|
-
|
|
148
|
-
return makeApiRequest<AreaResponse>({
|
|
149
|
-
method: GET,
|
|
150
|
-
url
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Retrieves available units for a specific emission factor type.
|
|
156
|
-
*
|
|
157
|
-
* @export
|
|
158
|
-
* @param {string} type - The emission factor type to get units for (e.g., "Natural Gas - Scope 3:AAA")
|
|
159
|
-
* @return {Promise<UnitResponse>} A promise that resolves to a UnitResponse containing the available units
|
|
160
|
-
* @throws {Error} May throw an error if the API request fails
|
|
161
|
-
*
|
|
162
|
-
* @example
|
|
163
|
-
* // Get units for the "Natural Gas - Scope 3:AAA" emission factor type with subtype
|
|
164
|
-
* const units = await getUnits("Natural Gas - Scope 3:AAA");
|
|
165
|
-
|
|
166
|
-
* // Get units for the "HFC-263fb" emission factor type without subtype
|
|
167
|
-
* const units = await getUnits("HFC-263fb");
|
|
168
|
-
*/
|
|
169
|
-
export async function getUnits(
|
|
170
|
-
type : string
|
|
171
|
-
): Promise<UnitResponse> {
|
|
172
|
-
const client = Client.getInstance();
|
|
173
|
-
const url = client.getDomain() + FACTOR_API_UNITS;
|
|
174
|
-
|
|
175
|
-
return makeApiRequest<UnitResponse>({
|
|
176
|
-
method: GET,
|
|
177
|
-
url,
|
|
178
|
-
params : { type }
|
|
179
|
-
});
|
|
180
87
|
}
|
package/src/api/Fugitive.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { Client } from "../Client";
|
|
2
|
-
import {
|
|
2
|
+
import { FUGITIVE_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 { makeApiRequest } from "../request";
|
|
10
7
|
|
|
11
8
|
/**
|
|
@@ -46,73 +43,3 @@ export async function calculate(
|
|
|
46
43
|
data: payload,
|
|
47
44
|
});
|
|
48
45
|
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Retrieves available fugitive emission 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 fugitive emission 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() + FUGITIVE_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 fugitive emissions 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() + FUGITIVE_API_AREA;
|
|
85
|
-
|
|
86
|
-
return makeApiRequest<AreaResponse>({
|
|
87
|
-
method: GET,
|
|
88
|
-
url
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Retrieves available units for a specific fugitive emission type.
|
|
94
|
-
*
|
|
95
|
-
* @export
|
|
96
|
-
* @param {string} type - The fugitive emission type to get units for (e.g., "R134A")
|
|
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 "Natural Gas - Scope 3:AAA" emission fugitive type with subtype
|
|
102
|
-
* const units = await getUnits("Natural Gas - Scope 3:AAA");
|
|
103
|
-
|
|
104
|
-
* // Get units for the "R-426A" emission fugitive type without subtype
|
|
105
|
-
* const units = await getUnits("R-426A");
|
|
106
|
-
*/
|
|
107
|
-
export async function getUnits(
|
|
108
|
-
type : string
|
|
109
|
-
): Promise<UnitResponse> {
|
|
110
|
-
const client = Client.getInstance();
|
|
111
|
-
const url = client.getDomain() + FUGITIVE_API_UNITS;
|
|
112
|
-
|
|
113
|
-
return makeApiRequest<UnitResponse>({
|
|
114
|
-
method: GET,
|
|
115
|
-
url,
|
|
116
|
-
params : { type }
|
|
117
|
-
});
|
|
118
|
-
}
|
package/src/api/Location.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { Client } from "../Client";
|
|
2
|
-
import {
|
|
2
|
+
import { LOCATION_API_PATH, POST } from "../Constants";
|
|
3
3
|
import { LocationRequest } 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
|
/**
|
|
@@ -45,73 +42,4 @@ export async function calculate(
|
|
|
45
42
|
url,
|
|
46
43
|
data: payload,
|
|
47
44
|
});
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Retrieves available location-based calculation types by making a GET request to the location types API endpoint.
|
|
53
|
-
*
|
|
54
|
-
* @export
|
|
55
|
-
* @return {Promise<TypeResponse>} A promise that resolves to a TypeResponse containing the available location-based calculation types
|
|
56
|
-
* @throws {Error} May throw an error if the API request fails
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
*
|
|
60
|
-
* const types = await getTypes();
|
|
61
|
-
*/
|
|
62
|
-
export async function getTypes(
|
|
63
|
-
): Promise<TypeResponse> {
|
|
64
|
-
const client = Client.getInstance();
|
|
65
|
-
const url = client.getDomain() + LOCATION_TYPES;
|
|
66
|
-
|
|
67
|
-
return makeApiRequest<TypeResponse>({
|
|
68
|
-
method: GET,
|
|
69
|
-
url
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Retrieves information about geographical areas supported by the location-based calculation 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() + LOCATION_API_AREA;
|
|
87
|
-
|
|
88
|
-
return makeApiRequest<AreaResponse>({
|
|
89
|
-
method: GET,
|
|
90
|
-
url
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Retrieves available units for a specific location-based calculation type.
|
|
96
|
-
*
|
|
97
|
-
* @export
|
|
98
|
-
* @param {string} type - The location-based calculation type to get units for (e.g., "electricity")
|
|
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 "electricity" location type
|
|
104
|
-
* const units = await getUnits("electricity");
|
|
105
|
-
*/
|
|
106
|
-
export async function getUnits(
|
|
107
|
-
type : string
|
|
108
|
-
): Promise<UnitResponse> {
|
|
109
|
-
const client = Client.getInstance();
|
|
110
|
-
const url = client.getDomain() + LOCATION_API_UNITS;
|
|
111
|
-
|
|
112
|
-
return makeApiRequest<UnitResponse>({
|
|
113
|
-
method: GET,
|
|
114
|
-
url,
|
|
115
|
-
params : { type }
|
|
116
|
-
});
|
|
117
45
|
}
|