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.
- package/README.md +9 -0
- package/dist/Constants.js +2 -1
- package/dist/api/Calculation.js +4 -4
- package/dist/api/Factor.js +7 -7
- package/dist/api/FactorSets.js +1 -1
- package/dist/api/Fugitive.js +4 -4
- package/dist/api/Location.js +4 -4
- package/dist/api/Mobile.js +4 -6
- package/dist/api/Stationary.js +4 -4
- package/dist/api/TransportationAndDistribution.js +5 -5
- package/dist/api/Usage.js +26 -0
- package/dist/coverage/clover.xml +346 -0
- package/dist/coverage/coverage-final.json +20 -0
- package/dist/coverage/lcov-report/base.css +224 -0
- package/dist/coverage/lcov-report/block-navigation.js +87 -0
- package/dist/coverage/lcov-report/favicon.png +0 -0
- package/dist/coverage/lcov-report/index.html +161 -0
- package/dist/coverage/lcov-report/prettify.css +1 -0
- package/dist/coverage/lcov-report/prettify.js +2 -0
- package/dist/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/dist/coverage/lcov-report/sorter.js +210 -0
- package/dist/coverage/lcov-report/src/Client.ts.html +838 -0
- package/dist/coverage/lcov-report/src/Constants.ts.html +214 -0
- package/dist/coverage/lcov-report/src/api/Calculation.ts.html +436 -0
- package/dist/coverage/lcov-report/src/api/Factor.ts.html +622 -0
- package/dist/coverage/lcov-report/src/api/FactorSets.ts.html +157 -0
- package/dist/coverage/lcov-report/src/api/Fugitive.ts.html +436 -0
- package/dist/coverage/lcov-report/src/api/Location.ts.html +433 -0
- package/dist/coverage/lcov-report/src/api/Mobile.ts.html +448 -0
- package/dist/coverage/lcov-report/src/api/Stationary.ts.html +442 -0
- package/dist/coverage/lcov-report/src/api/TransportationAndDistribution.ts.html +436 -0
- package/dist/coverage/lcov-report/src/api/Usage.ts.html +160 -0
- package/dist/coverage/lcov-report/src/api/index.html +236 -0
- package/dist/coverage/lcov-report/src/index.html +161 -0
- package/dist/coverage/lcov-report/src/request.ts.html +235 -0
- package/dist/coverage/lcov-report/src/utils.ts.html +139 -0
- package/dist/coverage/lcov-report/test/index.html +116 -0
- package/dist/coverage/lcov-report/test/mocks/CommonRequest.ts.html +142 -0
- package/dist/coverage/lcov-report/test/mocks/FactorRequest.ts.html +133 -0
- package/dist/coverage/lcov-report/test/mocks/GenericCalculationRequest.ts.html +142 -0
- package/dist/coverage/lcov-report/test/mocks/LocationRequest.ts.html +139 -0
- package/dist/coverage/lcov-report/test/mocks/SearchRequest.ts.html +142 -0
- package/dist/coverage/lcov-report/test/mocks/index.html +176 -0
- package/dist/coverage/lcov-report/test/testUtils.ts.html +97 -0
- package/dist/coverage/lcov.info +578 -0
- package/dist/index.js +2 -1
- package/dist/interfaces/response/AreaResponse.js +2 -0
- package/dist/interfaces/response/EmissionResponse.js +2 -0
- package/dist/interfaces/response/EmissionResponseWithDetails.js +2 -0
- package/dist/interfaces/response/FactorResponse.js +2 -0
- package/dist/interfaces/response/FactorSetResponse.js +2 -0
- package/dist/interfaces/response/SearchResponse.js +2 -0
- package/dist/interfaces/response/TypeResponse.js +2 -0
- package/dist/interfaces/response/UnitResponse.js +2 -0
- package/dist/interfaces/response/UsageResponse.js +5 -0
- package/dist/types/Constants.d.ts +1 -0
- package/dist/types/api/Calculation.d.ts +13 -8
- package/dist/types/api/Factor.d.ts +18 -13
- package/dist/types/api/FactorSets.d.ts +3 -2
- package/dist/types/api/Fugitive.d.ts +13 -8
- package/dist/types/api/Location.d.ts +13 -8
- package/dist/types/api/Mobile.d.ts +13 -10
- package/dist/types/api/Stationary.d.ts +13 -8
- package/dist/types/api/TransportationAndDistribution.d.ts +14 -9
- package/dist/types/api/Usage.d.ts +13 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/interfaces/response/AreaResponse.d.ts +20 -0
- package/dist/types/interfaces/response/EmissionResponse.d.ts +31 -0
- package/dist/types/interfaces/response/EmissionResponseWithDetails.d.ts +144 -0
- package/dist/types/interfaces/response/FactorResponse.d.ts +53 -0
- package/dist/types/interfaces/response/FactorSetResponse.d.ts +38 -0
- package/dist/types/interfaces/response/SearchResponse.d.ts +41 -0
- package/dist/types/interfaces/response/TypeResponse.d.ts +7 -0
- package/dist/types/interfaces/response/UnitResponse.d.ts +16 -0
- package/dist/types/interfaces/response/UsageResponse.d.ts +17 -0
- package/docs/_sources/index.rst.txt +1 -0
- package/docs/_sources/reference.rst.txt +6 -0
- package/docs/_sources/troubleshooting.rst.txt +486 -0
- package/docs/authentication.html +1 -0
- package/docs/client.html +1 -0
- package/docs/genindex.html +5 -0
- package/docs/getting_started.html +1 -0
- package/docs/index.html +15 -0
- package/docs/objects.inv +0 -0
- package/docs/reference.html +71 -35
- package/docs/sdk.html +1 -0
- package/docs/search.html +1 -0
- package/docs/searchindex.js +1 -1
- package/docs/troubleshooting.html +777 -0
- package/package.json +1 -1
- package/sphinx-build/requirements.txt +5 -0
- package/sphinx-build/source/index.rst +1 -0
- package/sphinx-build/source/reference.rst +6 -0
- package/sphinx-build/source/troubleshooting.rst +486 -0
- package/src/Constants.ts +2 -0
- package/src/api/Calculation.ts +19 -14
- package/src/api/Factor.ts +27 -22
- package/src/api/FactorSets.ts +4 -3
- package/src/api/Fugitive.ts +19 -14
- package/src/api/Location.ts +20 -15
- package/src/api/Mobile.ts +19 -16
- package/src/api/Stationary.ts +19 -14
- package/src/api/TransportationAndDistribution.ts +21 -16
- package/src/api/Usage.ts +26 -0
- package/src/index.ts +35 -1
- package/src/interfaces/response/AreaResponse.ts +25 -0
- package/src/interfaces/response/EmissionResponse.ts +44 -0
- package/src/interfaces/response/EmissionResponseWithDetails.ts +183 -0
- package/src/interfaces/response/FactorResponse.ts +78 -0
- package/src/interfaces/response/FactorSetResponse.ts +52 -0
- package/src/interfaces/response/SearchResponse.ts +52 -0
- package/src/interfaces/response/TypeResponse.ts +7 -0
- package/src/interfaces/response/UnitResponse.ts +17 -0
- package/src/interfaces/response/UsageResponse.ts +23 -0
- package/test/apiTest.test.ts +35 -4
package/test/apiTest.test.ts
CHANGED
|
@@ -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<
|
|
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
|
|
326
|
+
// For GET requests with queryParams
|
|
304
327
|
if (queryParams) {
|
|
305
|
-
|
|
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 {
|