emissions-api-sdk 1.0.0 → 1.0.2

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.
Files changed (155) hide show
  1. package/README.md +33 -2
  2. package/dist/Constants.js +23 -1
  3. package/dist/api/Calculation.js +78 -15
  4. package/dist/api/Factor.js +99 -18
  5. package/dist/api/FactorSets.js +1 -1
  6. package/dist/api/Fugitive.js +76 -13
  7. package/dist/api/Location.js +76 -15
  8. package/dist/api/Mobile.js +65 -1
  9. package/dist/api/Stationary.js +78 -15
  10. package/dist/api/TransportationAndDistribution.js +77 -14
  11. package/dist/coverage/clover.xml +191 -81
  12. package/dist/coverage/coverage-final.json +11 -11
  13. package/dist/coverage/lcov-report/index.html +16 -16
  14. package/dist/coverage/lcov-report/src/Client.ts.html +23 -23
  15. package/dist/coverage/lcov-report/src/Constants.ts.html +82 -4
  16. package/dist/coverage/lcov-report/src/api/Calculation.ts.html +245 -26
  17. package/dist/coverage/lcov-report/src/api/Factor.ts.html +313 -34
  18. package/dist/coverage/lcov-report/src/api/FactorSets.ts.html +8 -5
  19. package/dist/coverage/lcov-report/src/api/Fugitive.ts.html +246 -24
  20. package/dist/coverage/lcov-report/src/api/Location.ts.html +245 -26
  21. package/dist/coverage/lcov-report/src/api/Mobile.ts.html +240 -12
  22. package/dist/coverage/lcov-report/src/api/Stationary.ts.html +248 -26
  23. package/dist/coverage/lcov-report/src/api/TransportationAndDistribution.ts.html +250 -25
  24. package/dist/coverage/lcov-report/src/api/index.html +25 -25
  25. package/dist/coverage/lcov-report/src/index.html +7 -7
  26. package/dist/coverage/lcov-report/src/request.ts.html +1 -1
  27. package/dist/coverage/lcov-report/src/utils.ts.html +5 -5
  28. package/dist/coverage/lcov-report/test/index.html +1 -1
  29. package/dist/coverage/lcov-report/test/mocks/CommonRequest.ts.html +1 -1
  30. package/dist/coverage/lcov-report/test/mocks/FactorRequest.ts.html +1 -1
  31. package/dist/coverage/lcov-report/test/mocks/GenericCalculationRequest.ts.html +1 -1
  32. package/dist/coverage/lcov-report/test/mocks/LocationRequest.ts.html +1 -1
  33. package/dist/coverage/lcov-report/test/mocks/SearchRequest.ts.html +1 -1
  34. package/dist/coverage/lcov-report/test/mocks/index.html +1 -1
  35. package/dist/coverage/lcov-report/test/testUtils.ts.html +1 -1
  36. package/dist/coverage/lcov.info +287 -133
  37. package/dist/interfaces/response/AreaResponse.js +2 -0
  38. package/dist/interfaces/response/EmissionResponse.js +2 -0
  39. package/dist/interfaces/response/EmissionResponseWithDetails.js +2 -0
  40. package/dist/interfaces/response/FactorResponse.js +2 -0
  41. package/dist/interfaces/response/FactorSetResponse.js +2 -0
  42. package/dist/interfaces/response/SearchResponse.js +2 -0
  43. package/dist/interfaces/response/TypeResponse.js +2 -0
  44. package/dist/interfaces/response/UnitResponse.js +2 -0
  45. package/dist/types/Constants.d.ts +22 -0
  46. package/dist/types/api/Calculation.d.ts +59 -16
  47. package/dist/types/api/Factor.d.ts +73 -20
  48. package/dist/types/api/FactorSets.d.ts +3 -2
  49. package/dist/types/api/Fugitive.d.ts +57 -14
  50. package/dist/types/api/Location.d.ts +57 -16
  51. package/dist/types/api/Mobile.d.ts +46 -2
  52. package/dist/types/api/Stationary.d.ts +59 -16
  53. package/dist/types/api/TransportationAndDistribution.d.ts +58 -15
  54. package/dist/types/index.d.ts +8 -0
  55. package/dist/types/interfaces/response/AreaResponse.d.ts +20 -0
  56. package/dist/types/interfaces/response/EmissionResponse.d.ts +31 -0
  57. package/dist/types/interfaces/response/EmissionResponseWithDetails.d.ts +144 -0
  58. package/dist/types/interfaces/response/FactorResponse.d.ts +53 -0
  59. package/dist/types/interfaces/response/FactorSetResponse.d.ts +38 -0
  60. package/dist/types/interfaces/response/SearchResponse.d.ts +41 -0
  61. package/dist/types/interfaces/response/TypeResponse.d.ts +7 -0
  62. package/dist/types/interfaces/response/UnitResponse.d.ts +7 -0
  63. package/docs/.nojekyll +0 -0
  64. package/docs/_sources/authentication.rst.txt +164 -0
  65. package/docs/_sources/client.rst.txt +137 -0
  66. package/docs/_sources/getting_started.rst.txt +164 -0
  67. package/docs/_sources/index.rst.txt +30 -0
  68. package/docs/_sources/reference.rst.txt +129 -0
  69. package/docs/_sources/sdk.rst.txt +13 -0
  70. package/docs/_sources/troubleshooting.rst.txt +486 -0
  71. package/docs/_static/basic.css +914 -0
  72. package/docs/_static/custom.css +16 -0
  73. package/docs/_static/debug.css +69 -0
  74. package/docs/_static/doctools.js +149 -0
  75. package/docs/_static/documentation_options.js +13 -0
  76. package/docs/_static/file.png +0 -0
  77. package/docs/_static/language_data.js +192 -0
  78. package/docs/_static/minus.png +0 -0
  79. package/docs/_static/plus.png +0 -0
  80. package/docs/_static/pygments.css +232 -0
  81. package/docs/_static/scripts/furo-extensions.js +0 -0
  82. package/docs/_static/scripts/furo.js +3 -0
  83. package/docs/_static/scripts/furo.js.LICENSE.txt +7 -0
  84. package/docs/_static/scripts/furo.js.map +1 -0
  85. package/docs/_static/searchtools.js +632 -0
  86. package/docs/_static/skeleton.css +296 -0
  87. package/docs/_static/sphinx_highlight.js +154 -0
  88. package/docs/_static/sphinx_js.css +0 -0
  89. package/docs/_static/styles/furo-extensions.css +2 -0
  90. package/docs/_static/styles/furo-extensions.css.map +1 -0
  91. package/docs/_static/styles/furo.css +2 -0
  92. package/docs/_static/styles/furo.css.map +1 -0
  93. package/docs/authentication.html +523 -0
  94. package/docs/client.html +477 -0
  95. package/docs/genindex.html +492 -0
  96. package/docs/getting_started.html +491 -0
  97. package/docs/index.html +357 -0
  98. package/docs/objects.inv +0 -0
  99. package/docs/reference.html +1584 -0
  100. package/docs/sdk.html +334 -0
  101. package/docs/search.html +297 -0
  102. package/docs/searchindex.js +1 -0
  103. package/docs/troubleshooting.html +786 -0
  104. package/package.json +1 -1
  105. package/sphinx-build/Makefile +49 -0
  106. package/sphinx-build/requirements.txt +5 -0
  107. package/sphinx-build/source/_static/custom.css +16 -0
  108. package/sphinx-build/source/authentication.rst +164 -0
  109. package/sphinx-build/source/client.rst +137 -0
  110. package/sphinx-build/source/conf.py +56 -0
  111. package/sphinx-build/source/getting_started.rst +164 -0
  112. package/sphinx-build/source/index.rst +30 -0
  113. package/sphinx-build/source/reference.rst +129 -0
  114. package/sphinx-build/source/sdk.rst +13 -0
  115. package/sphinx-build/source/troubleshooting.rst +486 -0
  116. package/src/Constants.ts +26 -0
  117. package/src/api/Calculation.ts +94 -20
  118. package/src/api/Factor.ts +122 -28
  119. package/src/api/FactorSets.ts +4 -3
  120. package/src/api/Fugitive.ts +93 -18
  121. package/src/api/Location.ts +94 -20
  122. package/src/api/Mobile.ts +83 -6
  123. package/src/api/Stationary.ts +95 -20
  124. package/src/api/TransportationAndDistribution.ts +95 -19
  125. package/src/index.ts +33 -1
  126. package/src/interfaces/response/AreaResponse.ts +25 -0
  127. package/src/interfaces/response/EmissionResponse.ts +44 -0
  128. package/src/interfaces/response/EmissionResponseWithDetails.ts +183 -0
  129. package/src/interfaces/response/FactorResponse.ts +78 -0
  130. package/src/interfaces/response/FactorSetResponse.ts +52 -0
  131. package/src/interfaces/response/SearchResponse.ts +52 -0
  132. package/src/interfaces/response/TypeResponse.ts +7 -0
  133. package/src/interfaces/response/UnitResponse.ts +7 -0
  134. package/test/apiTest.test.ts +173 -6
  135. package/dist/api/Factors.js +0 -98
  136. package/dist/api/FugitiveEmission.js +0 -40
  137. package/dist/api/GenericCalculation.js +0 -41
  138. package/dist/api/LocationEmission.js +0 -41
  139. package/dist/api/MobileEmission.js +0 -41
  140. package/dist/api/StationaryEmission.js +0 -41
  141. package/dist/api/TransportationDistributionEmission.js +0 -40
  142. package/dist/coverage/lcov-report/src/api/Factors.ts.html +0 -403
  143. package/dist/coverage/lcov-report/src/api/FugitiveEmission.ts.html +0 -214
  144. package/dist/coverage/lcov-report/src/api/GenericCalculation.ts.html +0 -217
  145. package/dist/coverage/lcov-report/src/api/LocationEmission.ts.html +0 -214
  146. package/dist/coverage/lcov-report/src/api/MobileEmission.ts.html +0 -220
  147. package/dist/coverage/lcov-report/src/api/StationaryEmission.ts.html +0 -220
  148. package/dist/coverage/lcov-report/src/api/TransportationDistributionEmission.ts.html +0 -211
  149. package/dist/types/api/Factors.d.ts +0 -68
  150. package/dist/types/api/FugitiveEmission.d.ts +0 -27
  151. package/dist/types/api/GenericCalculation.d.ts +0 -28
  152. package/dist/types/api/LocationEmission.d.ts +0 -28
  153. package/dist/types/api/MobileEmission.d.ts +0 -28
  154. package/dist/types/api/StationaryEmission.d.ts +0 -28
  155. package/dist/types/api/TransportationDistributionEmission.d.ts +0 -27
package/src/api/Mobile.ts CHANGED
@@ -1,17 +1,22 @@
1
1
  import { makeApiRequest } from "../request";
2
- import { MOBILE_API_PATH, POST } from "../Constants";
2
+ import { GET, MOBILE_API_AREA, MOBILE_API_PATH, MOBILE_API_TYPES, MOBILE_API_UNITS, POST } from "../Constants";
3
3
  import { CommonRequest } from "../interfaces/Api";
4
+ import { AreaResponse } from "../interfaces/response/AreaResponse";
5
+ import { EmissionResponse } from "../interfaces/response/EmissionResponse";
6
+ import { EmissionResponseWithDetails } from "../interfaces/response/EmissionResponseWithDetails";
7
+ import { TypeResponse } from "../interfaces/response/TypeResponse";
8
+ import { UnitResponse } from "../interfaces/response/UnitResponse";
4
9
  import { Client } from "../Client";
5
10
 
6
11
 
7
12
  /**
8
13
  * Performs Scope 1 mobile emissions related calculations by making a POST request to the mobile API endpoint.
9
- *
14
+ *
10
15
  * @export
11
16
  * @param {CommonRequest} payload - The request data to be sent to the mobile API
12
- * @return {Promise<string>} A promise that resolves to the calculation result string returned by the API
17
+ * @return {Promise<EmissionResponse | EmissionResponseWithDetails>} A promise that resolves to the emission calculation result. Returns EmissionResponseWithDetails if includeDetails is true, otherwise EmissionResponse
13
18
  * @throws {Error} May throw an error if the API request fails
14
- *
19
+ *
15
20
  * @example
16
21
  * const request = {
17
22
  "time": {
@@ -33,13 +38,85 @@ import { Client } from "../Client";
33
38
 
34
39
  export async function calculate(
35
40
  payload: CommonRequest
36
- ): Promise<string> {
41
+ ): Promise<EmissionResponse | EmissionResponseWithDetails> {
37
42
  const client = Client.getInstance();
38
43
  const url = client.getDomain() + MOBILE_API_PATH;
39
44
 
40
- return makeApiRequest<string>({
45
+ return makeApiRequest<EmissionResponse | EmissionResponseWithDetails>({
41
46
  method: POST,
42
47
  url,
43
48
  data: payload,
44
49
  });
45
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
+ }
@@ -1,45 +1,120 @@
1
1
  import { Client } from "../Client";
2
- import { POST, STATIONARY_API_PATH } from "../Constants";
2
+ import { GET, POST, STATIONARY_API_AREA, STATIONARY_API_PATH, STATIONARY_API_TYPES, STATIONARY_API_UNITS } from "../Constants";
3
3
  import { CommonRequest } from "../interfaces/Api";
4
+ import { AreaResponse } from "../interfaces/response/AreaResponse";
5
+ import { EmissionResponse } from "../interfaces/response/EmissionResponse";
6
+ import { EmissionResponseWithDetails } from "../interfaces/response/EmissionResponseWithDetails";
7
+ import { TypeResponse } from "../interfaces/response/TypeResponse";
8
+ import { UnitResponse } from "../interfaces/response/UnitResponse";
4
9
  import { makeApiRequest } from "../request";
5
10
 
6
11
 
7
12
  /**
8
13
  * Performs Scope 1 stationary calculations by making a POST request to the stationary API endpoint.
9
- *
14
+ *
10
15
  * @export
11
16
  * @param {CommonRequest} payload - The request data to be sent to the stationary API
12
- * @return {Promise<string>} A promise that resolves to the calculation result string returned by the API
17
+ * @return {Promise<EmissionResponse | EmissionResponseWithDetails>} A promise that resolves to the emission calculation result. Returns EmissionResponseWithDetails if includeDetails is true, otherwise EmissionResponse
13
18
  * @throws {Error} May throw an error if the API request fails
14
- *
19
+ *
15
20
  * @example
16
21
  * const request = {
17
- "time" : {
18
- "date": "2025-01-04"
19
- },
20
- "location": {
21
- "country": "usa",
22
- "stateProvince": "new york"
23
- },
24
- "activity": {
25
- "type":"Coal - Lignite",
26
- "unit": "KJ",
27
- "value": 3
28
- },
29
- "includeDetails": true
30
- };
22
+ "time" : {
23
+ "date": "2025-01-04"
24
+ },
25
+ "location": {
26
+ "country": "usa",
27
+ "stateProvince": "new york"
28
+ },
29
+ "activity": {
30
+ "type":"Coal - Lignite",
31
+ "unit": "KJ",
32
+ "value": 3
33
+ },
34
+ "includeDetails": true
35
+ };
31
36
  * const result = await calculate(request);
32
37
  */
33
38
 
34
39
  export async function calculate(
35
40
  payload: CommonRequest
36
- ): Promise<string> {
41
+ ): Promise<EmissionResponse | EmissionResponseWithDetails> {
37
42
  const client = Client.getInstance();
38
43
  const url = client.getDomain() + STATIONARY_API_PATH;
39
44
 
40
- return makeApiRequest<string>({
45
+ return makeApiRequest<EmissionResponse | EmissionResponseWithDetails>({
41
46
  method: POST,
42
47
  url,
43
48
  data: payload,
44
49
  });
45
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
+ }
@@ -1,42 +1,118 @@
1
1
  import { Client } from "../Client";
2
- import { TRANSPORTATION_AND_DISTRIBUTION_API_PATH, POST } from "../Constants";
2
+ import { TRANSPORTATION_AND_DISTRIBUTION_API_PATH, POST, TRANSPORTATION_AND_DISTRIBUTION_API_TYPES, GET, TRANSPORTATION_AND_DISTRIBUTION_API_AREA, TRANSPORTATION_AND_DISTRIBUTION_API_UNITS } from "../Constants";
3
3
  import { CalculationRequest } from "../interfaces/Api";
4
+ import { AreaResponse } from "../interfaces/response/AreaResponse";
5
+ import { EmissionResponse } from "../interfaces/response/EmissionResponse";
6
+ import { EmissionResponseWithDetails } from "../interfaces/response/EmissionResponseWithDetails";
7
+ import { TypeResponse } from "../interfaces/response/TypeResponse";
8
+ import { UnitResponse } from "../interfaces/response/UnitResponse";
4
9
  import { makeApiRequest } from "../request";
5
10
 
6
11
  /**
7
- * Performs Scope 2 transportation and distribution emission calculations by making a POST request to the transportation and distribution API endpoint.
8
- *
12
+ * Performs Scope 3 transportation and distribution emission calculations by making a POST request to the transportation and distribution API endpoint.
13
+ *
9
14
  * @export
10
15
  * @param {CalculationRequest} payload - The calculation request data for transportation and distribution operations
11
- * @return {Promise<string>} A promise that resolves to the calculation result string returned by the API
16
+ * @return {Promise<EmissionResponse | EmissionResponseWithDetails>} A promise that resolves to the emission calculation result. Returns EmissionResponseWithDetails if includeDetails is true, otherwise EmissionResponse
12
17
  * @throws {Error} May throw an error if the API request fails
13
- *
18
+ *
14
19
  * @example
15
20
  * const request = {
16
- "time" : {
17
- "date": "2025-01-04"
18
- },
19
- "location": {
20
- "country": "usa"
21
- },
22
- "activity": {
23
- "type": "Freight - Cargo Ship - Bulk Carrier - 0-9999 dwt",
24
- "unit": ["t","km"],
25
- "value": [1.0,1.0]
26
- },
27
- "includeDetails": true
21
+ "time" : {
22
+ "date": "2025-01-04"
23
+ },
24
+ "location": {
25
+ "country": "usa"
26
+ },
27
+ "activity": {
28
+ "type": "Freight - Cargo Ship - Bulk Carrier - 0-9999 dwt",
29
+ "unit": ["t","km"],
30
+ "value": [1.0,1.0]
31
+ },
32
+ "includeDetails": true
28
33
  };
29
34
  * const result = await calculate(request);
30
35
  */
31
36
  export async function calculate(
32
37
  payload: CalculationRequest
33
- ): Promise<string> {
38
+ ): Promise<EmissionResponse | EmissionResponseWithDetails> {
34
39
  const client = Client.getInstance();
35
40
  const url = client.getDomain() + TRANSPORTATION_AND_DISTRIBUTION_API_PATH;
36
41
 
37
- return makeApiRequest<string>({
42
+ return makeApiRequest<EmissionResponse | EmissionResponseWithDetails>({
38
43
  method: POST,
39
44
  url,
40
45
  data: payload,
41
46
  });
42
47
  }
48
+
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
@@ -7,4 +7,36 @@ export * as Calculation from './api/Calculation';
7
7
  export * as TransportationAndDistribution from './api/TransportationAndDistribution';
8
8
  export * as Factor from './api/Factor';
9
9
  export * as FactorSets from './api/FactorSets'
10
- export { ClientConfig } from './interfaces/Config';
10
+ export { ClientConfig } from './interfaces/Config';
11
+
12
+ // Response interfaces
13
+ export { AreaResponse, Location as LocationInfo } from './interfaces/response/AreaResponse';
14
+ export { EmissionResponse } from './interfaces/response/EmissionResponse';
15
+ export {
16
+ EmissionResponseWithDetails,
17
+ UnitInfo,
18
+ AreaInfo,
19
+ AreaType,
20
+ FactorDataTypeCategory,
21
+ FactorSetInfo,
22
+ FactorSelectionDefault,
23
+ FactorDataTypeCode,
24
+ FactorSetVersion,
25
+ FactorValue,
26
+ FactorMetaData,
27
+ UnitConversion,
28
+ EmissionData
29
+ } from './interfaces/response/EmissionResponseWithDetails';
30
+ export { FactorResponse } from './interfaces/response/FactorResponse';
31
+ export {
32
+ FactorSetResponse,
33
+ FactorSet
34
+ } from './interfaces/response/FactorSetResponse';
35
+ export {
36
+ SearchResponse,
37
+ Pagination,
38
+ PaginationBody,
39
+ SearchLink
40
+ } from './interfaces/response/SearchResponse';
41
+ export { TypeResponse } from './interfaces/response/TypeResponse';
42
+ export { UnitResponse } from './interfaces/response/UnitResponse';
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Interface representing a location with geographical and power grid information
3
+ */
4
+ export interface Location {
5
+ /** ISO 3166-1 alpha-3 country code */
6
+ alpha3: string;
7
+
8
+ /** Full country name */
9
+ countryName: string;
10
+
11
+ /** List of state or province names (optional) */
12
+ stateProvinces?: string[];
13
+
14
+ /** List of power grid identifiers (optional) */
15
+ powerGrids?: string[];
16
+ }
17
+
18
+ /**
19
+ * Interface representing the response from the area/location API
20
+ */
21
+ export interface AreaResponse {
22
+ /** Array of location objects */
23
+ locations: Location[];
24
+ }
25
+
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Interface representing the emission calculation response
3
+ */
4
+ export interface EmissionResponse {
5
+ /** Unique transaction identifier (required) */
6
+ transactionId: string;
7
+
8
+ /** Total CO2 equivalent emissions (required) */
9
+ totalCO2e: number;
10
+
11
+ /** CO2 emissions value (optional) */
12
+ CO2?: number;
13
+
14
+ /** CH4 (Methane) emissions value (optional) */
15
+ CH4?: number;
16
+
17
+ /** N2O (Nitrous Oxide) emissions value (optional) */
18
+ N2O?: number;
19
+
20
+ /** Biogenic CO2 emissions value (optional) */
21
+ bioCO2?: number;
22
+
23
+ /** Indirect CO2 equivalent emissions value (optional) */
24
+ indirectCO2e?: number;
25
+
26
+ /** Hydrofluorocarbon emissions value (optional) */
27
+ HFC?: number;
28
+
29
+ /** Perfluorocarbon emissions value (optional) */
30
+ PFC?: number;
31
+
32
+ /** Sulfur hexafluoride emissions value (optional) */
33
+ SF6?: number;
34
+
35
+ /** Nitrogen trifluoride emissions value (optional) */
36
+ NF3?: number;
37
+
38
+ /** Unit of measurement for emissions (required) */
39
+ unit: string;
40
+
41
+ /** Description of the emission calculation (required) */
42
+ description: string;
43
+ }
44
+
@@ -0,0 +1,183 @@
1
+ import { EmissionResponse } from './EmissionResponse';
2
+
3
+ /**
4
+ * Interface for unit information in emission details
5
+ */
6
+ export interface UnitInfo {
7
+ /** Unit name */
8
+ name: string;
9
+
10
+ /** Unit description (optional) */
11
+ description?: string;
12
+ }
13
+
14
+ /**
15
+ * Interface for area information
16
+ */
17
+ export interface AreaInfo {
18
+ /** Internal name of the area */
19
+ internalName: string;
20
+
21
+ /** Standard name of the area */
22
+ standardName: string;
23
+
24
+ alpha3?: string;
25
+ }
26
+
27
+ /**
28
+ * Interface for area type information
29
+ */
30
+ export interface AreaType {
31
+ /** Type name (e.g., "Planet", "State") */
32
+ name: string;
33
+ }
34
+
35
+ /**
36
+ * Interface for factor data type categories
37
+ */
38
+ export interface FactorDataTypeCategory {
39
+ /** Category name */
40
+ name: string;
41
+ }
42
+
43
+ /**
44
+ * Interface for factor set information
45
+ */
46
+ export interface FactorSetInfo {
47
+ /** Factor set type */
48
+ type: string;
49
+
50
+ /** Description of the factor set */
51
+ description?: string;
52
+
53
+ /** Provider of the factor set */
54
+ provider?: string;
55
+
56
+ /** Source URL for the factor set */
57
+ sourceUrl?: string;
58
+
59
+ factorSource?: string;
60
+ }
61
+ export interface FactorSelectionDefault {
62
+ actorDataType?: string;
63
+ areaName?: string;
64
+ factorSetName?: string;
65
+ }
66
+ /**
67
+ * Interface for factor data type code
68
+ */
69
+ export interface FactorDataTypeCode {
70
+ /** Unit of measure */
71
+ unitOfMeasure: string;
72
+
73
+ /** Activity type */
74
+ type: string;
75
+
76
+ /** Activity subtype */
77
+ subtype: string;
78
+
79
+ /** Unique factor identifier */
80
+ factorId: number;
81
+ }
82
+
83
+ /**
84
+ * Interface for factor set version information
85
+ */
86
+ export interface FactorSetVersion {
87
+ /** Publication start date */
88
+ publishedFrom?: string;
89
+
90
+ /** Publication end date (optional) */
91
+ publishedTo?: string;
92
+
93
+ /** Source of the factor */
94
+ factorSource: string;
95
+ }
96
+
97
+ /**
98
+ * Interface for factor value
99
+ */
100
+ export interface FactorValue {
101
+ /** Unit information */
102
+ unit: {
103
+ /** Unit name */
104
+ name: string;
105
+ };
106
+
107
+ /** Factor value */
108
+ value: number;
109
+ }
110
+
111
+ /**
112
+ * Interface for factor metadata
113
+ */
114
+ export interface FactorMetaData {
115
+ /** Metadata key */
116
+ key: string;
117
+
118
+ /** Metadata value */
119
+ value: string;
120
+ }
121
+
122
+ /**
123
+ * Interface for unit conversion information
124
+ */
125
+ export interface UnitConversion {
126
+ /** Input unit */
127
+ inputUnit: string;
128
+
129
+ /** Unit from database */
130
+ unitFromDb: string;
131
+
132
+ /** Conversion ratio */
133
+ conversionRatio: string;
134
+ }
135
+
136
+ /**
137
+ * Interface for detailed emission data
138
+ */
139
+ export interface EmissionData {
140
+ /** Array of unit information */
141
+ unit: UnitInfo[];
142
+
143
+ /** Array of area information */
144
+ area: AreaInfo[];
145
+
146
+ /** Array of area types */
147
+ areaType: AreaType[];
148
+
149
+ /** Array of factor data type categories */
150
+ factorDataTypeCategories: FactorDataTypeCategory[];
151
+
152
+ factorSelectionDefault? :FactorSelectionDefault[];
153
+
154
+ /** Array of factor set information */
155
+ factorSet: FactorSetInfo[];
156
+
157
+ /** Array of factor data type codes */
158
+ factorDataTypeCode: FactorDataTypeCode[];
159
+
160
+ /** Array of factor set versions */
161
+ factorSetVersion: FactorSetVersion[];
162
+
163
+ /** Array of factor values */
164
+ factorValue: FactorValue[];
165
+
166
+ /** Array of factor metadata */
167
+ factorMetaData: FactorMetaData[];
168
+
169
+ /** Array of unit conversions */
170
+ unitConversion: UnitConversion[];
171
+ }
172
+
173
+ /**
174
+ * Interface representing the emission calculation response with detailed information
175
+ */
176
+ export interface EmissionResponseWithDetails {
177
+ /** Emission calculation result */
178
+ result: EmissionResponse;
179
+
180
+ /** Detailed emission data */
181
+ data: EmissionData;
182
+ }
183
+