emissions-api-sdk 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/README.md +33 -2
  2. package/dist/Constants.js +23 -1
  3. package/dist/api/Calculation.js +77 -14
  4. package/dist/api/Factor.js +97 -16
  5. package/dist/api/Fugitive.js +75 -12
  6. package/dist/api/Location.js +75 -14
  7. package/dist/api/Mobile.js +66 -0
  8. package/dist/api/Stationary.js +77 -14
  9. package/dist/api/TransportationAndDistribution.js +75 -12
  10. package/dist/types/Constants.d.ts +22 -0
  11. package/dist/types/api/Calculation.d.ts +52 -14
  12. package/dist/types/api/Factor.d.ts +64 -16
  13. package/dist/types/api/Fugitive.d.ts +50 -12
  14. package/dist/types/api/Location.d.ts +50 -14
  15. package/dist/types/api/Mobile.d.ts +41 -0
  16. package/dist/types/api/Stationary.d.ts +52 -14
  17. package/dist/types/api/TransportationAndDistribution.d.ts +50 -12
  18. package/docs/.nojekyll +0 -0
  19. package/docs/_sources/authentication.rst.txt +164 -0
  20. package/docs/_sources/client.rst.txt +137 -0
  21. package/docs/_sources/getting_started.rst.txt +164 -0
  22. package/docs/_sources/index.rst.txt +29 -0
  23. package/docs/_sources/reference.rst.txt +129 -0
  24. package/docs/_sources/sdk.rst.txt +13 -0
  25. package/docs/_static/basic.css +906 -0
  26. package/docs/_static/custom.css +16 -0
  27. package/docs/_static/debug.css +69 -0
  28. package/docs/_static/doctools.js +149 -0
  29. package/docs/_static/documentation_options.js +13 -0
  30. package/docs/_static/file.png +0 -0
  31. package/docs/_static/language_data.js +192 -0
  32. package/docs/_static/minus.png +0 -0
  33. package/docs/_static/plus.png +0 -0
  34. package/docs/_static/pygments.css +250 -0
  35. package/docs/_static/scripts/furo-extensions.js +0 -0
  36. package/docs/_static/scripts/furo.js +3 -0
  37. package/docs/_static/scripts/furo.js.LICENSE.txt +7 -0
  38. package/docs/_static/scripts/furo.js.map +1 -0
  39. package/docs/_static/searchtools.js +635 -0
  40. package/docs/_static/skeleton.css +296 -0
  41. package/docs/_static/sphinx_highlight.js +154 -0
  42. package/docs/_static/sphinx_js.css +0 -0
  43. package/docs/_static/styles/furo-extensions.css +2 -0
  44. package/docs/_static/styles/furo-extensions.css.map +1 -0
  45. package/docs/_static/styles/furo.css +2 -0
  46. package/docs/_static/styles/furo.css.map +1 -0
  47. package/docs/authentication.html +513 -0
  48. package/docs/client.html +467 -0
  49. package/docs/genindex.html +482 -0
  50. package/docs/getting_started.html +481 -0
  51. package/docs/index.html +334 -0
  52. package/docs/objects.inv +0 -0
  53. package/docs/reference.html +1568 -0
  54. package/docs/sdk.html +324 -0
  55. package/docs/search.html +287 -0
  56. package/docs/searchindex.js +1 -0
  57. package/package.json +1 -1
  58. package/sphinx-build/Makefile +49 -0
  59. package/sphinx-build/source/_static/custom.css +16 -0
  60. package/sphinx-build/source/authentication.rst +164 -0
  61. package/sphinx-build/source/client.rst +137 -0
  62. package/sphinx-build/source/conf.py +56 -0
  63. package/sphinx-build/source/getting_started.rst +164 -0
  64. package/sphinx-build/source/index.rst +29 -0
  65. package/sphinx-build/source/reference.rst +129 -0
  66. package/sphinx-build/source/sdk.rst +13 -0
  67. package/src/Constants.ts +26 -0
  68. package/src/api/Calculation.ts +84 -15
  69. package/src/api/Factor.ts +108 -19
  70. package/src/api/Fugitive.ts +83 -13
  71. package/src/api/Location.ts +84 -15
  72. package/src/api/Mobile.ts +75 -1
  73. package/src/api/Stationary.ts +85 -15
  74. package/src/api/TransportationAndDistribution.ts +84 -13
  75. package/test/apiTest.test.ts +172 -5
  76. package/dist/api/Factors.js +0 -98
  77. package/dist/api/FugitiveEmission.js +0 -40
  78. package/dist/api/GenericCalculation.js +0 -41
  79. package/dist/api/LocationEmission.js +0 -41
  80. package/dist/api/MobileEmission.js +0 -41
  81. package/dist/api/StationaryEmission.js +0 -41
  82. package/dist/api/TransportationDistributionEmission.js +0 -40
  83. package/dist/coverage/clover.xml +0 -225
  84. package/dist/coverage/coverage-final.json +0 -19
  85. package/dist/coverage/lcov-report/base.css +0 -224
  86. package/dist/coverage/lcov-report/block-navigation.js +0 -87
  87. package/dist/coverage/lcov-report/favicon.png +0 -0
  88. package/dist/coverage/lcov-report/index.html +0 -161
  89. package/dist/coverage/lcov-report/prettify.css +0 -1
  90. package/dist/coverage/lcov-report/prettify.js +0 -2
  91. package/dist/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  92. package/dist/coverage/lcov-report/sorter.js +0 -210
  93. package/dist/coverage/lcov-report/src/Client.ts.html +0 -838
  94. package/dist/coverage/lcov-report/src/Constants.ts.html +0 -130
  95. package/dist/coverage/lcov-report/src/api/Calculation.ts.html +0 -217
  96. package/dist/coverage/lcov-report/src/api/Factor.ts.html +0 -343
  97. package/dist/coverage/lcov-report/src/api/FactorSets.ts.html +0 -154
  98. package/dist/coverage/lcov-report/src/api/Factors.ts.html +0 -403
  99. package/dist/coverage/lcov-report/src/api/Fugitive.ts.html +0 -214
  100. package/dist/coverage/lcov-report/src/api/FugitiveEmission.ts.html +0 -214
  101. package/dist/coverage/lcov-report/src/api/GenericCalculation.ts.html +0 -217
  102. package/dist/coverage/lcov-report/src/api/Location.ts.html +0 -214
  103. package/dist/coverage/lcov-report/src/api/LocationEmission.ts.html +0 -214
  104. package/dist/coverage/lcov-report/src/api/Mobile.ts.html +0 -220
  105. package/dist/coverage/lcov-report/src/api/MobileEmission.ts.html +0 -220
  106. package/dist/coverage/lcov-report/src/api/Stationary.ts.html +0 -220
  107. package/dist/coverage/lcov-report/src/api/StationaryEmission.ts.html +0 -220
  108. package/dist/coverage/lcov-report/src/api/TransportationAndDistribution.ts.html +0 -211
  109. package/dist/coverage/lcov-report/src/api/TransportationDistributionEmission.ts.html +0 -211
  110. package/dist/coverage/lcov-report/src/api/index.html +0 -221
  111. package/dist/coverage/lcov-report/src/index.html +0 -161
  112. package/dist/coverage/lcov-report/src/request.ts.html +0 -235
  113. package/dist/coverage/lcov-report/src/utils.ts.html +0 -139
  114. package/dist/coverage/lcov-report/test/index.html +0 -116
  115. package/dist/coverage/lcov-report/test/mocks/CommonRequest.ts.html +0 -142
  116. package/dist/coverage/lcov-report/test/mocks/FactorRequest.ts.html +0 -133
  117. package/dist/coverage/lcov-report/test/mocks/GenericCalculationRequest.ts.html +0 -142
  118. package/dist/coverage/lcov-report/test/mocks/LocationRequest.ts.html +0 -139
  119. package/dist/coverage/lcov-report/test/mocks/SearchRequest.ts.html +0 -142
  120. package/dist/coverage/lcov-report/test/mocks/index.html +0 -176
  121. package/dist/coverage/lcov-report/test/testUtils.ts.html +0 -97
  122. package/dist/coverage/lcov.info +0 -404
  123. package/dist/types/api/Factors.d.ts +0 -68
  124. package/dist/types/api/FugitiveEmission.d.ts +0 -27
  125. package/dist/types/api/GenericCalculation.d.ts +0 -28
  126. package/dist/types/api/LocationEmission.d.ts +0 -28
  127. package/dist/types/api/MobileEmission.d.ts +0 -28
  128. package/dist/types/api/StationaryEmission.d.ts +0 -28
  129. package/dist/types/api/TransportationDistributionEmission.d.ts +0 -27
package/src/api/Mobile.ts CHANGED
@@ -1,5 +1,5 @@
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
4
  import { Client } from "../Client";
5
5
 
@@ -43,3 +43,77 @@ export async function calculate(
43
43
  data: payload,
44
44
  });
45
45
  }
46
+
47
+
48
+ /**
49
+ * Retrieves available mobile emission calculation types by making a GET request to the API endpoint.
50
+ *
51
+ * @export
52
+ * @return {Promise<string>} A promise that resolves to a string containing the available mobile emission types
53
+ * @throws {Error} May throw an error if the API request fails
54
+ *
55
+ * @example
56
+ * // Get all available mobile emission types
57
+ * const types = await getTypes();
58
+ * const typesData = JSON.parse(types);
59
+ * console.log("Available mobile emission types:", typesData);
60
+ */
61
+ export async function getTypes(
62
+ ): Promise<string> {
63
+ const client = Client.getInstance();
64
+ const url = client.getDomain() + MOBILE_API_TYPES;
65
+
66
+ return makeApiRequest<string>({
67
+ method: GET,
68
+ url
69
+ });
70
+ }
71
+
72
+ /**
73
+ * Retrieves information about geographical areas supported by the mobile emissions API.
74
+ *
75
+ * @export
76
+ * @return {Promise<string>} A promise that resolves to a string 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(
83
+ ): Promise<string> {
84
+ const client = Client.getInstance();
85
+ const url = client.getDomain() + MOBILE_API_AREA;
86
+
87
+ return makeApiRequest<string>({
88
+ method: GET,
89
+ url
90
+ });
91
+ }
92
+
93
+ /**
94
+ * Retrieves available units for a specific mobile emission type.
95
+ *
96
+ * @export
97
+ * @param {string} type - The mobile emission type to get units for (e.g., "Diesel Fuel")
98
+ * @return {Promise<string>} A promise that resolves to a string containing the available units
99
+ * @throws {Error} May throw an error if the API request fails
100
+ *
101
+ * @example
102
+ * Get units for the "Cars:B20:(NE)" emission mobile type with subtype
103
+ * const units = await getUnits("Cars:B20:(NE)");
104
+
105
+ * Get units for the "Cars by Size - Large Car - Hybrid" emission mobile type without subtype
106
+ * const units = await getUnits("Cars by Size - Large Car - Hybrid");
107
+ */
108
+ export async function getUnits(
109
+ type : string
110
+ ): Promise<string> {
111
+ const client = Client.getInstance();
112
+ const url = client.getDomain() + MOBILE_API_UNITS;
113
+
114
+ return makeApiRequest<string>({
115
+ method: GET,
116
+ url,
117
+ params : { type }
118
+ });
119
+ }
@@ -1,5 +1,5 @@
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
4
  import { makeApiRequest } from "../request";
5
5
 
@@ -14,20 +14,20 @@ import { makeApiRequest } from "../request";
14
14
  *
15
15
  * @example
16
16
  * 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
- };
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
+ };
31
31
  * const result = await calculate(request);
32
32
  */
33
33
 
@@ -43,3 +43,73 @@ export async function calculate(
43
43
  data: payload,
44
44
  });
45
45
  }
46
+
47
+ /**
48
+ * Retrieves available stationary emission calculation types by making a GET request to the API endpoint.
49
+ *
50
+ * @export
51
+ * @return {Promise<string>} A promise that resolves to a string containing the available stationary emission types
52
+ * @throws {Error} May throw an error if the API request fails
53
+ *
54
+ * @example
55
+ * const types = await getTypes();
56
+ */
57
+ export async function getTypes(
58
+ ): Promise<string> {
59
+ const client = Client.getInstance();
60
+ const url = client.getDomain() + STATIONARY_API_TYPES;
61
+
62
+ return makeApiRequest<string>({
63
+ method: GET,
64
+ url
65
+ });
66
+ }
67
+
68
+ /**
69
+ * Retrieves information about geographical areas supported by the stationary emissions API.
70
+ *
71
+ * @export
72
+ * @return {Promise<string>} A promise that resolves to a string containing the supported geographical areas
73
+ * @throws {Error} May throw an error if the API request fails
74
+ *
75
+ * @example
76
+ * const areas = await getArea();
77
+ */
78
+ export async function getArea(
79
+ ): Promise<string> {
80
+ const client = Client.getInstance();
81
+ const url = client.getDomain() + STATIONARY_API_AREA;
82
+
83
+ return makeApiRequest<string>({
84
+ method: GET,
85
+ url
86
+ });
87
+ }
88
+
89
+ /**
90
+ * Retrieves available units for a specific stationary emission type.
91
+ *
92
+ * @export
93
+ * @param {string} type - The stationary emission type to get units for (e.g., "Coal - Lignite")
94
+ * @return {Promise<string>} A promise that resolves to a string containing the available units
95
+ * @throws {Error} May throw an error if the API request fails
96
+ *
97
+ * @example
98
+ * Get units for the "Petroleum Based Greases - NC:A" emission stationary type with subtype
99
+ * const units = await getUnits("Petroleum Based Greases - NC:A");
100
+
101
+ * Get units for the "Jet Kerosene" emission stationary type without subtype
102
+ * const units = await getUnits("Jet Kerosene");
103
+ */
104
+ export async function getUnits(
105
+ type : string
106
+ ): Promise<string> {
107
+ const client = Client.getInstance();
108
+ const url = client.getDomain() + STATIONARY_API_UNITS;
109
+
110
+ return makeApiRequest<string>({
111
+ method: GET,
112
+ url,
113
+ params : { type }
114
+ });
115
+ }
@@ -1,5 +1,5 @@
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
4
  import { makeApiRequest } from "../request";
5
5
 
@@ -13,18 +13,18 @@ import { makeApiRequest } from "../request";
13
13
  *
14
14
  * @example
15
15
  * 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
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
28
28
  };
29
29
  * const result = await calculate(request);
30
30
  */
@@ -40,3 +40,74 @@ export async function calculate(
40
40
  data: payload,
41
41
  });
42
42
  }
43
+
44
+
45
+ /**
46
+ * Retrieves available transportation and distribution calculation types by making a GET request to the API endpoint.
47
+ *
48
+ * @export
49
+ * @return {Promise<string>} A promise that resolves to a string containing the available transportation and distribution calculation types
50
+ * @throws {Error} May throw an error if the API request fails
51
+ *
52
+ * @example
53
+ * const types = await getTypes();
54
+ */
55
+ export async function getTypes(
56
+ ): Promise<string> {
57
+ const client = Client.getInstance();
58
+ const url = client.getDomain() + TRANSPORTATION_AND_DISTRIBUTION_API_TYPES;
59
+
60
+ return makeApiRequest<string>({
61
+ method: GET,
62
+ url
63
+ });
64
+ }
65
+
66
+ /**
67
+ * Retrieves information about geographical areas supported by the transportation and distribution API.
68
+ *
69
+ * @export
70
+ * @return {Promise<string>} A promise that resolves to a string containing the supported geographical areas
71
+ * @throws {Error} May throw an error if the API request fails
72
+ *
73
+ * @example
74
+ * const areas = await getArea();
75
+ */
76
+ export async function getArea(
77
+ ): Promise<string> {
78
+ const client = Client.getInstance();
79
+ const url = client.getDomain() + TRANSPORTATION_AND_DISTRIBUTION_API_AREA;
80
+
81
+ return makeApiRequest<string>({
82
+ method: GET,
83
+ url
84
+ });
85
+ }
86
+
87
+ /**
88
+ * Retrieves available units for a specific transportation and distribution calculation type.
89
+ *
90
+ * @export
91
+ * @param {string} type - The transportation and distribution calculation type to get units for (e.g., "Freight - Cargo Ship")
92
+ * @return {Promise<string>} A promise that resolves to a string containing the available units
93
+ * @throws {Error} May throw an error if the API request fails
94
+ *
95
+ * @example
96
+ * // Get units for the "Business Travel - Cars:Diesel - Small" transportation and distribution type without subtype
97
+ * const units = await getUnits("Business Travel - Cars:Diesel - Small");
98
+ *
99
+ * // Get units for the "Business Travel - Cars" transportation and distribution type with subtype
100
+ * const units = await getUnits("Business Travel - Cars");
101
+ */
102
+ export async function getUnits(
103
+ type : string
104
+ ): Promise<string> {
105
+ const client = Client.getInstance();
106
+ const url = client.getDomain() + TRANSPORTATION_AND_DISTRIBUTION_API_UNITS;
107
+
108
+ return makeApiRequest<string>({
109
+ method: GET,
110
+ url,
111
+ params : { type }
112
+ });
113
+ }
@@ -18,6 +18,28 @@ import {
18
18
  FACTOR_API_PATH,
19
19
  FACTOR_SET_API_PATH,
20
20
  SEARCH_API_PATH,
21
+ LOCATION_TYPES,
22
+ FUGITIVE_API_TYPES,
23
+ MOBILE_API_TYPES,
24
+ STATIONARY_API_TYPES,
25
+ CALCULATION_TYPES,
26
+ FACTOR_API_TYPES,
27
+ TRANSPORTATION_AND_DISTRIBUTION_API_TYPES,
28
+ LOCATION_API_AREA,
29
+ FUGITIVE_API_AREA,
30
+ MOBILE_API_AREA,
31
+ STATIONARY_API_AREA,
32
+ GENERAL_API_AREA,
33
+ FACTOR_API_AREA,
34
+ TRANSPORTATION_AND_DISTRIBUTION_API_AREA,
35
+ LOCATION_API_UNITS,
36
+ SEARCH_API_AREA,
37
+ FUGITIVE_API_UNITS,
38
+ MOBILE_API_UNITS,
39
+ STATIONARY_API_UNITS,
40
+ GENERAL_API_UNITS,
41
+ FACTOR_API_UNITS,
42
+ TRANSPORTATION_AND_DISTRIBUTION_API_UNITS,
21
43
  } from "../src/Constants";
22
44
  import locationPayload from "./mocks/LocationRequest";
23
45
  import commonpayload from "./mocks/CommonRequest";
@@ -32,6 +54,7 @@ type ApiTestCase = {
32
54
  path: string;
33
55
  payload?: any;
34
56
  pathParams?: string | string[];
57
+ queryParams?: Record<string, string>;
35
58
  method: "GET" | "POST";
36
59
  };
37
60
 
@@ -100,6 +123,145 @@ const testCases: ApiTestCase[] = [
100
123
  payload: SearchPayload,
101
124
  method: "POST",
102
125
  },
126
+ {
127
+ name: "Location API - getTypes",
128
+ func: locationApi.getTypes,
129
+ path: LOCATION_TYPES,
130
+ method: "GET",
131
+ },
132
+ {
133
+ name: "Fugitive API - getTypes",
134
+ func: fugitiveApi.getTypes,
135
+ path: FUGITIVE_API_TYPES,
136
+ method: "GET",
137
+ },
138
+ {
139
+ name: "Mobile API - getTypes",
140
+ func: mobileApi.getTypes,
141
+ path: MOBILE_API_TYPES,
142
+ method: "GET",
143
+ },
144
+ {
145
+ name: "Stationary API - getTypes",
146
+ func: stationaryApi.getTypes,
147
+ path: STATIONARY_API_TYPES,
148
+ method: "GET",
149
+ },
150
+ {
151
+ name: "GenericCalculation API - getTypes",
152
+ func: GenericCalculation.getTypes,
153
+ path: CALCULATION_TYPES,
154
+ method: "GET",
155
+ },
156
+ {
157
+ name: "Factor API - getTypes",
158
+ func: Factors.getTypes,
159
+ path: FACTOR_API_TYPES,
160
+ method: "GET",
161
+ },
162
+ {
163
+ name: "Transportation and Distribution API - getTypes",
164
+ func: TransportationDistributionApi.getTypes,
165
+ path: TRANSPORTATION_AND_DISTRIBUTION_API_TYPES,
166
+ method: "GET",
167
+ },
168
+ {
169
+ name: "Location API - getArea",
170
+ func: locationApi.getArea,
171
+ path: LOCATION_API_AREA,
172
+ method: "GET",
173
+ },
174
+ {
175
+ name: "Fugitive API - getArea",
176
+ func: fugitiveApi.getArea,
177
+ path: FUGITIVE_API_AREA,
178
+ method: "GET",
179
+ },
180
+ {
181
+ name: "Mobile API - getArea",
182
+ func: mobileApi.getArea,
183
+ path: MOBILE_API_AREA,
184
+ method: "GET",
185
+ },
186
+ {
187
+ name: "Stationary API - getArea",
188
+ func: stationaryApi.getArea,
189
+ path: STATIONARY_API_AREA,
190
+ method: "GET",
191
+ },
192
+ {
193
+ name: "GenericCalculation API - getArea",
194
+ func: GenericCalculation.getArea,
195
+ path: GENERAL_API_AREA,
196
+ method: "GET",
197
+ },
198
+ {
199
+ name: "Factor API - getArea",
200
+ func: Factors.getArea,
201
+ path: FACTOR_API_AREA,
202
+ method: "GET",
203
+ },
204
+ {
205
+ name: "Factor SEARCH API - getArea",
206
+ func: Factors.getSearchArea,
207
+ path: SEARCH_API_AREA,
208
+ method: "GET",
209
+ },
210
+ {
211
+ name: "Transportation and Distribution API - getArea",
212
+ func: TransportationDistributionApi.getArea,
213
+ path: TRANSPORTATION_AND_DISTRIBUTION_API_AREA,
214
+ method: "GET",
215
+ },
216
+ {
217
+ name: "Location API - getUnits",
218
+ func: locationApi.getUnits,
219
+ path: LOCATION_API_UNITS,
220
+ queryParams: { type: "electricity" },
221
+ method: "GET",
222
+ },
223
+ {
224
+ name: "Fugitive API - getUnits",
225
+ func: fugitiveApi.getUnits,
226
+ path: FUGITIVE_API_UNITS,
227
+ queryParams: { type: "Natural Gas - Scope 3:AAA" },
228
+ method: "GET",
229
+ },
230
+ {
231
+ name: "Mobile API - getUnits",
232
+ func: mobileApi.getUnits,
233
+ path: MOBILE_API_UNITS,
234
+ queryParams: { type: "Cars:B20:(NE)" },
235
+ method: "GET",
236
+ },
237
+ {
238
+ name: "Stationary API - getUnits",
239
+ func: stationaryApi.getUnits,
240
+ path: STATIONARY_API_UNITS,
241
+ queryParams: { type: "Jet Kerosene" },
242
+ method: "GET",
243
+ },
244
+ {
245
+ name: "GenericCalculation API - getUnits",
246
+ func: GenericCalculation.getUnits,
247
+ path: GENERAL_API_UNITS,
248
+ queryParams: { type: "Natural Gas - Scope 3:AAA" },
249
+ method: "GET",
250
+ },
251
+ {
252
+ name: "Factor API - getUnits",
253
+ func: Factors.getUnits,
254
+ path: FACTOR_API_UNITS,
255
+ queryParams: { type: "HFC-263fb" },
256
+ method: "GET",
257
+ },
258
+ {
259
+ name: "Transportation and Distribution API - getUnits",
260
+ func: TransportationDistributionApi.getUnits,
261
+ path: TRANSPORTATION_AND_DISTRIBUTION_API_UNITS,
262
+ queryParams: { type: "Business Travel - Cars:Diesel - Small" },
263
+ method: "GET",
264
+ },
103
265
  ];
104
266
 
105
267
  describe("API Test calculate functions", () => {
@@ -132,16 +294,20 @@ describe("API Test calculate functions", () => {
132
294
  });
133
295
  describe.each(testCases)(
134
296
  "$name",
135
- ({ func, path, payload, pathParams, method }) => {
297
+ ({ func, path, payload, pathParams, queryParams, method }) => {
136
298
  it("Should call makeApiRequest with API url", async () => {
137
299
  let result;
138
300
  if (method === "POST") {
139
301
  result = await func(payload);
140
302
  } else {
141
- result =
142
- pathParams !== undefined
143
- ? await func(pathParams)
144
- : await func();
303
+ // For GET requests with queryParams, pass the type value
304
+ if (queryParams) {
305
+ result = await func(queryParams.type);
306
+ } else if (pathParams !== undefined) {
307
+ result = await func(pathParams);
308
+ } else {
309
+ result = await func();
310
+ }
145
311
  }
146
312
  const clientDomain = Client.getInstance().getDomain();
147
313
 
@@ -160,6 +326,7 @@ describe("API Test calculate functions", () => {
160
326
  url: expectedUrl,
161
327
  };
162
328
  if (method === "POST") expectedRequest.data = payload;
329
+ if (method === "GET" && queryParams) expectedRequest.params = queryParams;
163
330
  expect(spy).toHaveBeenCalledWith(expectedRequest);
164
331
  expect(result).toBe(mockResp);
165
332
  });
@@ -1,98 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.retrieveFactor = retrieveFactor;
4
- exports.getFactorSets = getFactorSets;
5
- exports.Search = Search;
6
- const Client_1 = require("../Client");
7
- const Constants_1 = require("../Constants");
8
- const request_1 = require("../request");
9
- /**
10
- * Retrieves a factor details by making a POST request to the factor API endpoint.
11
- *
12
- * @export
13
- * @param {FactorRequest} payload - The factor request data to be sent to the API
14
- * @return {Promise<string>} A promise that resolves to the factor string returned by the API
15
- * @throws {Error} May throw an error if the API request fails
16
- *
17
- * @example
18
- * const factorRequest = {
19
-
20
- "activity": {
21
- "factorId": 12345
22
- }
23
- };
24
-
25
- or
26
-
27
- const factorRequest = {
28
- "time" : {
29
- "date": "2025-01-04"
30
- },
31
- "location": {
32
- "country": "usa",
33
- "stateProvince": "new york"
34
- },
35
- "activity": {
36
- "type":"natural gas"
37
- },
38
- "includeDetails": true
39
- };
40
- * const factor = await retrieveFactor(factorRequest);
41
- */
42
- async function retrieveFactor(payload) {
43
- const client = Client_1.Client.getInstance();
44
- const url = client.getDomain() + Constants_1.FACTOR_API_PATH;
45
- return (0, request_1.makeApiRequest)({
46
- method: Constants_1.POST,
47
- url,
48
- data: payload,
49
- });
50
- }
51
- /**
52
- * Retrieves factor sets by making a GET request to the factor set API endpoint.
53
- *
54
- * @export
55
- * @return {Promise<string>} A promise that resolves to the factor sets string returned by the API
56
- * @throws {Error} May throw an error if the API request fails
57
- *
58
- * @example
59
- * const factorSets = await getFactorSets();
60
- */
61
- async function getFactorSets() {
62
- const client = Client_1.Client.getInstance();
63
- const url = client.getDomain() + Constants_1.FACTOR_SET_API_PATH;
64
- return (0, request_1.makeApiRequest)({
65
- method: Constants_1.GET,
66
- url
67
- });
68
- }
69
- /**
70
- * Performs a search operation by making a POST request to the search API endpoint.
71
- *
72
- * @export
73
- * @param {SearchRequest} payload - The search request data to be sent to the API
74
- * @return {Promise<string>} A promise that resolves to the search results string returned by the API
75
- * @throws {Error} May throw an error if the API request fails
76
- *
77
- * @example
78
- * const searchRequest = {
79
- "time":{
80
- "date": "2020-06-10"
81
- },
82
- "activity": {
83
- "search" : "travel"},
84
- "location": {
85
- "country": "USA"
86
- }
87
- };
88
- * const results = await Search(searchRequest);
89
- */
90
- async function Search(payload) {
91
- const client = Client_1.Client.getInstance();
92
- const url = client.getDomain() + Constants_1.SEARCH_API_PATH;
93
- return (0, request_1.makeApiRequest)({
94
- method: Constants_1.POST,
95
- url,
96
- data: payload,
97
- });
98
- }
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calculate = calculate;
4
- const Client_1 = require("../Client");
5
- const Constants_1 = require("../Constants");
6
- const request_1 = require("../request");
7
- /**
8
- * Performs scope 1 fugitve emission calculations by making a POST request to the fugitive API endpoint.
9
- *
10
- * @export
11
- * @param {CommonRequest} payload - The request data to be sent to the API
12
- * @return {Promise<string>} A promise that resolves to the calculation result string returned by the API
13
- * @throws {Error} May throw an error if the API request fails
14
- *
15
- * @example
16
- * const request = {
17
- "time": {
18
- "date": "2025-01-04"
19
- },
20
- "location": {
21
- "country": "usa"
22
- },
23
- "activity": {
24
- "type": "R134A",
25
- "value": 150,
26
- "unit": "kg"
27
- },
28
- "includeDetails": false
29
- };
30
- * const result = await calculate(request);
31
- */
32
- async function calculate(payload) {
33
- const client = Client_1.Client.getInstance();
34
- const url = client.getDomain() + Constants_1.FUGITIVE_API_PATH;
35
- return (0, request_1.makeApiRequest)({
36
- method: Constants_1.POST,
37
- url,
38
- data: payload,
39
- });
40
- }