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
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Interface representing the response from the retrieve factor API
3
+ */
4
+ export interface FactorResponse {
5
+ /** Unique transaction identifier */
6
+ transactionId: string;
7
+
8
+ /** Total CO2 equivalent emissions (optional - not present in all responses)*/
9
+ totalCO2e?: number;
10
+
11
+ /** CO2 emissions value (optional - not present in all responses) */
12
+ CO2?: number;
13
+
14
+ /** CH4 (Methane) emissions value (optional - not present in all responses) */
15
+ CH4?: number;
16
+
17
+ /** N2O (Nitrous Oxide) emissions value (optional - not present in all responses) */
18
+ N2O?: number;
19
+
20
+ /** Biogenic CO2 emissions value (optional - not present in all responses) */
21
+ bioCO2?: number;
22
+
23
+ /** Indirect CO2 equivalent emissions value (optional - not present in all responses) */
24
+ indirectCO2e?: number;
25
+
26
+ /** Hydrofluorocarbon emissions value (optional - not present in all responses) */
27
+ HFC?: number;
28
+
29
+ /** Perfluorocarbon emissions value (optional - not present in all responses) */
30
+ PFC?: number;
31
+
32
+ /** Sulfur hexafluoride emissions value (optional - not present in all responses) */
33
+ SF6?: number;
34
+
35
+ /** Nitrogen trifluoride emissions value (optional - not present in all responses) */
36
+ NF3?: number;
37
+
38
+
39
+ /** Unit of measurement for emissions */
40
+ unit?: string;
41
+
42
+ /** Description of the emission factors (optional)*/
43
+ description?: string;
44
+
45
+ /** Factor set identifier (e.g., "IPCC", "IGES") */
46
+ factorSet: string;
47
+
48
+ /** Source reference for the emission factors (optional)*/
49
+ source?: string;
50
+
51
+ /** Type of activity (e.g., "Gas/Diesel Oil", "Electricity") */
52
+ activityType: string;
53
+
54
+ /** Array of supported activity units */
55
+ activityUnit: string[];
56
+
57
+ /** Name of the emission factor */
58
+ name?: string;
59
+
60
+ /** Publication start date in ISO format (optional)*/
61
+ publishedFrom?: string;
62
+
63
+ /** Publication end date in ISO format (optional) */
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
+
73
+ /** Geographic region (e.g., "Earth", "India") */
74
+ region: string;
75
+
76
+ /** Unique factor identifier */
77
+ factorId: number;
78
+ }
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Interface for individual factor set within the response
3
+ */
4
+ export interface FactorSet {
5
+ /** Unique identifier for the factor set (required) */
6
+ id: number;
7
+
8
+ /** Name of the factor set (required) */
9
+ name: string;
10
+
11
+ /** License type for the factor set (required, e.g., "Public") */
12
+ license: string;
13
+
14
+ /** Number of factors in this set (required) */
15
+ factorCount: number;
16
+
17
+ /** Source URL for the factor set data */
18
+ sourceUrl?: string;
19
+
20
+ /** Detailed description of the factor set */
21
+ description?: string;
22
+
23
+ /** Short description of the factor set */
24
+ descriptionShort?: string;
25
+
26
+ /** Array of emission factor types included in this set */
27
+ types?: string[];
28
+
29
+ /** Array of regions/countries covered by this factor set */
30
+ regions?: string[];
31
+
32
+ /** Array of version years available for this factor set */
33
+ versions?: string[];
34
+
35
+ /** Provider/publisher of the factor set */
36
+ provider?: string;
37
+
38
+ /** Optional citation information for the factor set */
39
+ citation?: string;
40
+ }
41
+
42
+ /**
43
+ * Interface for Factor Set API response
44
+ */
45
+ export interface FactorSetResponse {
46
+ /** Transaction ID for the API request */
47
+ transactionId: string;
48
+
49
+ /** Array of factor sets returned in the response */
50
+ factorSets: FactorSet[];
51
+ }
52
+
@@ -0,0 +1,52 @@
1
+ import { FactorResponse } from './FactorResponse';
2
+
3
+ /**
4
+ * Pagination parameters for search requests
5
+ */
6
+ export interface Pagination {
7
+ /** Page number */
8
+ page: number;
9
+
10
+ /** Page size */
11
+ size: number;
12
+ }
13
+
14
+ /**
15
+ * Request body structure for pagination links
16
+ */
17
+ export interface PaginationBody {
18
+ /** Pagination parameters */
19
+ pagination?: Pagination;
20
+ }
21
+
22
+ /**
23
+ * Link object for pagination in search results
24
+ */
25
+ export interface SearchLink {
26
+ /** Relationship type (e.g., "next", "prev") */
27
+ rel: string;
28
+
29
+ /** URL for the link */
30
+ href: string;
31
+
32
+ /** Content type */
33
+ type: string;
34
+
35
+ /** HTTP method */
36
+ method: string;
37
+
38
+ /** Request body for pagination */
39
+ body?: PaginationBody;
40
+ }
41
+
42
+ /**
43
+ * Interface representing the response from the search factor API
44
+ */
45
+ export interface SearchResponse {
46
+ /** Array of factor results */
47
+ factors: FactorResponse[];
48
+
49
+ /** Pagination links (optional) */
50
+ links?: SearchLink[];
51
+ }
52
+
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Interface for type metadata API
3
+ */
4
+ export interface TypeResponse {
5
+ /** Array of string*/
6
+ types: string[];
7
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Interface for /units metadata API
3
+ */
4
+ export interface UnitResponse {
5
+ /** Array of string*/
6
+ units: string[];
7
+ }
@@ -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";
@@ -28,10 +50,11 @@ import SearchPayload from "./mocks/SearchRequest";
28
50
 
29
51
  type ApiTestCase = {
30
52
  name: string;
31
- func: (payload?: any) => Promise<string>;
53
+ func: (payload?: any) => Promise<any>;
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
- }
@@ -1,41 +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 emission calculations by making a POST request to the generic calculation API endpoint.
9
- *
10
- * @export
11
- * @param {GenericCalculationRequest} payload - The calculation 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 calculationRequest = {
17
- "time" : {
18
- "date": "2025-01-04"
19
- },
20
- "location": {
21
- "country": "usa",
22
- "stateProvince": "new york"
23
- },
24
- "activity": {
25
- "type":"Waste Combusted - Steel Cans:Default factor",
26
- "unit": "kg",
27
- "value": 1223123.121
28
- },
29
- "includeDetails": true
30
- };
31
- * const result = await calculate(calculationRequest);
32
- */
33
- async function calculate(payload) {
34
- const client = Client_1.Client.getInstance();
35
- const url = client.getDomain() + Constants_1.GENERIC_CALCULATION_API_PATH;
36
- return (0, request_1.makeApiRequest)({
37
- method: Constants_1.POST,
38
- url,
39
- data: payload,
40
- });
41
- }
@@ -1,41 +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 2 purchased energy Emission calculations by making a POST request to the location API endpoint.
9
- *
10
- * @export
11
- * @param {LocationRequest} payload - The location request data to be sent to the API
12
- * @return {Promise<string>} A promise that resolves to the purchased energy emission result string returned by the API
13
- * @throws {Error} May throw an error if the API request fails
14
- *
15
- * @example
16
- * const calculationRequest = {
17
- "time" : {
18
- "date": "2025-01-04"
19
- },
20
- "location": {
21
- "country": "usa",
22
- "stateProvince": "new york"
23
- },
24
- "activity": {
25
- "type":"electricity",
26
- "unit": "kwh",
27
- "value": 14123143
28
- },
29
- "includeDetails": true
30
- };
31
- * const result = await calculate(calculationRequest);
32
- */
33
- async function calculate(payload) {
34
- const client = Client_1.Client.getInstance();
35
- const url = client.getDomain() + Constants_1.LOCATION_API_PATH;
36
- return (0, request_1.makeApiRequest)({
37
- method: Constants_1.POST,
38
- url,
39
- data: payload,
40
- });
41
- }
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calculate = calculate;
4
- const request_1 = require("../request");
5
- const Constants_1 = require("../Constants");
6
- const Client_1 = require("../Client");
7
- /**
8
- * Performs Scope 1 mobile emissions related calculations by making a POST request to the mobile API endpoint.
9
- *
10
- * @export
11
- * @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
13
- * @throws {Error} May throw an error if the API request fails
14
- *
15
- * @example
16
- * const request = {
17
- "time": {
18
- "date": "2022-01-01"
19
- },
20
- "location": {
21
- "country": "USA",
22
- "stateProvince": "new york"
23
- },
24
- "activity": {
25
- "type": "Diesel Fuel",
26
- "value": 1500000,
27
- "unit": "l"
28
- },
29
- "includeDetails": false
30
- };
31
- * const result = await calculate(request);
32
- */
33
- async function calculate(payload) {
34
- const client = Client_1.Client.getInstance();
35
- const url = client.getDomain() + Constants_1.MOBILE_API_PATH;
36
- return (0, request_1.makeApiRequest)({
37
- method: Constants_1.POST,
38
- url,
39
- data: payload,
40
- });
41
- }