emissions-api-sdk 1.0.1 → 1.0.3

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 (115) hide show
  1. package/README.md +9 -0
  2. package/dist/Constants.js +2 -1
  3. package/dist/api/Calculation.js +4 -4
  4. package/dist/api/Factor.js +7 -7
  5. package/dist/api/FactorSets.js +1 -1
  6. package/dist/api/Fugitive.js +4 -4
  7. package/dist/api/Location.js +4 -4
  8. package/dist/api/Mobile.js +4 -6
  9. package/dist/api/Stationary.js +4 -4
  10. package/dist/api/TransportationAndDistribution.js +5 -5
  11. package/dist/api/Usage.js +26 -0
  12. package/dist/coverage/clover.xml +346 -0
  13. package/dist/coverage/coverage-final.json +20 -0
  14. package/dist/coverage/lcov-report/base.css +224 -0
  15. package/dist/coverage/lcov-report/block-navigation.js +87 -0
  16. package/dist/coverage/lcov-report/favicon.png +0 -0
  17. package/dist/coverage/lcov-report/index.html +161 -0
  18. package/dist/coverage/lcov-report/prettify.css +1 -0
  19. package/dist/coverage/lcov-report/prettify.js +2 -0
  20. package/dist/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  21. package/dist/coverage/lcov-report/sorter.js +210 -0
  22. package/dist/coverage/lcov-report/src/Client.ts.html +838 -0
  23. package/dist/coverage/lcov-report/src/Constants.ts.html +214 -0
  24. package/dist/coverage/lcov-report/src/api/Calculation.ts.html +436 -0
  25. package/dist/coverage/lcov-report/src/api/Factor.ts.html +622 -0
  26. package/dist/coverage/lcov-report/src/api/FactorSets.ts.html +157 -0
  27. package/dist/coverage/lcov-report/src/api/Fugitive.ts.html +436 -0
  28. package/dist/coverage/lcov-report/src/api/Location.ts.html +433 -0
  29. package/dist/coverage/lcov-report/src/api/Mobile.ts.html +448 -0
  30. package/dist/coverage/lcov-report/src/api/Stationary.ts.html +442 -0
  31. package/dist/coverage/lcov-report/src/api/TransportationAndDistribution.ts.html +436 -0
  32. package/dist/coverage/lcov-report/src/api/Usage.ts.html +160 -0
  33. package/dist/coverage/lcov-report/src/api/index.html +236 -0
  34. package/dist/coverage/lcov-report/src/index.html +161 -0
  35. package/dist/coverage/lcov-report/src/request.ts.html +235 -0
  36. package/dist/coverage/lcov-report/src/utils.ts.html +139 -0
  37. package/dist/coverage/lcov-report/test/index.html +116 -0
  38. package/dist/coverage/lcov-report/test/mocks/CommonRequest.ts.html +142 -0
  39. package/dist/coverage/lcov-report/test/mocks/FactorRequest.ts.html +133 -0
  40. package/dist/coverage/lcov-report/test/mocks/GenericCalculationRequest.ts.html +142 -0
  41. package/dist/coverage/lcov-report/test/mocks/LocationRequest.ts.html +139 -0
  42. package/dist/coverage/lcov-report/test/mocks/SearchRequest.ts.html +142 -0
  43. package/dist/coverage/lcov-report/test/mocks/index.html +176 -0
  44. package/dist/coverage/lcov-report/test/testUtils.ts.html +97 -0
  45. package/dist/coverage/lcov.info +578 -0
  46. package/dist/index.js +2 -1
  47. package/dist/interfaces/response/AreaResponse.js +2 -0
  48. package/dist/interfaces/response/EmissionResponse.js +2 -0
  49. package/dist/interfaces/response/EmissionResponseWithDetails.js +2 -0
  50. package/dist/interfaces/response/FactorResponse.js +2 -0
  51. package/dist/interfaces/response/FactorSetResponse.js +2 -0
  52. package/dist/interfaces/response/SearchResponse.js +2 -0
  53. package/dist/interfaces/response/TypeResponse.js +2 -0
  54. package/dist/interfaces/response/UnitResponse.js +2 -0
  55. package/dist/interfaces/response/UsageResponse.js +5 -0
  56. package/dist/types/Constants.d.ts +1 -0
  57. package/dist/types/api/Calculation.d.ts +13 -8
  58. package/dist/types/api/Factor.d.ts +18 -13
  59. package/dist/types/api/FactorSets.d.ts +3 -2
  60. package/dist/types/api/Fugitive.d.ts +13 -8
  61. package/dist/types/api/Location.d.ts +13 -8
  62. package/dist/types/api/Mobile.d.ts +13 -10
  63. package/dist/types/api/Stationary.d.ts +13 -8
  64. package/dist/types/api/TransportationAndDistribution.d.ts +14 -9
  65. package/dist/types/api/Usage.d.ts +13 -0
  66. package/dist/types/index.d.ts +10 -0
  67. package/dist/types/interfaces/response/AreaResponse.d.ts +20 -0
  68. package/dist/types/interfaces/response/EmissionResponse.d.ts +31 -0
  69. package/dist/types/interfaces/response/EmissionResponseWithDetails.d.ts +144 -0
  70. package/dist/types/interfaces/response/FactorResponse.d.ts +53 -0
  71. package/dist/types/interfaces/response/FactorSetResponse.d.ts +38 -0
  72. package/dist/types/interfaces/response/SearchResponse.d.ts +41 -0
  73. package/dist/types/interfaces/response/TypeResponse.d.ts +7 -0
  74. package/dist/types/interfaces/response/UnitResponse.d.ts +16 -0
  75. package/dist/types/interfaces/response/UsageResponse.d.ts +17 -0
  76. package/docs/_sources/index.rst.txt +1 -0
  77. package/docs/_sources/reference.rst.txt +6 -0
  78. package/docs/_sources/troubleshooting.rst.txt +486 -0
  79. package/docs/authentication.html +1 -0
  80. package/docs/client.html +1 -0
  81. package/docs/genindex.html +5 -0
  82. package/docs/getting_started.html +1 -0
  83. package/docs/index.html +15 -0
  84. package/docs/objects.inv +0 -0
  85. package/docs/reference.html +71 -35
  86. package/docs/sdk.html +1 -0
  87. package/docs/search.html +1 -0
  88. package/docs/searchindex.js +1 -1
  89. package/docs/troubleshooting.html +777 -0
  90. package/package.json +1 -1
  91. package/sphinx-build/requirements.txt +5 -0
  92. package/sphinx-build/source/index.rst +1 -0
  93. package/sphinx-build/source/reference.rst +6 -0
  94. package/sphinx-build/source/troubleshooting.rst +486 -0
  95. package/src/Constants.ts +2 -0
  96. package/src/api/Calculation.ts +19 -14
  97. package/src/api/Factor.ts +27 -22
  98. package/src/api/FactorSets.ts +4 -3
  99. package/src/api/Fugitive.ts +19 -14
  100. package/src/api/Location.ts +20 -15
  101. package/src/api/Mobile.ts +19 -16
  102. package/src/api/Stationary.ts +19 -14
  103. package/src/api/TransportationAndDistribution.ts +21 -16
  104. package/src/api/Usage.ts +26 -0
  105. package/src/index.ts +35 -1
  106. package/src/interfaces/response/AreaResponse.ts +25 -0
  107. package/src/interfaces/response/EmissionResponse.ts +44 -0
  108. package/src/interfaces/response/EmissionResponseWithDetails.ts +183 -0
  109. package/src/interfaces/response/FactorResponse.ts +78 -0
  110. package/src/interfaces/response/FactorSetResponse.ts +52 -0
  111. package/src/interfaces/response/SearchResponse.ts +52 -0
  112. package/src/interfaces/response/TypeResponse.ts +7 -0
  113. package/src/interfaces/response/UnitResponse.ts +17 -0
  114. package/src/interfaces/response/UsageResponse.ts +23 -0
  115. package/test/apiTest.test.ts +35 -4
@@ -5,6 +5,7 @@ import * as mobileApi from "../src/api/Mobile";
5
5
  import * as stationaryApi from "../src/api/Stationary";
6
6
  import * as GenericCalculation from "../src/api/Calculation";
7
7
  import * as TransportationDistributionApi from "../src/api/TransportationAndDistribution";
8
+ import * as UsageApi from "../src/api/Usage";
8
9
  import * as Factors from "../src/api/Factor";
9
10
  import * as FactorSets from "../src/api/FactorSets";
10
11
 
@@ -40,6 +41,7 @@ import {
40
41
  GENERAL_API_UNITS,
41
42
  FACTOR_API_UNITS,
42
43
  TRANSPORTATION_AND_DISTRIBUTION_API_UNITS,
44
+ USAGE_API
43
45
  } from "../src/Constants";
44
46
  import locationPayload from "./mocks/LocationRequest";
45
47
  import commonpayload from "./mocks/CommonRequest";
@@ -50,11 +52,11 @@ import SearchPayload from "./mocks/SearchRequest";
50
52
 
51
53
  type ApiTestCase = {
52
54
  name: string;
53
- func: (payload?: any) => Promise<string>;
55
+ func: (payload?: any) => Promise<any>;
54
56
  path: string;
55
57
  payload?: any;
56
58
  pathParams?: string | string[];
57
- queryParams?: Record<string, string>;
59
+ queryParams?: Record<string, string> | Record<string, boolean>;
58
60
  method: "GET" | "POST";
59
61
  };
60
62
 
@@ -262,6 +264,27 @@ const testCases: ApiTestCase[] = [
262
264
  queryParams: { type: "Business Travel - Cars:Diesel - Small" },
263
265
  method: "GET",
264
266
  },
267
+ {
268
+ name: "Usage API - getUsage with history false",
269
+ func: UsageApi.getUsage,
270
+ path: USAGE_API,
271
+ queryParams: { history: false },
272
+ method: "GET",
273
+ },
274
+ {
275
+ name: "Usage API - getUsage with history true",
276
+ func: UsageApi.getUsage,
277
+ path: USAGE_API,
278
+ queryParams: { history: true },
279
+ method: "GET",
280
+ },
281
+ {
282
+ name: "Usage API - getUsage default",
283
+ func: UsageApi.getUsage,
284
+ path: USAGE_API,
285
+ queryParams: { history: false },
286
+ method: "GET",
287
+ }
265
288
  ];
266
289
 
267
290
  describe("API Test calculate functions", () => {
@@ -300,9 +323,17 @@ describe("API Test calculate functions", () => {
300
323
  if (method === "POST") {
301
324
  result = await func(payload);
302
325
  } else {
303
- // For GET requests with queryParams, pass the type value
326
+ // For GET requests with queryParams
304
327
  if (queryParams) {
305
- result = await func(queryParams.type);
328
+ // Check if it's a Usage API call with history parameter
329
+ if (queryParams.hasOwnProperty('history')) {
330
+ result = await func(queryParams.history);
331
+ } else if (queryParams.type) {
332
+ // For other APIs that use type parameter
333
+ result = await func(queryParams.type);
334
+ } else {
335
+ result = await func();
336
+ }
306
337
  } else if (pathParams !== undefined) {
307
338
  result = await func(pathParams);
308
339
  } else {