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
package/src/api/Factor.ts CHANGED
@@ -1,6 +1,11 @@
1
1
  import { Client } from "../Client";
2
2
  import { FACTOR_API_AREA, FACTOR_API_PATH, FACTOR_API_TYPES, FACTOR_API_UNITS, GET, POST, SEARCH_API_AREA, SEARCH_API_PATH } from "../Constants";
3
3
  import { FactorRequest, SearchRequest } from "../interfaces/Api";
4
+ import { AreaResponse } from "../interfaces/response/AreaResponse";
5
+ import { FactorResponse } from "../interfaces/response/FactorResponse";
6
+ import { SearchResponse } from "../interfaces/response/SearchResponse";
7
+ import { TypeResponse } from "../interfaces/response/TypeResponse";
8
+ import { UnitResponse } from "../interfaces/response/UnitResponse";
4
9
  import { makeApiRequest } from "../request";
5
10
 
6
11
  /**
@@ -8,7 +13,7 @@ import { makeApiRequest } from "../request";
8
13
  *
9
14
  * @export
10
15
  * @param {FactorRequest} payload - The factor request data to be sent to the API
11
- * @return {Promise<string>} A promise that resolves to the factor string returned by the API
16
+ * @return {Promise<FactorResponse>} A promise that resolves to the FactorResponse returned by the API
12
17
  * @throws {Error} May throw an error if the API request fails
13
18
  *
14
19
  * @example
@@ -38,11 +43,11 @@ import { makeApiRequest } from "../request";
38
43
 
39
44
  export async function retrieveFactor(
40
45
  payload: FactorRequest
41
- ): Promise<string> {
46
+ ): Promise<FactorResponse> {
42
47
  const client = Client.getInstance();
43
48
  const url = client.getDomain() + FACTOR_API_PATH;
44
49
 
45
- return makeApiRequest<string>({
50
+ return makeApiRequest<FactorResponse>({
46
51
  method: POST,
47
52
  url,
48
53
  data: payload,
@@ -52,14 +57,14 @@ export async function retrieveFactor(
52
57
 
53
58
  /**
54
59
  * Performs a search operation by making a POST request to the search API endpoint.
55
- *
60
+ *
56
61
  * @export
57
62
  * @param {SearchRequest} payload - The search request data to be sent to the API
58
- * @return {Promise<string>} A promise that resolves to the search results string returned by the API
63
+ * @return {Promise<SearchResponse>} A promise that resolves to the search results returned by the API
59
64
  * @throws {Error} May throw an error if the API request fails
60
- *
65
+ *
61
66
  * @example
62
- * const searchRequest = {
67
+ * const searchRequest = {
63
68
  "time":{
64
69
  "date": "2020-06-10"
65
70
  },
@@ -73,11 +78,11 @@ export async function retrieveFactor(
73
78
  */
74
79
  export async function search(
75
80
  payload: SearchRequest
76
- ): Promise<string> {
81
+ ): Promise<SearchResponse> {
77
82
  const client = Client.getInstance();
78
83
  const url = client.getDomain() + SEARCH_API_PATH;
79
84
 
80
- return makeApiRequest<string>({
85
+ return makeApiRequest<SearchResponse>({
81
86
  method: POST,
82
87
  url,
83
88
  data: payload,
@@ -88,18 +93,18 @@ export async function search(
88
93
  * Retrieves available emission factor types by making a GET request to the API endpoint.
89
94
  *
90
95
  * @export
91
- * @return {Promise<string>} A promise that resolves to a string containing the available emission factor types
96
+ * @return {Promise<TypeResponse>} A promise that resolves to a TypeResponse containing the available emission factor types
92
97
  * @throws {Error} May throw an error if the API request fails
93
98
  *
94
99
  * @example
95
100
  * const types = await getTypes();
96
101
  */
97
102
  export async function getTypes(
98
- ): Promise<string> {
103
+ ): Promise<TypeResponse> {
99
104
  const client = Client.getInstance();
100
105
  const url = client.getDomain() + FACTOR_API_TYPES;
101
106
 
102
- return makeApiRequest<string>({
107
+ return makeApiRequest<TypeResponse>({
103
108
  method: GET,
104
109
  url
105
110
  });
@@ -109,18 +114,18 @@ export async function getTypes(
109
114
  * Retrieves information about geographical areas supported by the factor search API.
110
115
  *
111
116
  * @export
112
- * @return {Promise<string>} A promise that resolves to a string containing the supported geographical areas
117
+ * @return {Promise<AreaResponse>} A promise that resolves to an AreaResponse containing the supported geographical areas
113
118
  * @throws {Error} May throw an error if the API request fails
114
119
  *
115
120
  * @example
116
- * const areas = await getArea();
121
+ * const areas = await getSearchArea();
117
122
  */
118
123
  export async function getSearchArea(
119
- ): Promise<string> {
124
+ ): Promise<AreaResponse> {
120
125
  const client = Client.getInstance();
121
126
  const url = client.getDomain() + SEARCH_API_AREA;
122
127
 
123
- return makeApiRequest<string>({
128
+ return makeApiRequest<AreaResponse>({
124
129
  method: GET,
125
130
  url
126
131
  });
@@ -130,17 +135,17 @@ export async function getSearchArea(
130
135
  * Retrieves information about geographical areas supported by the factor API.
131
136
  *
132
137
  * @export
133
- * @return {Promise<string>} A promise that resolves to a string containing the supported geographical areas
138
+ * @return {Promise<AreaResponse>} A promise that resolves to an AreaResponse containing the supported geographical areas
134
139
  * @throws {Error} May throw an error if the API request fails
135
140
  *
136
141
  * @example
137
142
  * const areas = await getArea();
138
143
  */
139
- export async function getArea(): Promise<string> {
144
+ export async function getArea(): Promise<AreaResponse> {
140
145
  const client = Client.getInstance();
141
146
  const url = client.getDomain() + FACTOR_API_AREA;
142
147
 
143
- return makeApiRequest<string>({
148
+ return makeApiRequest<AreaResponse>({
144
149
  method: GET,
145
150
  url
146
151
  });
@@ -151,7 +156,7 @@ export async function getArea(): Promise<string> {
151
156
  *
152
157
  * @export
153
158
  * @param {string} type - The emission factor type to get units for (e.g., "Natural Gas - Scope 3:AAA")
154
- * @return {Promise<string>} A promise that resolves to a string containing the available units
159
+ * @return {Promise<UnitResponse>} A promise that resolves to a UnitResponse containing the available units
155
160
  * @throws {Error} May throw an error if the API request fails
156
161
  *
157
162
  * @example
@@ -163,11 +168,11 @@ export async function getArea(): Promise<string> {
163
168
  */
164
169
  export async function getUnits(
165
170
  type : string
166
- ): Promise<string> {
171
+ ): Promise<UnitResponse> {
167
172
  const client = Client.getInstance();
168
173
  const url = client.getDomain() + FACTOR_API_UNITS;
169
174
 
170
- return makeApiRequest<string>({
175
+ return makeApiRequest<UnitResponse>({
171
176
  method: GET,
172
177
  url,
173
178
  params : { type }
@@ -1,23 +1,24 @@
1
1
  import { Client } from "../Client";
2
2
  import { FACTOR_SET_API_PATH, GET } from "../Constants";
3
+ import { FactorSetResponse } from "../interfaces/response/FactorSetResponse";
3
4
  import { makeApiRequest } from "../request";
4
5
 
5
6
  /**
6
7
  * Retrieves factor sets by making a GET request to the factor set API endpoint.
7
8
  *
8
9
  * @export
9
- * @return {Promise<string>} A promise that resolves to the factor sets string returned by the API
10
+ * @return {Promise<FactorSetResponse>} A promise that resolves to the FactorSetResponse returned by the API
10
11
  * @throws {Error} May throw an error if the API request fails
11
12
  *
12
13
  * @example
13
14
  * const factorSets = await get();
14
15
  */
15
16
  export async function get(
16
- ): Promise<string> {
17
+ ): Promise<FactorSetResponse> {
17
18
  const client = Client.getInstance();
18
19
  const url = client.getDomain() + FACTOR_SET_API_PATH;
19
20
 
20
- return makeApiRequest<string>({
21
+ return makeApiRequest<FactorSetResponse>({
21
22
  method: GET,
22
23
  url
23
24
  });
@@ -1,16 +1,21 @@
1
1
  import { Client } from "../Client";
2
2
  import { FUGITIVE_API_AREA, FUGITIVE_API_PATH, FUGITIVE_API_TYPES, FUGITIVE_API_UNITS, GET, 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 { makeApiRequest } from "../request";
5
10
 
6
11
  /**
7
12
  * Performs scope 1 fugitve emission calculations by making a POST request to the fugitive API endpoint.
8
- *
13
+ *
9
14
  * @export
10
15
  * @param {CommonRequest} payload - The request data to be sent to the API
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
21
  "time": {
@@ -31,11 +36,11 @@ import { makeApiRequest } from "../request";
31
36
 
32
37
  export async function calculate(
33
38
  payload: CommonRequest
34
- ): Promise<string> {
39
+ ): Promise<EmissionResponse | EmissionResponseWithDetails> {
35
40
  const client = Client.getInstance();
36
41
  const url = client.getDomain() + FUGITIVE_API_PATH;
37
42
 
38
- return makeApiRequest<string>({
43
+ return makeApiRequest<EmissionResponse | EmissionResponseWithDetails>({
39
44
  method: POST,
40
45
  url,
41
46
  data: payload,
@@ -46,18 +51,18 @@ export async function calculate(
46
51
  * Retrieves available fugitive emission calculation types by making a GET request to the API endpoint.
47
52
  *
48
53
  * @export
49
- * @return {Promise<string>} A promise that resolves to a string containing the available fugitive emission types
54
+ * @return {Promise<TypeResponse>} A promise that resolves to a TypeResponse containing the available fugitive emission types
50
55
  * @throws {Error} May throw an error if the API request fails
51
56
  *
52
57
  * @example
53
58
  * const types = await getTypes();
54
59
  */
55
60
  export async function getTypes(
56
- ): Promise<string> {
61
+ ): Promise<TypeResponse> {
57
62
  const client = Client.getInstance();
58
63
  const url = client.getDomain() + FUGITIVE_API_TYPES;
59
64
 
60
- return makeApiRequest<string>({
65
+ return makeApiRequest<TypeResponse>({
61
66
  method: GET,
62
67
  url
63
68
  });
@@ -67,18 +72,18 @@ export async function getTypes(
67
72
  * Retrieves information about geographical areas supported by the fugitive emissions API.
68
73
  *
69
74
  * @export
70
- * @return {Promise<string>} A promise that resolves to a string containing the supported geographical areas
75
+ * @return {Promise<AreaResponse>} A promise that resolves to an AreaResponse containing the supported geographical areas
71
76
  * @throws {Error} May throw an error if the API request fails
72
77
  *
73
78
  * @example
74
79
  * const areas = await getArea();
75
80
  */
76
81
  export async function getArea(
77
- ): Promise<string> {
82
+ ): Promise<AreaResponse> {
78
83
  const client = Client.getInstance();
79
84
  const url = client.getDomain() + FUGITIVE_API_AREA;
80
85
 
81
- return makeApiRequest<string>({
86
+ return makeApiRequest<AreaResponse>({
82
87
  method: GET,
83
88
  url
84
89
  });
@@ -89,7 +94,7 @@ export async function getArea(
89
94
  *
90
95
  * @export
91
96
  * @param {string} type - The fugitive emission type to get units for (e.g., "R134A")
92
- * @return {Promise<string>} A promise that resolves to a string containing the available units
97
+ * @return {Promise<UnitResponse>} A promise that resolves to a UnitResponse containing the available units
93
98
  * @throws {Error} May throw an error if the API request fails
94
99
  *
95
100
  * @example
@@ -101,11 +106,11 @@ export async function getArea(
101
106
  */
102
107
  export async function getUnits(
103
108
  type : string
104
- ): Promise<string> {
109
+ ): Promise<UnitResponse> {
105
110
  const client = Client.getInstance();
106
111
  const url = client.getDomain() + FUGITIVE_API_UNITS;
107
112
 
108
- return makeApiRequest<string>({
113
+ return makeApiRequest<UnitResponse>({
109
114
  method: GET,
110
115
  url,
111
116
  params : { type }
@@ -1,16 +1,21 @@
1
1
  import { Client } from "../Client";
2
2
  import { GET, LOCATION_API_AREA, LOCATION_API_PATH, LOCATION_API_UNITS, LOCATION_TYPES, POST } from "../Constants";
3
3
  import { LocationRequest } 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
  * Performs scope 2 purchased energy Emission calculations by making a POST request to the location API endpoint.
8
- *
13
+ *
9
14
  * @export
10
15
  * @param {LocationRequest} payload - The location request data to be sent to the API
11
- * @return {Promise<string>} A promise that resolves to the purchased energy emission 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 calculationRequest = {
16
21
  "time" : {
@@ -31,11 +36,11 @@ import { makeApiRequest } from "../request";
31
36
  */
32
37
  export async function calculate(
33
38
  payload: LocationRequest
34
- ): Promise<string> {
39
+ ): Promise<EmissionResponse | EmissionResponseWithDetails> {
35
40
  const client = Client.getInstance();
36
41
  const url = client.getDomain() + LOCATION_API_PATH;
37
42
 
38
- return makeApiRequest<string>({
43
+ return makeApiRequest<EmissionResponse | EmissionResponseWithDetails>({
39
44
  method: POST,
40
45
  url,
41
46
  data: payload,
@@ -47,19 +52,19 @@ export async function calculate(
47
52
  * Retrieves available location-based calculation types by making a GET request to the location types API endpoint.
48
53
  *
49
54
  * @export
50
- * @return {Promise<string>} A promise that resolves to a string containing the available location-based calculation types
55
+ * @return {Promise<TypeResponse>} A promise that resolves to a TypeResponse containing the available location-based calculation types
51
56
  * @throws {Error} May throw an error if the API request fails
52
57
  *
53
58
  * @example
54
- *
59
+ *
55
60
  * const types = await getTypes();
56
61
  */
57
62
  export async function getTypes(
58
- ): Promise<string> {
63
+ ): Promise<TypeResponse> {
59
64
  const client = Client.getInstance();
60
65
  const url = client.getDomain() + LOCATION_TYPES;
61
66
 
62
- return makeApiRequest<string>({
67
+ return makeApiRequest<TypeResponse>({
63
68
  method: GET,
64
69
  url
65
70
  });
@@ -69,18 +74,18 @@ export async function getTypes(
69
74
  * Retrieves information about geographical areas supported by the location-based calculation API.
70
75
  *
71
76
  * @export
72
- * @return {Promise<string>} A promise that resolves to a string containing the supported geographical areas
77
+ * @return {Promise<AreaResponse>} A promise that resolves to an AreaResponse containing the supported geographical areas
73
78
  * @throws {Error} May throw an error if the API request fails
74
79
  *
75
80
  * @example
76
81
  * const areas = await getArea();
77
82
  */
78
83
  export async function getArea(
79
- ): Promise<string> {
84
+ ): Promise<AreaResponse> {
80
85
  const client = Client.getInstance();
81
86
  const url = client.getDomain() + LOCATION_API_AREA;
82
87
 
83
- return makeApiRequest<string>({
88
+ return makeApiRequest<AreaResponse>({
84
89
  method: GET,
85
90
  url
86
91
  });
@@ -91,7 +96,7 @@ export async function getArea(
91
96
  *
92
97
  * @export
93
98
  * @param {string} type - The location-based calculation type to get units for (e.g., "electricity")
94
- * @return {Promise<string>} A promise that resolves to a string containing the available units
99
+ * @return {Promise<UnitResponse>} A promise that resolves to a UnitResponse containing the available units
95
100
  * @throws {Error} May throw an error if the API request fails
96
101
  *
97
102
  * @example
@@ -100,11 +105,11 @@ export async function getArea(
100
105
  */
101
106
  export async function getUnits(
102
107
  type : string
103
- ): Promise<string> {
108
+ ): Promise<UnitResponse> {
104
109
  const client = Client.getInstance();
105
110
  const url = client.getDomain() + LOCATION_API_UNITS;
106
111
 
107
- return makeApiRequest<string>({
112
+ return makeApiRequest<UnitResponse>({
108
113
  method: GET,
109
114
  url,
110
115
  params : { type }
package/src/api/Mobile.ts CHANGED
@@ -1,17 +1,22 @@
1
1
  import { makeApiRequest } from "../request";
2
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,11 +38,11 @@ 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,
@@ -49,21 +54,19 @@ export async function calculate(
49
54
  * Retrieves available mobile emission calculation types by making a GET request to the API endpoint.
50
55
  *
51
56
  * @export
52
- * @return {Promise<string>} A promise that resolves to a string containing the available mobile emission types
57
+ * @return {Promise<TypeResponse>} A promise that resolves to a TypeResponse containing the available mobile emission types
53
58
  * @throws {Error} May throw an error if the API request fails
54
59
  *
55
60
  * @example
56
61
  * // Get all available mobile emission types
57
62
  * const types = await getTypes();
58
- * const typesData = JSON.parse(types);
59
- * console.log("Available mobile emission types:", typesData);
60
63
  */
61
64
  export async function getTypes(
62
- ): Promise<string> {
65
+ ): Promise<TypeResponse> {
63
66
  const client = Client.getInstance();
64
67
  const url = client.getDomain() + MOBILE_API_TYPES;
65
68
 
66
- return makeApiRequest<string>({
69
+ return makeApiRequest<TypeResponse>({
67
70
  method: GET,
68
71
  url
69
72
  });
@@ -73,18 +76,18 @@ export async function getTypes(
73
76
  * Retrieves information about geographical areas supported by the mobile emissions API.
74
77
  *
75
78
  * @export
76
- * @return {Promise<string>} A promise that resolves to a string containing the supported geographical areas
79
+ * @return {Promise<AreaResponse>} A promise that resolves to an AreaResponse containing the supported geographical areas
77
80
  * @throws {Error} May throw an error if the API request fails
78
81
  *
79
82
  * @example
80
83
  * const areas = await getArea();
81
84
  */
82
85
  export async function getArea(
83
- ): Promise<string> {
86
+ ): Promise<AreaResponse> {
84
87
  const client = Client.getInstance();
85
88
  const url = client.getDomain() + MOBILE_API_AREA;
86
89
 
87
- return makeApiRequest<string>({
90
+ return makeApiRequest<AreaResponse>({
88
91
  method: GET,
89
92
  url
90
93
  });
@@ -95,7 +98,7 @@ export async function getArea(
95
98
  *
96
99
  * @export
97
100
  * @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
101
+ * @return {Promise<UnitResponse>} A promise that resolves to a UnitResponse containing the available units
99
102
  * @throws {Error} May throw an error if the API request fails
100
103
  *
101
104
  * @example
@@ -107,11 +110,11 @@ export async function getArea(
107
110
  */
108
111
  export async function getUnits(
109
112
  type : string
110
- ): Promise<string> {
113
+ ): Promise<UnitResponse> {
111
114
  const client = Client.getInstance();
112
115
  const url = client.getDomain() + MOBILE_API_UNITS;
113
116
 
114
- return makeApiRequest<string>({
117
+ return makeApiRequest<UnitResponse>({
115
118
  method: GET,
116
119
  url,
117
120
  params : { type }
@@ -1,17 +1,22 @@
1
1
  import { Client } from "../Client";
2
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
22
  "time" : {
@@ -33,11 +38,11 @@ import { makeApiRequest } from "../request";
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,
@@ -48,18 +53,18 @@ export async function calculate(
48
53
  * Retrieves available stationary emission calculation types by making a GET request to the API endpoint.
49
54
  *
50
55
  * @export
51
- * @return {Promise<string>} A promise that resolves to a string containing the available stationary emission types
56
+ * @return {Promise<TypeResponse>} A promise that resolves to a TypeResponse containing the available stationary emission types
52
57
  * @throws {Error} May throw an error if the API request fails
53
58
  *
54
59
  * @example
55
60
  * const types = await getTypes();
56
61
  */
57
62
  export async function getTypes(
58
- ): Promise<string> {
63
+ ): Promise<TypeResponse> {
59
64
  const client = Client.getInstance();
60
65
  const url = client.getDomain() + STATIONARY_API_TYPES;
61
66
 
62
- return makeApiRequest<string>({
67
+ return makeApiRequest<TypeResponse>({
63
68
  method: GET,
64
69
  url
65
70
  });
@@ -69,18 +74,18 @@ export async function getTypes(
69
74
  * Retrieves information about geographical areas supported by the stationary emissions API.
70
75
  *
71
76
  * @export
72
- * @return {Promise<string>} A promise that resolves to a string containing the supported geographical areas
77
+ * @return {Promise<AreaResponse>} A promise that resolves to an AreaResponse containing the supported geographical areas
73
78
  * @throws {Error} May throw an error if the API request fails
74
79
  *
75
80
  * @example
76
81
  * const areas = await getArea();
77
82
  */
78
83
  export async function getArea(
79
- ): Promise<string> {
84
+ ): Promise<AreaResponse> {
80
85
  const client = Client.getInstance();
81
86
  const url = client.getDomain() + STATIONARY_API_AREA;
82
87
 
83
- return makeApiRequest<string>({
88
+ return makeApiRequest<AreaResponse>({
84
89
  method: GET,
85
90
  url
86
91
  });
@@ -91,7 +96,7 @@ export async function getArea(
91
96
  *
92
97
  * @export
93
98
  * @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
99
+ * @return {Promise<UnitResponse>} A promise that resolves to a UnitResponse containing the available units
95
100
  * @throws {Error} May throw an error if the API request fails
96
101
  *
97
102
  * @example
@@ -103,11 +108,11 @@ export async function getArea(
103
108
  */
104
109
  export async function getUnits(
105
110
  type : string
106
- ): Promise<string> {
111
+ ): Promise<UnitResponse> {
107
112
  const client = Client.getInstance();
108
113
  const url = client.getDomain() + STATIONARY_API_UNITS;
109
114
 
110
- return makeApiRequest<string>({
115
+ return makeApiRequest<UnitResponse>({
111
116
  method: GET,
112
117
  url,
113
118
  params : { type }