emissions-api-sdk 1.0.4 → 1.0.6

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 (93) hide show
  1. package/README.md +19 -26
  2. package/dist/Constants.js +6 -23
  3. package/dist/api/Calculation.js +0 -63
  4. package/dist/api/EconomicActivity.js +40 -0
  5. package/dist/api/Factor.js +0 -82
  6. package/dist/api/Fugitive.js +0 -63
  7. package/dist/api/Location.js +0 -61
  8. package/dist/api/Metadata.js +155 -0
  9. package/dist/api/Mobile.js +0 -64
  10. package/dist/api/RealEstate.js +40 -0
  11. package/dist/api/Stationary.js +0 -63
  12. package/dist/api/TransportationAndDistribution.js +0 -63
  13. package/dist/coverage/clover.xml +144 -199
  14. package/dist/coverage/coverage-final.json +14 -11
  15. package/dist/coverage/lcov-report/index.html +20 -20
  16. package/dist/coverage/lcov-report/src/Client.ts.html +28 -28
  17. package/dist/coverage/lcov-report/src/Constants.ts.html +31 -88
  18. package/dist/coverage/lcov-report/src/api/Calculation.ts.html +7 -217
  19. package/dist/coverage/lcov-report/src/api/EconomicActivity.ts.html +220 -0
  20. package/dist/coverage/lcov-report/src/api/Factor.ts.html +6 -285
  21. package/dist/coverage/lcov-report/src/api/FactorSets.ts.html +1 -1
  22. package/dist/coverage/lcov-report/src/api/Fugitive.ts.html +7 -223
  23. package/dist/coverage/lcov-report/src/api/Location.ts.html +6 -222
  24. package/dist/coverage/lcov-report/src/api/Metadata.ts.html +604 -0
  25. package/dist/coverage/lcov-report/src/api/Mobile.ts.html +6 -231
  26. package/dist/coverage/lcov-report/src/api/RealEstate.ts.html +217 -0
  27. package/dist/coverage/lcov-report/src/api/Stationary.ts.html +6 -225
  28. package/dist/coverage/lcov-report/src/api/TransportationAndDistribution.ts.html +7 -223
  29. package/dist/coverage/lcov-report/src/api/Usage.ts.html +1 -1
  30. package/dist/coverage/lcov-report/src/api/index.html +72 -27
  31. package/dist/coverage/lcov-report/src/index.html +7 -7
  32. package/dist/coverage/lcov-report/src/request.ts.html +5 -5
  33. package/dist/coverage/lcov-report/src/utils.ts.html +6 -6
  34. package/dist/coverage/lcov-report/test/index.html +1 -1
  35. package/dist/coverage/lcov-report/test/mocks/CommonRequest.ts.html +1 -1
  36. package/dist/coverage/lcov-report/test/mocks/FactorRequest.ts.html +1 -1
  37. package/dist/coverage/lcov-report/test/mocks/GenericCalculationRequest.ts.html +1 -1
  38. package/dist/coverage/lcov-report/test/mocks/LocationRequest.ts.html +1 -1
  39. package/dist/coverage/lcov-report/test/mocks/SearchRequest.ts.html +1 -1
  40. package/dist/coverage/lcov-report/test/mocks/index.html +1 -1
  41. package/dist/coverage/lcov-report/test/testUtils.ts.html +1 -1
  42. package/dist/coverage/lcov.info +241 -294
  43. package/dist/index.js +4 -1
  44. package/dist/types/Constants.d.ts +5 -22
  45. package/dist/types/api/Calculation.d.ts +0 -41
  46. package/dist/types/api/EconomicActivity.d.ts +29 -0
  47. package/dist/types/api/Factor.d.ts +0 -52
  48. package/dist/types/api/Fugitive.d.ts +0 -41
  49. package/dist/types/api/Location.d.ts +0 -39
  50. package/dist/types/api/Metadata.d.ts +99 -0
  51. package/dist/types/api/Mobile.d.ts +0 -42
  52. package/dist/types/api/RealEstate.d.ts +29 -0
  53. package/dist/types/api/Stationary.d.ts +0 -41
  54. package/dist/types/api/TransportationAndDistribution.d.ts +0 -41
  55. package/dist/types/index.d.ts +3 -0
  56. package/dist/types/interfaces/response/FactorResponse.d.ts +0 -4
  57. package/docs/_sources/index.rst.txt +8 -6
  58. package/docs/_sources/reference.rst.txt +17 -37
  59. package/docs/_static/basic.css +8 -0
  60. package/docs/_static/pygments.css +146 -164
  61. package/docs/_static/searchtools.js +5 -8
  62. package/docs/_static/styles/furo.css +1 -1
  63. package/docs/_static/styles/furo.css.map +1 -1
  64. package/docs/authentication.html +28 -19
  65. package/docs/client.html +28 -19
  66. package/docs/genindex.html +56 -71
  67. package/docs/getting_started.html +28 -19
  68. package/docs/index.html +31 -20
  69. package/docs/objects.inv +0 -0
  70. package/docs/reference.html +151 -357
  71. package/docs/sdk.html +28 -19
  72. package/docs/search.html +28 -19
  73. package/docs/searchindex.js +1 -1
  74. package/docs/troubleshooting.html +28 -19
  75. package/package.json +7 -2
  76. package/sphinx-build/source/index.rst +8 -6
  77. package/sphinx-build/source/reference.rst +17 -37
  78. package/src/Constants.ts +6 -25
  79. package/src/api/Calculation.ts +1 -72
  80. package/src/api/EconomicActivity.ts +45 -0
  81. package/src/api/Factor.ts +1 -94
  82. package/src/api/Fugitive.ts +1 -74
  83. package/src/api/Location.ts +1 -73
  84. package/src/api/Metadata.ts +174 -0
  85. package/src/api/Mobile.ts +1 -76
  86. package/src/api/RealEstate.ts +45 -0
  87. package/src/api/Stationary.ts +1 -74
  88. package/src/api/TransportationAndDistribution.ts +1 -74
  89. package/src/index.ts +3 -0
  90. package/src/interfaces/response/FactorResponse.ts +0 -7
  91. package/test/apiTest.test.ts +19 -162
  92. package/test/metadata.test.ts +224 -0
  93. package/test/request.test.ts +0 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # IBM Envizi - Emissions API Node.js SDK
2
2
 
3
- IBM Envizi - Emissions API (Emissions API) is a managed factor database and calculation engine for embedding greenhouse gas (GHG) emissions calculations into operational decision making.
3
+ [IBM Envizi - Emissions API](https://www.ibm.com/products/envizi/emissions-api) (Emissions API) is a managed factor database and calculation engine for embedding greenhouse gas (GHG) emissions calculations into operational decision making.
4
4
 
5
5
  The `emissions-api-sdk` is a Node.js SDK for using Emissions API in your projects.
6
6
 
@@ -8,7 +8,7 @@ The `emissions-api-sdk` is a Node.js SDK for using Emissions API in your project
8
8
 
9
9
  To get started with the Emissions API follow these steps:
10
10
 
11
- - Sign up for the preview waitlist [IBMid sign up](https://www.ibm.com/account/reg/us-en/signup?formid=urx-53659) page.
11
+ - Sign up for the preview waitlist [IBMid sign up](https://www.ibm.com/account/reg/us-en/signup?formid=urx-53999) page.
12
12
  - You will be sent an invite email to join to create an account.
13
13
  - Read the [Introduction](https://developer.ibm.com/apis/catalog/ghgemissions--ibm-envizi-emissions-api/Introduction) page to get an overview of the Emissions API.
14
14
 
@@ -48,42 +48,35 @@ const result = await LocationEmission.calculate({
48
48
 
49
49
  ## Metadata APIs
50
50
 
51
- The SDK provides Metadata APIs to discover available emission types, geographical areas, and units:
52
-
53
- ### Get Available Types
51
+ The Metadata API provides a unified way to query metadata for any endpoint:
54
52
 
55
53
  ```javascript
56
- import { LocationEmission } from 'emissions-api-sdk';
57
-
58
- // Get all available Location emission types
59
- const types = await LocationEmission.getTypes();
60
- ```
54
+ import { Metadata } from 'emissions-api-sdk';
61
55
 
62
- ### Get Supported Areas
56
+ // Get types for any endpoint (defaults to 'calculation')
57
+ const allTypes = await Metadata.getTypes();
58
+ const locationTypes = await Metadata.getTypes('location');
59
+ const stationaryTypes = await Metadata.postTypes('stationary');
63
60
 
64
- ```javascript
65
- import { LocationEmission } from 'emissions-api-sdk';
61
+ // Get areas for any endpoint
62
+ const allAreas = await Metadata.getArea();
63
+ const mobileAreas = await Metadata.getArea('mobile');
64
+ const fugitiveAreas = await Metadata.postArea('fugitive');
66
65
 
67
- // Get supported geographical areas
68
- const areas = await LocationEmission.getArea();
66
+ // Get units for any type
67
+ const allUnits = await Metadata.getUnits(); // All units
68
+ const typeUnits = await Metadata.getUnits('Natural Gas'); // Units for specific type
69
69
  ```
70
70
 
71
- ### Get Valid Units
72
-
73
- ```javascript
74
- import { LocationEmission } from 'emissions-api-sdk';
75
-
76
- // Get valid units for a specific emission type
77
- const units = await LocationEmission.getUnits("electricity");
78
- ```
71
+ **Supported endpoints**: `calculation`, `location`, `stationary`, `mobile`, `fugitive`, `factor`, `search`, `transportation-and-distribution`, `economic-activity`, `real-estate`
79
72
 
80
73
  ### Get Organization Usage
81
74
  ```javascript
82
75
  import { Usage } from 'emissions-api-sdk';
83
76
 
84
- // Retrieves current billing period or historical usage data for the Organization
77
+ // Retrieves current billing period or historical usage data for the Organization
85
78
  // History Flag to retrieve current billing or historical usage data.
86
- const units = await Usage.getUsage(true);
79
+ const usage = await Usage.getUsage(true);
87
80
  ```
88
81
 
89
82
  ## Authentication
@@ -126,4 +119,4 @@ Other resources:
126
119
 
127
120
  ## License
128
121
 
129
- This project is licensed under the terms of the [LICENSE](LICENSE) file.
122
+ This project is licensed under the terms of the [LICENSE](LICENSE) file.
package/dist/Constants.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CLIENT_SOURCE_SDK = exports.CLIENT_SOURCE_EXCEL = exports.CLIENT_SOURCE_HEADER = exports.POST = exports.GET = exports.USAGE_API = exports.TRANSPORTATION_AND_DISTRIBUTION_API_UNITS = exports.FACTOR_API_UNITS = exports.GENERAL_API_UNITS = exports.STATIONARY_API_UNITS = exports.MOBILE_API_UNITS = exports.LOCATION_API_UNITS = exports.FUGITIVE_API_UNITS = exports.FACTOR_API_AREA = exports.SEARCH_API_AREA = exports.TRANSPORTATION_AND_DISTRIBUTION_API_AREA = exports.STATIONARY_API_AREA = exports.MOBILE_API_AREA = exports.LOCATION_API_AREA = exports.GENERAL_API_AREA = exports.FUGITIVE_API_AREA = exports.TRANSPORTATION_AND_DISTRIBUTION_API_TYPES = exports.FACTOR_API_TYPES = exports.STATIONARY_API_TYPES = exports.MOBILE_API_TYPES = exports.FUGITIVE_API_TYPES = exports.LOCATION_TYPES = exports.CALCULATION_TYPES = exports.SEARCH_API_PATH = exports.FACTOR_SET_API_PATH = exports.FACTOR_API_PATH = exports.TRANSPORTATION_AND_DISTRIBUTION_API_PATH = exports.GENERIC_CALCULATION_API_PATH = exports.STATIONARY_API_PATH = exports.FUGITIVE_API_PATH = exports.LOCATION_API_PATH = exports.MOBILE_API_PATH = exports.TOKEN_GENERATION_API = exports.API_DOMAIN = void 0;
3
+ exports.CLIENT_SOURCE_SDK = exports.CLIENT_SOURCE_EXCEL = exports.CLIENT_SOURCE_HEADER = exports.POST = exports.GET = exports.METADATA_UNITS_ENDPOINT = exports.METADATA_AREA_ENDPOINT = exports.METADATA_TYPES_ENDPOINT = exports.USAGE_API = exports.REAL_ESTATE_API_PATH = exports.ECONOMIC_ACTIVITY_API_PATH = exports.SEARCH_API_PATH = exports.FACTOR_SET_API_PATH = exports.FACTOR_API_PATH = exports.TRANSPORTATION_AND_DISTRIBUTION_API_PATH = exports.GENERIC_CALCULATION_API_PATH = exports.STATIONARY_API_PATH = exports.FUGITIVE_API_PATH = exports.LOCATION_API_PATH = exports.MOBILE_API_PATH = exports.TOKEN_GENERATION_API = exports.API_DOMAIN = void 0;
4
4
  exports.API_DOMAIN = "https://api.ibm.com/ghgemissions/run";
5
5
  exports.TOKEN_GENERATION_API = "https://api.ibm.com/saascore/run/authentication-retrieve/api-key";
6
6
  exports.MOBILE_API_PATH = "/v3/carbon/mobile";
@@ -12,29 +12,12 @@ exports.TRANSPORTATION_AND_DISTRIBUTION_API_PATH = "/v3/carbon/transportation-an
12
12
  exports.FACTOR_API_PATH = "/v3/carbon/factor";
13
13
  exports.FACTOR_SET_API_PATH = "/v3/carbon/factorset";
14
14
  exports.SEARCH_API_PATH = "/v3/carbon/factor/search";
15
- exports.CALCULATION_TYPES = "/v3/carbon/calculation/types";
16
- exports.LOCATION_TYPES = "/v3/carbon/location/types";
17
- exports.FUGITIVE_API_TYPES = "/v3/carbon/fugitive/types";
18
- exports.MOBILE_API_TYPES = "/v3/carbon/mobile/types";
19
- exports.STATIONARY_API_TYPES = "/v3/carbon/stationary/types";
20
- exports.FACTOR_API_TYPES = "/v3/carbon/factor/types";
21
- exports.TRANSPORTATION_AND_DISTRIBUTION_API_TYPES = "/v3/carbon/transportation-and-distribution/types";
22
- exports.FUGITIVE_API_AREA = "/v3/carbon/fugitive/area";
23
- exports.GENERAL_API_AREA = "/v3/carbon/calculation/area";
24
- exports.LOCATION_API_AREA = "/v3/carbon/location/area";
25
- exports.MOBILE_API_AREA = "/v3/carbon/mobile/area";
26
- exports.STATIONARY_API_AREA = "/v3/carbon/stationary/area";
27
- exports.TRANSPORTATION_AND_DISTRIBUTION_API_AREA = "/v3/carbon/transportation-and-distribution/area";
28
- exports.SEARCH_API_AREA = "/v3/carbon/factor/search/area";
29
- exports.FACTOR_API_AREA = "/v3/carbon/factor/area";
30
- exports.FUGITIVE_API_UNITS = "/v3/carbon/fugitive/units";
31
- exports.LOCATION_API_UNITS = "/v3/carbon/location/units";
32
- exports.MOBILE_API_UNITS = "/v3/carbon/mobile/units";
33
- exports.STATIONARY_API_UNITS = "/v3/carbon/stationary/units";
34
- exports.GENERAL_API_UNITS = "/v3/carbon/calculation/units";
35
- exports.FACTOR_API_UNITS = "/v3/carbon/factor/units";
36
- exports.TRANSPORTATION_AND_DISTRIBUTION_API_UNITS = "/v3/carbon/transportation-and-distribution/units";
15
+ exports.ECONOMIC_ACTIVITY_API_PATH = "/v3/carbon/economic-activity";
16
+ exports.REAL_ESTATE_API_PATH = "/v3/carbon/real-estate";
37
17
  exports.USAGE_API = "/v3/carbon/usage";
18
+ exports.METADATA_TYPES_ENDPOINT = "/v3/carbon/metadata/types";
19
+ exports.METADATA_AREA_ENDPOINT = "/v3/carbon/metadata/area";
20
+ exports.METADATA_UNITS_ENDPOINT = "/v3/carbon/metadata/units";
38
21
  exports.GET = "GET";
39
22
  exports.POST = "POST";
40
23
  exports.CLIENT_SOURCE_HEADER = "X-Client-Source";
@@ -1,9 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.calculate = calculate;
4
- exports.getTypes = getTypes;
5
- exports.getArea = getArea;
6
- exports.getUnits = getUnits;
7
4
  const Client_1 = require("../Client");
8
5
  const Constants_1 = require("../Constants");
9
6
  const request_1 = require("../request");
@@ -42,63 +39,3 @@ async function calculate(payload) {
42
39
  data: payload,
43
40
  });
44
41
  }
45
- /**
46
- * Retrieves available calculation types by making a GET request to the calculation types API endpoint.
47
- *
48
- * @export
49
- * @return {Promise<TypeResponse>} A promise that resolves to a TypeResponse containing the available calculation types
50
- * @throws {Error} May throw an error if the API request fails
51
- *
52
- * @example
53
- * const types = await getTypes();
54
- */
55
- async function getTypes() {
56
- const client = Client_1.Client.getInstance();
57
- const url = client.getDomain() + Constants_1.CALCULATION_TYPES;
58
- return (0, request_1.makeApiRequest)({
59
- method: Constants_1.GET,
60
- url
61
- });
62
- }
63
- /**
64
- * Retrieves information about geographical areas supported by the calculation API.
65
- *
66
- * @export
67
- * @return {Promise<AreaResponse>} A promise that resolves to an AreaResponse containing the supported geographical areas
68
- * @throws {Error} May throw an error if the API request fails
69
- *
70
- * @example
71
- * const areas = await getArea();
72
- */
73
- async function getArea() {
74
- const client = Client_1.Client.getInstance();
75
- const url = client.getDomain() + Constants_1.GENERAL_API_AREA;
76
- return (0, request_1.makeApiRequest)({
77
- method: Constants_1.GET,
78
- url
79
- });
80
- }
81
- /**
82
- * Retrieves available units for a specific calculation type.
83
- *
84
- * @export
85
- * @param {string} type - The calculation type to get units for
86
- * @return {Promise<UnitResponse>} A promise that resolves to a UnitResponse containing the available units
87
- * @throws {Error} May throw an error if the API request fails
88
- *
89
- * @example
90
- * // Get units for the "Natural Gas - Scope 3:AAA" emission calculation type with subtype
91
- * const units = await getUnits("Natural Gas - Scope 3:AAA");
92
-
93
- * // Get units for the "HFC-263fb" emission calculation type without subtype
94
- * const units = await getUnits("HFC-263fb");
95
- */
96
- async function getUnits(type) {
97
- const client = Client_1.Client.getInstance();
98
- const url = client.getDomain() + Constants_1.GENERAL_API_UNITS;
99
- return (0, request_1.makeApiRequest)({
100
- method: Constants_1.GET,
101
- url,
102
- params: { type }
103
- });
104
- }
@@ -0,0 +1,40 @@
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 3 Spend based emission calculations by making a POST request to the economic activity API endpoint.
9
+ *
10
+ * @export
11
+ * @param {CommonRequest} payload - The request data to be sent to the API
12
+ * @return {Promise<EmissionResponse | EmissionResponseWithDetails>} A promise that resolves to the emission calculation result. Returns EmissionResponseWithDetails if includeDetails is true, otherwise EmissionResponse
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": "accomodation",
25
+ "value": 1500.12,
26
+ "unit": "usd"
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.ECONOMIC_ACTIVITY_API_PATH;
35
+ return (0, request_1.makeApiRequest)({
36
+ method: Constants_1.POST,
37
+ url,
38
+ data: payload,
39
+ });
40
+ }
@@ -2,10 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.retrieveFactor = retrieveFactor;
4
4
  exports.search = search;
5
- exports.getTypes = getTypes;
6
- exports.getSearchArea = getSearchArea;
7
- exports.getArea = getArea;
8
- exports.getUnits = getUnits;
9
5
  const Client_1 = require("../Client");
10
6
  const Constants_1 = require("../Constants");
11
7
  const request_1 = require("../request");
@@ -80,81 +76,3 @@ async function search(payload) {
80
76
  data: payload,
81
77
  });
82
78
  }
83
- /**
84
- * Retrieves available emission factor types by making a GET request to the API endpoint.
85
- *
86
- * @export
87
- * @return {Promise<TypeResponse>} A promise that resolves to a TypeResponse containing the available emission factor types
88
- * @throws {Error} May throw an error if the API request fails
89
- *
90
- * @example
91
- * const types = await getTypes();
92
- */
93
- async function getTypes() {
94
- const client = Client_1.Client.getInstance();
95
- const url = client.getDomain() + Constants_1.FACTOR_API_TYPES;
96
- return (0, request_1.makeApiRequest)({
97
- method: Constants_1.GET,
98
- url
99
- });
100
- }
101
- /**
102
- * Retrieves information about geographical areas supported by the factor search API.
103
- *
104
- * @export
105
- * @return {Promise<AreaResponse>} A promise that resolves to an AreaResponse containing the supported geographical areas
106
- * @throws {Error} May throw an error if the API request fails
107
- *
108
- * @example
109
- * const areas = await getSearchArea();
110
- */
111
- async function getSearchArea() {
112
- const client = Client_1.Client.getInstance();
113
- const url = client.getDomain() + Constants_1.SEARCH_API_AREA;
114
- return (0, request_1.makeApiRequest)({
115
- method: Constants_1.GET,
116
- url
117
- });
118
- }
119
- /**
120
- * Retrieves information about geographical areas supported by the factor API.
121
- *
122
- * @export
123
- * @return {Promise<AreaResponse>} A promise that resolves to an AreaResponse containing the supported geographical areas
124
- * @throws {Error} May throw an error if the API request fails
125
- *
126
- * @example
127
- * const areas = await getArea();
128
- */
129
- async function getArea() {
130
- const client = Client_1.Client.getInstance();
131
- const url = client.getDomain() + Constants_1.FACTOR_API_AREA;
132
- return (0, request_1.makeApiRequest)({
133
- method: Constants_1.GET,
134
- url
135
- });
136
- }
137
- /**
138
- * Retrieves available units for a specific emission factor type.
139
- *
140
- * @export
141
- * @param {string} type - The emission factor type to get units for (e.g., "Natural Gas - Scope 3:AAA")
142
- * @return {Promise<UnitResponse>} A promise that resolves to a UnitResponse containing the available units
143
- * @throws {Error} May throw an error if the API request fails
144
- *
145
- * @example
146
- * // Get units for the "Natural Gas - Scope 3:AAA" emission factor type with subtype
147
- * const units = await getUnits("Natural Gas - Scope 3:AAA");
148
-
149
- * // Get units for the "HFC-263fb" emission factor type without subtype
150
- * const units = await getUnits("HFC-263fb");
151
- */
152
- async function getUnits(type) {
153
- const client = Client_1.Client.getInstance();
154
- const url = client.getDomain() + Constants_1.FACTOR_API_UNITS;
155
- return (0, request_1.makeApiRequest)({
156
- method: Constants_1.GET,
157
- url,
158
- params: { type }
159
- });
160
- }
@@ -1,9 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.calculate = calculate;
4
- exports.getTypes = getTypes;
5
- exports.getArea = getArea;
6
- exports.getUnits = getUnits;
7
4
  const Client_1 = require("../Client");
8
5
  const Constants_1 = require("../Constants");
9
6
  const request_1 = require("../request");
@@ -41,63 +38,3 @@ async function calculate(payload) {
41
38
  data: payload,
42
39
  });
43
40
  }
44
- /**
45
- * Retrieves available fugitive emission calculation types by making a GET request to the API endpoint.
46
- *
47
- * @export
48
- * @return {Promise<TypeResponse>} A promise that resolves to a TypeResponse containing the available fugitive emission types
49
- * @throws {Error} May throw an error if the API request fails
50
- *
51
- * @example
52
- * const types = await getTypes();
53
- */
54
- async function getTypes() {
55
- const client = Client_1.Client.getInstance();
56
- const url = client.getDomain() + Constants_1.FUGITIVE_API_TYPES;
57
- return (0, request_1.makeApiRequest)({
58
- method: Constants_1.GET,
59
- url
60
- });
61
- }
62
- /**
63
- * Retrieves information about geographical areas supported by the fugitive emissions API.
64
- *
65
- * @export
66
- * @return {Promise<AreaResponse>} A promise that resolves to an AreaResponse containing the supported geographical areas
67
- * @throws {Error} May throw an error if the API request fails
68
- *
69
- * @example
70
- * const areas = await getArea();
71
- */
72
- async function getArea() {
73
- const client = Client_1.Client.getInstance();
74
- const url = client.getDomain() + Constants_1.FUGITIVE_API_AREA;
75
- return (0, request_1.makeApiRequest)({
76
- method: Constants_1.GET,
77
- url
78
- });
79
- }
80
- /**
81
- * Retrieves available units for a specific fugitive emission type.
82
- *
83
- * @export
84
- * @param {string} type - The fugitive emission type to get units for (e.g., "R134A")
85
- * @return {Promise<UnitResponse>} A promise that resolves to a UnitResponse containing the available units
86
- * @throws {Error} May throw an error if the API request fails
87
- *
88
- * @example
89
- * // Get units for the "Natural Gas - Scope 3:AAA" emission fugitive type with subtype
90
- * const units = await getUnits("Natural Gas - Scope 3:AAA");
91
-
92
- * // Get units for the "R-426A" emission fugitive type without subtype
93
- * const units = await getUnits("R-426A");
94
- */
95
- async function getUnits(type) {
96
- const client = Client_1.Client.getInstance();
97
- const url = client.getDomain() + Constants_1.FUGITIVE_API_UNITS;
98
- return (0, request_1.makeApiRequest)({
99
- method: Constants_1.GET,
100
- url,
101
- params: { type }
102
- });
103
- }
@@ -1,9 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.calculate = calculate;
4
- exports.getTypes = getTypes;
5
- exports.getArea = getArea;
6
- exports.getUnits = getUnits;
7
4
  const Client_1 = require("../Client");
8
5
  const Constants_1 = require("../Constants");
9
6
  const request_1 = require("../request");
@@ -42,61 +39,3 @@ async function calculate(payload) {
42
39
  data: payload,
43
40
  });
44
41
  }
45
- /**
46
- * Retrieves available location-based calculation types by making a GET request to the location types API endpoint.
47
- *
48
- * @export
49
- * @return {Promise<TypeResponse>} A promise that resolves to a TypeResponse containing the available location-based calculation types
50
- * @throws {Error} May throw an error if the API request fails
51
- *
52
- * @example
53
- *
54
- * const types = await getTypes();
55
- */
56
- async function getTypes() {
57
- const client = Client_1.Client.getInstance();
58
- const url = client.getDomain() + Constants_1.LOCATION_TYPES;
59
- return (0, request_1.makeApiRequest)({
60
- method: Constants_1.GET,
61
- url
62
- });
63
- }
64
- /**
65
- * Retrieves information about geographical areas supported by the location-based calculation API.
66
- *
67
- * @export
68
- * @return {Promise<AreaResponse>} A promise that resolves to an AreaResponse containing the supported geographical areas
69
- * @throws {Error} May throw an error if the API request fails
70
- *
71
- * @example
72
- * const areas = await getArea();
73
- */
74
- async function getArea() {
75
- const client = Client_1.Client.getInstance();
76
- const url = client.getDomain() + Constants_1.LOCATION_API_AREA;
77
- return (0, request_1.makeApiRequest)({
78
- method: Constants_1.GET,
79
- url
80
- });
81
- }
82
- /**
83
- * Retrieves available units for a specific location-based calculation type.
84
- *
85
- * @export
86
- * @param {string} type - The location-based calculation type to get units for (e.g., "electricity")
87
- * @return {Promise<UnitResponse>} A promise that resolves to a UnitResponse containing the available units
88
- * @throws {Error} May throw an error if the API request fails
89
- *
90
- * @example
91
- * // Get units for the "electricity" location type
92
- * const units = await getUnits("electricity");
93
- */
94
- async function getUnits(type) {
95
- const client = Client_1.Client.getInstance();
96
- const url = client.getDomain() + Constants_1.LOCATION_API_UNITS;
97
- return (0, request_1.makeApiRequest)({
98
- method: Constants_1.GET,
99
- url,
100
- params: { type }
101
- });
102
- }
@@ -0,0 +1,155 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getTypes = getTypes;
4
+ exports.postTypes = postTypes;
5
+ exports.getArea = getArea;
6
+ exports.postArea = postArea;
7
+ exports.getUnits = getUnits;
8
+ exports.postUnits = postUnits;
9
+ const Client_1 = require("../Client");
10
+ const Constants_1 = require("../Constants");
11
+ const request_1 = require("../request");
12
+ /**
13
+ * Retrieves available emission source types for a specific endpoint using GET request.
14
+ *
15
+ * @export
16
+ * @param {string} [endpoint] - The endpoint name to retrieve types for. Defaults to 'calculation' if not provided.
17
+ * @return {Promise<TypeResponse>} A promise that resolves to a TypeResponse containing the available types
18
+ * @throws {Error} May throw an error if the API request fails
19
+ *
20
+ * @example
21
+ * // Get types for calculation endpoint (default)
22
+ * const types = await getTypes();
23
+ *
24
+ * // Get types for a specific endpoint
25
+ * const locationTypes = await getTypes('location');
26
+ */
27
+ async function getTypes(endpoint) {
28
+ const client = Client_1.Client.getInstance();
29
+ const url = client.getDomain() + Constants_1.METADATA_TYPES_ENDPOINT;
30
+ return (0, request_1.makeApiRequest)({
31
+ method: Constants_1.GET,
32
+ url,
33
+ params: endpoint ? { endpoint } : undefined,
34
+ });
35
+ }
36
+ /**
37
+ * Retrieves available emission source types for a specific endpoint using POST request.
38
+ *
39
+ * @export
40
+ * @param {string} [endpoint] - The endpoint name to retrieve types for. Defaults to 'calculation' if not provided.
41
+ * @return {Promise<TypeResponse>} A promise that resolves to a TypeResponse containing the available types
42
+ * @throws {Error} May throw an error if the API request fails
43
+ *
44
+ * @example
45
+ * // Get types for calculation endpoint (default)
46
+ * const types = await postTypes();
47
+ *
48
+ * // Get types for a specific endpoint
49
+ * const stationaryTypes = await postTypes('stationary');
50
+ */
51
+ async function postTypes(endpoint) {
52
+ const client = Client_1.Client.getInstance();
53
+ const url = client.getDomain() + Constants_1.METADATA_TYPES_ENDPOINT;
54
+ return (0, request_1.makeApiRequest)({
55
+ method: Constants_1.POST,
56
+ url,
57
+ data: endpoint ? { endpoint } : {},
58
+ });
59
+ }
60
+ /**
61
+ * Retrieves available geographic locations for a specific endpoint using GET request.
62
+ *
63
+ * @export
64
+ * @param {string} [endpoint] - The endpoint name to retrieve locations for. Defaults to 'calculation' if not provided.
65
+ * @return {Promise<AreaResponse>} A promise that resolves to an AreaResponse containing the available locations
66
+ * @throws {Error} May throw an error if the API request fails
67
+ *
68
+ * @example
69
+ * // Get areas for calculation endpoint (default)
70
+ * const areas = await getArea();
71
+ *
72
+ * // Get areas for a specific endpoint
73
+ * const mobileAreas = await getArea('mobile');
74
+ */
75
+ async function getArea(endpoint) {
76
+ const client = Client_1.Client.getInstance();
77
+ const url = client.getDomain() + Constants_1.METADATA_AREA_ENDPOINT;
78
+ return (0, request_1.makeApiRequest)({
79
+ method: Constants_1.GET,
80
+ url,
81
+ params: endpoint ? { endpoint } : undefined,
82
+ });
83
+ }
84
+ /**
85
+ * Retrieves available geographic locations for a specific endpoint using POST request.
86
+ *
87
+ * @export
88
+ * @param {string} [endpoint] - The endpoint name to retrieve locations for. Defaults to 'calculation' if not provided.
89
+ * @return {Promise<AreaResponse>} A promise that resolves to an AreaResponse containing the available locations
90
+ * @throws {Error} May throw an error if the API request fails
91
+ *
92
+ * @example
93
+ * // Get areas for calculation endpoint (default)
94
+ * const areas = await postArea();
95
+ *
96
+ * // Get areas for a specific endpoint
97
+ * const fugitiveAreas = await postArea('fugitive');
98
+ */
99
+ async function postArea(endpoint) {
100
+ const client = Client_1.Client.getInstance();
101
+ const url = client.getDomain() + Constants_1.METADATA_AREA_ENDPOINT;
102
+ return (0, request_1.makeApiRequest)({
103
+ method: Constants_1.POST,
104
+ url,
105
+ data: endpoint ? { endpoint } : {},
106
+ });
107
+ }
108
+ /**
109
+ * Retrieves available measurement units for a specific type using GET request.
110
+ *
111
+ * @export
112
+ * @param {string} [type] - The emission source type to retrieve units for. If not provided, returns the full UOM table.
113
+ * @return {Promise<UnitResponse>} A promise that resolves to a UnitResponse containing the available units
114
+ * @throws {Error} May throw an error if the API request fails
115
+ *
116
+ * @example
117
+ * // Get all units
118
+ * const allUnits = await getUnits();
119
+ *
120
+ * // Get units for a specific type
121
+ * const naturalGasUnits = await getUnits('Natural Gas');
122
+ */
123
+ async function getUnits(type) {
124
+ const client = Client_1.Client.getInstance();
125
+ const url = client.getDomain() + Constants_1.METADATA_UNITS_ENDPOINT;
126
+ return (0, request_1.makeApiRequest)({
127
+ method: Constants_1.GET,
128
+ url,
129
+ params: type ? { type } : undefined,
130
+ });
131
+ }
132
+ /**
133
+ * Retrieves available measurement units for a specific type using POST request.
134
+ *
135
+ * @export
136
+ * @param {string} [type] - The emission source type to retrieve units for. If not provided, returns the full UOM table.
137
+ * @return {Promise<UnitResponse>} A promise that resolves to a UnitResponse containing the available units
138
+ * @throws {Error} May throw an error if the API request fails
139
+ *
140
+ * @example
141
+ * // Get all units
142
+ * const allUnits = await postUnits();
143
+ *
144
+ * // Get units for a specific type
145
+ * const jetKeroseneUnits = await postUnits('Jet Kerosene');
146
+ */
147
+ async function postUnits(type) {
148
+ const client = Client_1.Client.getInstance();
149
+ const url = client.getDomain() + Constants_1.METADATA_UNITS_ENDPOINT;
150
+ return (0, request_1.makeApiRequest)({
151
+ method: Constants_1.POST,
152
+ url,
153
+ data: type ? { type } : {},
154
+ });
155
+ }