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
@@ -0,0 +1,129 @@
1
+ =========
2
+ Reference
3
+ =========
4
+
5
+
6
+ .. js:autoclass:: Client
7
+ :members:
8
+
9
+ .. js:autofunction:: request.makeApiRequest
10
+
11
+ .. js:autofunction:: utils.findExpiryTime
12
+
13
+ API
14
+ ===
15
+
16
+ .. js:autofunction:: Factor.retrieveFactor
17
+
18
+ .. js:autofunction:: Fugitive.calculate
19
+
20
+ .. js:autofunction:: Calculation.calculate
21
+
22
+ .. js:autofunction:: Location.calculate
23
+
24
+ .. js:autofunction:: Mobile.calculate
25
+
26
+ .. js:autofunction:: Stationary.calculate
27
+
28
+ .. js:autofunction:: TransportationAndDistribution.calculate
29
+
30
+ Metadata APIs
31
+ ===========
32
+
33
+ getTypes
34
+ --------
35
+
36
+ .. js:autofunction:: Factor.getTypes
37
+
38
+ .. js:autofunction:: Calculation.getTypes
39
+
40
+ .. js:autofunction:: Location.getTypes
41
+
42
+ .. js:autofunction:: Mobile.getTypes
43
+
44
+ .. js:autofunction:: Stationary.getTypes
45
+
46
+ .. js:autofunction:: TransportationAndDistribution.getTypes
47
+
48
+ .. js:autofunction:: Fugitive.getTypes
49
+
50
+ getArea
51
+ -------
52
+
53
+ .. js:autofunction:: Factor.getArea
54
+
55
+ .. js:autofunction:: Factor.getSearchArea
56
+
57
+ .. js:autofunction:: Calculation.getArea
58
+
59
+ .. js:autofunction:: Location.getArea
60
+
61
+ .. js:autofunction:: Mobile.getArea
62
+
63
+ .. js:autofunction:: Stationary.getArea
64
+
65
+ .. js:autofunction:: TransportationAndDistribution.getArea
66
+
67
+ .. js:autofunction:: Fugitive.getArea
68
+
69
+ getUnits
70
+ --------
71
+
72
+ .. js:autofunction:: Factor.getUnits
73
+
74
+ .. js:autofunction:: Calculation.getUnits
75
+
76
+ .. js:autofunction:: Location.getUnits
77
+
78
+ .. js:autofunction:: Mobile.getUnits
79
+
80
+ .. js:autofunction:: Stationary.getUnits
81
+
82
+ .. js:autofunction:: TransportationAndDistribution.getUnits
83
+
84
+ .. js:autofunction:: Fugitive.getUnits
85
+
86
+ Interfaces
87
+ ==========
88
+
89
+ .. js:autoclass:: Api.LocationRequestWithoutFactorId
90
+
91
+ .. js:autoclass:: Api.LocationRequestWithFactorId
92
+
93
+ .. js:autoclass:: Api.CommonRequestWithoutFactorId
94
+
95
+ .. js:autoclass:: Api.CommonRequestWithFactorId
96
+
97
+ .. js:autoclass:: Api.GenericCalculationRequestWithoutFactorId
98
+
99
+ .. js:autoclass:: Api.GenericCalculationRequestWithFactorId
100
+
101
+ .. js:autoclass:: Api.FactorRequestWithoutFactorId
102
+
103
+ .. js:autoclass:: Api.FactorRequestWithFactorId
104
+
105
+ .. js:autoclass:: Api.SearchRequest
106
+
107
+ .. js:autoclass:: common.Location
108
+
109
+ .. js:autoclass:: common.Time
110
+
111
+ .. js:autoclass:: common.Activity
112
+
113
+ .. js:autoclass:: common.ActivityWithFactorId
114
+
115
+ .. js:autoclass:: common.CombinedUnitsActivity
116
+
117
+ .. js:autoclass:: common.CombinedUnitsActivityWithFactorId
118
+
119
+ .. js:autoclass:: common.FactorActivity
120
+
121
+ .. js:autoclass:: common.FactorActivityWithFactorId
122
+
123
+ .. js:autoclass:: common.SearchActivity
124
+
125
+ .. js:autoclass:: common.Pagination
126
+
127
+ .. js:autoclass:: Config.RequestConfig
128
+
129
+ .. js:autoclass:: Config.ClientConfig
@@ -0,0 +1,13 @@
1
+ ===
2
+ SDK
3
+ ===
4
+
5
+ The IBM Envizi - Emissions API Node.js SDK provides a structured approach to interact with the Emissions API. This section covers the key components and usage patterns.
6
+
7
+ .. toctree::
8
+ :maxdepth: 2
9
+
10
+ client
11
+ authentication
12
+
13
+ .. Made with Bob
package/src/Constants.ts CHANGED
@@ -9,6 +9,32 @@ export const TRANSPORTATION_AND_DISTRIBUTION_API_PATH = "/v3/carbon/transportati
9
9
  export const FACTOR_API_PATH = "/v3/carbon/factor";
10
10
  export const FACTOR_SET_API_PATH = "/v3/carbon/factorset";
11
11
  export const SEARCH_API_PATH = "/v3/carbon/factor/search";
12
+
13
+ export const CALCULATION_TYPES = "/v3/carbon/calculation/types";
14
+ export const LOCATION_TYPES = "/v3/carbon/location/types";
15
+ export const FUGITIVE_API_TYPES = "/v3/carbon/fugitive/types";
16
+ export const MOBILE_API_TYPES = "/v3/carbon/mobile/types";
17
+ export const STATIONARY_API_TYPES = "/v3/carbon/stationary/types";
18
+ export const FACTOR_API_TYPES = "/v3/carbon/factor/types";
19
+ export const TRANSPORTATION_AND_DISTRIBUTION_API_TYPES = "/v3/carbon/transportation-and-distribution/types";
20
+
21
+ export const FUGITIVE_API_AREA = "/v3/carbon/fugitive/area";
22
+ export const GENERAL_API_AREA = "/v3/carbon/calculation/area";
23
+ export const LOCATION_API_AREA = "/v3/carbon/location/area";
24
+ export const MOBILE_API_AREA = "/v3/carbon/mobile/area";
25
+ export const STATIONARY_API_AREA = "/v3/carbon/stationary/area";
26
+ export const TRANSPORTATION_AND_DISTRIBUTION_API_AREA = "/v3/carbon/transportation-and-distribution/area";
27
+ export const SEARCH_API_AREA = "/v3/carbon/factor/search/area";
28
+ export const FACTOR_API_AREA = "/v3/carbon/factor/area";
29
+
30
+ export const FUGITIVE_API_UNITS = "/v3/carbon/fugitive/units";
31
+ export const LOCATION_API_UNITS = "/v3/carbon/location/units";
32
+ export const MOBILE_API_UNITS = "/v3/carbon/mobile/units";
33
+ export const STATIONARY_API_UNITS = "/v3/carbon/stationary/units";
34
+ export const GENERAL_API_UNITS = "/v3/carbon/calculation/units";
35
+ export const FACTOR_API_UNITS = "/v3/carbon/factor/units";
36
+ export const TRANSPORTATION_AND_DISTRIBUTION_API_UNITS = "/v3/carbon/transportation-and-distribution/units";
37
+
12
38
  export const GET = "GET";
13
39
  export const POST = "POST";
14
40
  export const CLIENT_SOURCE_HEADER = "X-Client-Source";
@@ -1,5 +1,5 @@
1
1
  import { Client } from "../Client";
2
- import { GENERIC_CALCULATION_API_PATH, POST } from "../Constants";
2
+ import { GENERIC_CALCULATION_API_PATH,CALCULATION_TYPES, POST, GET, GENERAL_API_AREA, GENERAL_API_UNITS } from "../Constants";
3
3
  import { CalculationRequest } 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 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
- };
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
31
  * const result = await calculate(calculationRequest);
32
32
  */
33
33
  export async function calculate(
@@ -42,3 +42,72 @@ export async function calculate(
42
42
  data: payload,
43
43
  });
44
44
  }
45
+
46
+
47
+ /**
48
+ * Retrieves available calculation types by making a GET request to the calculation types API endpoint.
49
+ *
50
+ * @export
51
+ * @return {Promise<string>} A promise that resolves to a string containing the available calculation 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(): Promise<string> {
58
+ const client = Client.getInstance();
59
+ const url = client.getDomain() + CALCULATION_TYPES;
60
+
61
+ return makeApiRequest<string>({
62
+ method: GET,
63
+ url
64
+ });
65
+ }
66
+
67
+ /**
68
+ * Retrieves information about geographical areas supported by the calculation API.
69
+ *
70
+ * @export
71
+ * @return {Promise<string>} A promise that resolves to a string containing the supported geographical areas
72
+ * @throws {Error} May throw an error if the API request fails
73
+ *
74
+ * @example
75
+ * const areas = await getArea();
76
+ */
77
+ export async function getArea(): Promise<string> {
78
+ const client = Client.getInstance();
79
+ const url = client.getDomain() + GENERAL_API_AREA;
80
+
81
+ return makeApiRequest<string>({
82
+ method: GET,
83
+ url
84
+ });
85
+ }
86
+
87
+ /**
88
+ * Retrieves available units for a specific calculation type.
89
+ *
90
+ * @export
91
+ * @param {string} type - The calculation type to get units for
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 "Natural Gas - Scope 3:AAA" emission calculation type with subtype
97
+ * const units = await getUnits("Natural Gas - Scope 3:AAA");
98
+
99
+ * // Get units for the "HFC-263fb" emission calculation type without subtype
100
+ * const units = await getUnits("HFC-263fb");
101
+ */
102
+ export async function getUnits(
103
+ type: string
104
+ ): Promise<string> {
105
+ const client = Client.getInstance();
106
+ const url = client.getDomain() + GENERAL_API_UNITS;
107
+
108
+ return makeApiRequest<string>({
109
+ method: GET,
110
+ url,
111
+ params : { type }
112
+ });
113
+ }
package/src/api/Factor.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Client } from "../Client";
2
- import { FACTOR_API_PATH, POST, SEARCH_API_PATH } from "../Constants";
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
4
  import { makeApiRequest } from "../request";
5
5
 
@@ -13,27 +13,26 @@ import { makeApiRequest } from "../request";
13
13
  *
14
14
  * @example
15
15
  * const factorRequest = {
16
-
17
- "activity": {
18
- "factorId": 12345
19
- }
16
+ "activity": {
17
+ "factorId": 12345
18
+ }
20
19
  };
21
20
 
22
- or
21
+ OR
23
22
 
24
23
  const factorRequest = {
25
- "time" : {
26
- "date": "2025-01-04"
27
- },
28
- "location": {
29
- "country": "usa",
30
- "stateProvince": "new york"
31
- },
32
- "activity": {
33
- "type":"natural gas"
34
- },
35
- "includeDetails": true
36
- };
24
+ "time" : {
25
+ "date": "2025-01-04"
26
+ },
27
+ "location": {
28
+ "country": "usa",
29
+ "stateProvince": "new york"
30
+ },
31
+ "activity": {
32
+ "type":"natural gas"
33
+ },
34
+ "includeDetails": true
35
+ };
37
36
  * const factor = await retrieveFactor(factorRequest);
38
37
  */
39
38
 
@@ -66,7 +65,7 @@ export async function retrieveFactor(
66
65
  },
67
66
  "activity": {
68
67
  "search" : "travel"},
69
- "location": {
68
+ "location": {
70
69
  "country": "USA"
71
70
  }
72
71
  };
@@ -84,3 +83,93 @@ export async function search(
84
83
  data: payload,
85
84
  });
86
85
  }
86
+
87
+ /**
88
+ * Retrieves available emission factor types by making a GET request to the API endpoint.
89
+ *
90
+ * @export
91
+ * @return {Promise<string>} A promise that resolves to a string containing the available emission factor types
92
+ * @throws {Error} May throw an error if the API request fails
93
+ *
94
+ * @example
95
+ * const types = await getTypes();
96
+ */
97
+ export async function getTypes(
98
+ ): Promise<string> {
99
+ const client = Client.getInstance();
100
+ const url = client.getDomain() + FACTOR_API_TYPES;
101
+
102
+ return makeApiRequest<string>({
103
+ method: GET,
104
+ url
105
+ });
106
+ }
107
+
108
+ /**
109
+ * Retrieves information about geographical areas supported by the factor search API.
110
+ *
111
+ * @export
112
+ * @return {Promise<string>} A promise that resolves to a string containing the supported geographical areas
113
+ * @throws {Error} May throw an error if the API request fails
114
+ *
115
+ * @example
116
+ * const areas = await getArea();
117
+ */
118
+ export async function getSearchArea(
119
+ ): Promise<string> {
120
+ const client = Client.getInstance();
121
+ const url = client.getDomain() + SEARCH_API_AREA;
122
+
123
+ return makeApiRequest<string>({
124
+ method: GET,
125
+ url
126
+ });
127
+ }
128
+
129
+ /**
130
+ * Retrieves information about geographical areas supported by the factor API.
131
+ *
132
+ * @export
133
+ * @return {Promise<string>} A promise that resolves to a string containing the supported geographical areas
134
+ * @throws {Error} May throw an error if the API request fails
135
+ *
136
+ * @example
137
+ * const areas = await getArea();
138
+ */
139
+ export async function getArea(): Promise<string> {
140
+ const client = Client.getInstance();
141
+ const url = client.getDomain() + FACTOR_API_AREA;
142
+
143
+ return makeApiRequest<string>({
144
+ method: GET,
145
+ url
146
+ });
147
+ }
148
+
149
+ /**
150
+ * Retrieves available units for a specific emission factor type.
151
+ *
152
+ * @export
153
+ * @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
155
+ * @throws {Error} May throw an error if the API request fails
156
+ *
157
+ * @example
158
+ * // Get units for the "Natural Gas - Scope 3:AAA" emission factor type with subtype
159
+ * const units = await getUnits("Natural Gas - Scope 3:AAA");
160
+
161
+ * // Get units for the "HFC-263fb" emission factor type without subtype
162
+ * const units = await getUnits("HFC-263fb");
163
+ */
164
+ export async function getUnits(
165
+ type : string
166
+ ): Promise<string> {
167
+ const client = Client.getInstance();
168
+ const url = client.getDomain() + FACTOR_API_UNITS;
169
+
170
+ return makeApiRequest<string>({
171
+ method: GET,
172
+ url,
173
+ params : { type }
174
+ });
175
+ }
@@ -1,5 +1,5 @@
1
1
  import { Client } from "../Client";
2
- import { FUGITIVE_API_PATH, POST } from "../Constants";
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
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": "R134A",
24
- "value": 150,
25
- "unit": "kg"
26
- },
27
- "includeDetails": false
16
+ "time": {
17
+ "date": "2025-01-04"
18
+ },
19
+ "location": {
20
+ "country": "usa"
21
+ },
22
+ "activity": {
23
+ "type": "R134A",
24
+ "value": 150,
25
+ "unit": "kg"
26
+ },
27
+ "includeDetails": false
28
28
  };
29
29
  * const result = await calculate(request);
30
30
  */
@@ -41,3 +41,73 @@ export async function calculate(
41
41
  data: payload,
42
42
  });
43
43
  }
44
+
45
+ /**
46
+ * Retrieves available fugitive emission 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 fugitive emission 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() + FUGITIVE_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 fugitive emissions 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() + FUGITIVE_API_AREA;
80
+
81
+ return makeApiRequest<string>({
82
+ method: GET,
83
+ url
84
+ });
85
+ }
86
+
87
+ /**
88
+ * Retrieves available units for a specific fugitive emission type.
89
+ *
90
+ * @export
91
+ * @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
93
+ * @throws {Error} May throw an error if the API request fails
94
+ *
95
+ * @example
96
+ * // Get units for the "Natural Gas - Scope 3:AAA" emission fugitive type with subtype
97
+ * const units = await getUnits("Natural Gas - Scope 3:AAA");
98
+
99
+ * // Get units for the "R-426A" emission fugitive type without subtype
100
+ * const units = await getUnits("R-426A");
101
+ */
102
+ export async function getUnits(
103
+ type : string
104
+ ): Promise<string> {
105
+ const client = Client.getInstance();
106
+ const url = client.getDomain() + FUGITIVE_API_UNITS;
107
+
108
+ return makeApiRequest<string>({
109
+ method: GET,
110
+ url,
111
+ params : { type }
112
+ });
113
+ }
@@ -1,5 +1,5 @@
1
1
  import { Client } from "../Client";
2
- import { LOCATION_API_PATH, POST } from "../Constants";
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
4
  import { makeApiRequest } from "../request";
5
5
 
@@ -13,20 +13,20 @@ import { makeApiRequest } from "../request";
13
13
  *
14
14
  * @example
15
15
  * const calculationRequest = {
16
- "time" : {
17
- "date": "2025-01-04"
18
- },
19
- "location": {
20
- "country": "usa",
21
- "stateProvince": "new york"
22
- },
23
- "activity": {
24
- "type":"electricity",
25
- "unit": "kwh",
26
- "value": 14123143
27
- },
28
- "includeDetails": true
29
- };
16
+ "time" : {
17
+ "date": "2025-01-04"
18
+ },
19
+ "location": {
20
+ "country": "usa",
21
+ "stateProvince": "new york"
22
+ },
23
+ "activity": {
24
+ "type":"electricity",
25
+ "unit": "kwh",
26
+ "value": 14123143
27
+ },
28
+ "includeDetails": true
29
+ };
30
30
  * const result = await calculate(calculationRequest);
31
31
  */
32
32
  export async function calculate(
@@ -41,3 +41,72 @@ export async function calculate(
41
41
  data: payload,
42
42
  });
43
43
  }
44
+
45
+
46
+ /**
47
+ * Retrieves available location-based calculation types by making a GET request to the location types API endpoint.
48
+ *
49
+ * @export
50
+ * @return {Promise<string>} A promise that resolves to a string containing the available location-based calculation types
51
+ * @throws {Error} May throw an error if the API request fails
52
+ *
53
+ * @example
54
+ *
55
+ * const types = await getTypes();
56
+ */
57
+ export async function getTypes(
58
+ ): Promise<string> {
59
+ const client = Client.getInstance();
60
+ const url = client.getDomain() + LOCATION_TYPES;
61
+
62
+ return makeApiRequest<string>({
63
+ method: GET,
64
+ url
65
+ });
66
+ }
67
+
68
+ /**
69
+ * Retrieves information about geographical areas supported by the location-based calculation 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() + LOCATION_API_AREA;
82
+
83
+ return makeApiRequest<string>({
84
+ method: GET,
85
+ url
86
+ });
87
+ }
88
+
89
+ /**
90
+ * Retrieves available units for a specific location-based calculation type.
91
+ *
92
+ * @export
93
+ * @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
95
+ * @throws {Error} May throw an error if the API request fails
96
+ *
97
+ * @example
98
+ * // Get units for the "electricity" location type
99
+ * const units = await getUnits("electricity");
100
+ */
101
+ export async function getUnits(
102
+ type : string
103
+ ): Promise<string> {
104
+ const client = Client.getInstance();
105
+ const url = client.getDomain() + LOCATION_API_UNITS;
106
+
107
+ return makeApiRequest<string>({
108
+ method: GET,
109
+ url,
110
+ params : { type }
111
+ });
112
+ }