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.
- package/README.md +33 -2
- package/dist/Constants.js +23 -1
- package/dist/api/Calculation.js +77 -14
- package/dist/api/Factor.js +97 -16
- package/dist/api/Fugitive.js +75 -12
- package/dist/api/Location.js +75 -14
- package/dist/api/Mobile.js +66 -0
- package/dist/api/Stationary.js +77 -14
- package/dist/api/TransportationAndDistribution.js +75 -12
- package/dist/types/Constants.d.ts +22 -0
- package/dist/types/api/Calculation.d.ts +52 -14
- package/dist/types/api/Factor.d.ts +64 -16
- package/dist/types/api/Fugitive.d.ts +50 -12
- package/dist/types/api/Location.d.ts +50 -14
- package/dist/types/api/Mobile.d.ts +41 -0
- package/dist/types/api/Stationary.d.ts +52 -14
- package/dist/types/api/TransportationAndDistribution.d.ts +50 -12
- package/docs/.nojekyll +0 -0
- package/docs/_sources/authentication.rst.txt +164 -0
- package/docs/_sources/client.rst.txt +137 -0
- package/docs/_sources/getting_started.rst.txt +164 -0
- package/docs/_sources/index.rst.txt +29 -0
- package/docs/_sources/reference.rst.txt +129 -0
- package/docs/_sources/sdk.rst.txt +13 -0
- package/docs/_static/basic.css +906 -0
- package/docs/_static/custom.css +16 -0
- package/docs/_static/debug.css +69 -0
- package/docs/_static/doctools.js +149 -0
- package/docs/_static/documentation_options.js +13 -0
- package/docs/_static/file.png +0 -0
- package/docs/_static/language_data.js +192 -0
- package/docs/_static/minus.png +0 -0
- package/docs/_static/plus.png +0 -0
- package/docs/_static/pygments.css +250 -0
- package/docs/_static/scripts/furo-extensions.js +0 -0
- package/docs/_static/scripts/furo.js +3 -0
- package/docs/_static/scripts/furo.js.LICENSE.txt +7 -0
- package/docs/_static/scripts/furo.js.map +1 -0
- package/docs/_static/searchtools.js +635 -0
- package/docs/_static/skeleton.css +296 -0
- package/docs/_static/sphinx_highlight.js +154 -0
- package/docs/_static/sphinx_js.css +0 -0
- package/docs/_static/styles/furo-extensions.css +2 -0
- package/docs/_static/styles/furo-extensions.css.map +1 -0
- package/docs/_static/styles/furo.css +2 -0
- package/docs/_static/styles/furo.css.map +1 -0
- package/docs/authentication.html +513 -0
- package/docs/client.html +467 -0
- package/docs/genindex.html +482 -0
- package/docs/getting_started.html +481 -0
- package/docs/index.html +334 -0
- package/docs/objects.inv +0 -0
- package/docs/reference.html +1568 -0
- package/docs/sdk.html +324 -0
- package/docs/search.html +287 -0
- package/docs/searchindex.js +1 -0
- package/package.json +1 -1
- package/sphinx-build/Makefile +49 -0
- package/sphinx-build/source/_static/custom.css +16 -0
- package/sphinx-build/source/authentication.rst +164 -0
- package/sphinx-build/source/client.rst +137 -0
- package/sphinx-build/source/conf.py +56 -0
- package/sphinx-build/source/getting_started.rst +164 -0
- package/sphinx-build/source/index.rst +29 -0
- package/sphinx-build/source/reference.rst +129 -0
- package/sphinx-build/source/sdk.rst +13 -0
- package/src/Constants.ts +26 -0
- package/src/api/Calculation.ts +84 -15
- package/src/api/Factor.ts +108 -19
- package/src/api/Fugitive.ts +83 -13
- package/src/api/Location.ts +84 -15
- package/src/api/Mobile.ts +75 -1
- package/src/api/Stationary.ts +85 -15
- package/src/api/TransportationAndDistribution.ts +84 -13
- package/test/apiTest.test.ts +172 -5
- package/dist/api/Factors.js +0 -98
- package/dist/api/FugitiveEmission.js +0 -40
- package/dist/api/GenericCalculation.js +0 -41
- package/dist/api/LocationEmission.js +0 -41
- package/dist/api/MobileEmission.js +0 -41
- package/dist/api/StationaryEmission.js +0 -41
- package/dist/api/TransportationDistributionEmission.js +0 -40
- package/dist/coverage/clover.xml +0 -225
- package/dist/coverage/coverage-final.json +0 -19
- package/dist/coverage/lcov-report/base.css +0 -224
- package/dist/coverage/lcov-report/block-navigation.js +0 -87
- package/dist/coverage/lcov-report/favicon.png +0 -0
- package/dist/coverage/lcov-report/index.html +0 -161
- package/dist/coverage/lcov-report/prettify.css +0 -1
- package/dist/coverage/lcov-report/prettify.js +0 -2
- package/dist/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/dist/coverage/lcov-report/sorter.js +0 -210
- package/dist/coverage/lcov-report/src/Client.ts.html +0 -838
- package/dist/coverage/lcov-report/src/Constants.ts.html +0 -130
- package/dist/coverage/lcov-report/src/api/Calculation.ts.html +0 -217
- package/dist/coverage/lcov-report/src/api/Factor.ts.html +0 -343
- package/dist/coverage/lcov-report/src/api/FactorSets.ts.html +0 -154
- package/dist/coverage/lcov-report/src/api/Factors.ts.html +0 -403
- package/dist/coverage/lcov-report/src/api/Fugitive.ts.html +0 -214
- package/dist/coverage/lcov-report/src/api/FugitiveEmission.ts.html +0 -214
- package/dist/coverage/lcov-report/src/api/GenericCalculation.ts.html +0 -217
- package/dist/coverage/lcov-report/src/api/Location.ts.html +0 -214
- package/dist/coverage/lcov-report/src/api/LocationEmission.ts.html +0 -214
- package/dist/coverage/lcov-report/src/api/Mobile.ts.html +0 -220
- package/dist/coverage/lcov-report/src/api/MobileEmission.ts.html +0 -220
- package/dist/coverage/lcov-report/src/api/Stationary.ts.html +0 -220
- package/dist/coverage/lcov-report/src/api/StationaryEmission.ts.html +0 -220
- package/dist/coverage/lcov-report/src/api/TransportationAndDistribution.ts.html +0 -211
- package/dist/coverage/lcov-report/src/api/TransportationDistributionEmission.ts.html +0 -211
- package/dist/coverage/lcov-report/src/api/index.html +0 -221
- package/dist/coverage/lcov-report/src/index.html +0 -161
- package/dist/coverage/lcov-report/src/request.ts.html +0 -235
- package/dist/coverage/lcov-report/src/utils.ts.html +0 -139
- package/dist/coverage/lcov-report/test/index.html +0 -116
- package/dist/coverage/lcov-report/test/mocks/CommonRequest.ts.html +0 -142
- package/dist/coverage/lcov-report/test/mocks/FactorRequest.ts.html +0 -133
- package/dist/coverage/lcov-report/test/mocks/GenericCalculationRequest.ts.html +0 -142
- package/dist/coverage/lcov-report/test/mocks/LocationRequest.ts.html +0 -139
- package/dist/coverage/lcov-report/test/mocks/SearchRequest.ts.html +0 -142
- package/dist/coverage/lcov-report/test/mocks/index.html +0 -176
- package/dist/coverage/lcov-report/test/testUtils.ts.html +0 -97
- package/dist/coverage/lcov.info +0 -404
- package/dist/types/api/Factors.d.ts +0 -68
- package/dist/types/api/FugitiveEmission.d.ts +0 -27
- package/dist/types/api/GenericCalculation.d.ts +0 -28
- package/dist/types/api/LocationEmission.d.ts +0 -28
- package/dist/types/api/MobileEmission.d.ts +0 -28
- package/dist/types/api/StationaryEmission.d.ts +0 -28
- package/dist/types/api/TransportationDistributionEmission.d.ts +0 -27
package/docs/client.html
ADDED
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html class="no-js" lang="en" data-content_root="./">
|
|
3
|
+
<head><meta charset="utf-8">
|
|
4
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
5
|
+
<meta name="color-scheme" content="light dark"><meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<link rel="index" title="Index" href="genindex.html"><link rel="search" title="Search" href="search.html"><link rel="next" title="Authentication" href="authentication.html"><link rel="prev" title="SDK" href="sdk.html">
|
|
7
|
+
|
|
8
|
+
<!-- Generated with Sphinx 8.2.3 and Furo 2025.09.25 -->
|
|
9
|
+
<title>Client - IBM Envizi - Emissions API Node.js SDK documentation</title>
|
|
10
|
+
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=d111a655" />
|
|
11
|
+
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?v=580074bf" />
|
|
12
|
+
<link rel="stylesheet" type="text/css" href="_static/sphinx_js.css" />
|
|
13
|
+
<link rel="stylesheet" type="text/css" href="_static/styles/furo-extensions.css?v=8dab3a3b" />
|
|
14
|
+
<link rel="stylesheet" type="text/css" href="_static/custom.css?v=8d04aa46" />
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
<style>
|
|
20
|
+
body {
|
|
21
|
+
--color-code-background: #f2f2f2;
|
|
22
|
+
--color-code-foreground: #1e1e1e;
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
@media not print {
|
|
26
|
+
body[data-theme="dark"] {
|
|
27
|
+
--color-code-background: #202020;
|
|
28
|
+
--color-code-foreground: #d0d0d0;
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
@media (prefers-color-scheme: dark) {
|
|
32
|
+
body:not([data-theme="light"]) {
|
|
33
|
+
--color-code-background: #202020;
|
|
34
|
+
--color-code-foreground: #d0d0d0;
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
</style></head>
|
|
40
|
+
<body>
|
|
41
|
+
|
|
42
|
+
<script>
|
|
43
|
+
document.body.dataset.theme = localStorage.getItem("theme") || "auto";
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
|
|
48
|
+
<symbol id="svg-toc" viewBox="0 0 24 24">
|
|
49
|
+
<title>Contents</title>
|
|
50
|
+
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 1024 1024">
|
|
51
|
+
<path d="M408 442h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8zm-8 204c0 4.4 3.6 8 8 8h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56zm504-486H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 632H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM115.4 518.9L271.7 642c5.8 4.6 14.4.5 14.4-6.9V388.9c0-7.4-8.5-11.5-14.4-6.9L115.4 505.1a8.74 8.74 0 0 0 0 13.8z"/>
|
|
52
|
+
</svg>
|
|
53
|
+
</symbol>
|
|
54
|
+
<symbol id="svg-menu" viewBox="0 0 24 24">
|
|
55
|
+
<title>Menu</title>
|
|
56
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
|
57
|
+
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather-menu">
|
|
58
|
+
<line x1="3" y1="12" x2="21" y2="12"></line>
|
|
59
|
+
<line x1="3" y1="6" x2="21" y2="6"></line>
|
|
60
|
+
<line x1="3" y1="18" x2="21" y2="18"></line>
|
|
61
|
+
</svg>
|
|
62
|
+
</symbol>
|
|
63
|
+
<symbol id="svg-arrow-right" viewBox="0 0 24 24">
|
|
64
|
+
<title>Expand</title>
|
|
65
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
|
66
|
+
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather-chevron-right">
|
|
67
|
+
<polyline points="9 18 15 12 9 6"></polyline>
|
|
68
|
+
</svg>
|
|
69
|
+
</symbol>
|
|
70
|
+
<symbol id="svg-sun" viewBox="0 0 24 24">
|
|
71
|
+
<title>Light mode</title>
|
|
72
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
|
73
|
+
stroke-width="1" stroke-linecap="round" stroke-linejoin="round" class="feather-sun">
|
|
74
|
+
<circle cx="12" cy="12" r="5"></circle>
|
|
75
|
+
<line x1="12" y1="1" x2="12" y2="3"></line>
|
|
76
|
+
<line x1="12" y1="21" x2="12" y2="23"></line>
|
|
77
|
+
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
|
|
78
|
+
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
|
|
79
|
+
<line x1="1" y1="12" x2="3" y2="12"></line>
|
|
80
|
+
<line x1="21" y1="12" x2="23" y2="12"></line>
|
|
81
|
+
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
|
|
82
|
+
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
|
|
83
|
+
</svg>
|
|
84
|
+
</symbol>
|
|
85
|
+
<symbol id="svg-moon" viewBox="0 0 24 24">
|
|
86
|
+
<title>Dark mode</title>
|
|
87
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
|
88
|
+
stroke-width="1" stroke-linecap="round" stroke-linejoin="round" class="icon-tabler-moon">
|
|
89
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
90
|
+
<path d="M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454z" />
|
|
91
|
+
</svg>
|
|
92
|
+
</symbol>
|
|
93
|
+
<symbol id="svg-sun-with-moon" viewBox="0 0 24 24">
|
|
94
|
+
<title>Auto light/dark, in light mode</title>
|
|
95
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
|
96
|
+
stroke-width="1" stroke-linecap="round" stroke-linejoin="round"
|
|
97
|
+
class="icon-custom-derived-from-feather-sun-and-tabler-moon">
|
|
98
|
+
<path style="opacity: 50%" d="M 5.411 14.504 C 5.471 14.504 5.532 14.504 5.591 14.504 C 3.639 16.319 4.383 19.569 6.931 20.352 C 7.693 20.586 8.512 20.551 9.25 20.252 C 8.023 23.207 4.056 23.725 2.11 21.184 C 0.166 18.642 1.702 14.949 4.874 14.536 C 5.051 14.512 5.231 14.5 5.411 14.5 L 5.411 14.504 Z"/>
|
|
99
|
+
<line x1="14.5" y1="3.25" x2="14.5" y2="1.25"/>
|
|
100
|
+
<line x1="14.5" y1="15.85" x2="14.5" y2="17.85"/>
|
|
101
|
+
<line x1="10.044" y1="5.094" x2="8.63" y2="3.68"/>
|
|
102
|
+
<line x1="19" y1="14.05" x2="20.414" y2="15.464"/>
|
|
103
|
+
<line x1="8.2" y1="9.55" x2="6.2" y2="9.55"/>
|
|
104
|
+
<line x1="20.8" y1="9.55" x2="22.8" y2="9.55"/>
|
|
105
|
+
<line x1="10.044" y1="14.006" x2="8.63" y2="15.42"/>
|
|
106
|
+
<line x1="19" y1="5.05" x2="20.414" y2="3.636"/>
|
|
107
|
+
<circle cx="14.5" cy="9.55" r="3.6"/>
|
|
108
|
+
</svg>
|
|
109
|
+
</symbol>
|
|
110
|
+
<symbol id="svg-moon-with-sun" viewBox="0 0 24 24">
|
|
111
|
+
<title>Auto light/dark, in dark mode</title>
|
|
112
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
|
113
|
+
stroke-width="1" stroke-linecap="round" stroke-linejoin="round"
|
|
114
|
+
class="icon-custom-derived-from-feather-sun-and-tabler-moon">
|
|
115
|
+
<path d="M 8.282 7.007 C 8.385 7.007 8.494 7.007 8.595 7.007 C 5.18 10.184 6.481 15.869 10.942 17.24 C 12.275 17.648 13.706 17.589 15 17.066 C 12.851 22.236 5.91 23.143 2.505 18.696 C -0.897 14.249 1.791 7.786 7.342 7.063 C 7.652 7.021 7.965 7 8.282 7 L 8.282 7.007 Z"/>
|
|
116
|
+
<line style="opacity: 50%" x1="18" y1="3.705" x2="18" y2="2.5"/>
|
|
117
|
+
<line style="opacity: 50%" x1="18" y1="11.295" x2="18" y2="12.5"/>
|
|
118
|
+
<line style="opacity: 50%" x1="15.316" y1="4.816" x2="14.464" y2="3.964"/>
|
|
119
|
+
<line style="opacity: 50%" x1="20.711" y1="10.212" x2="21.563" y2="11.063"/>
|
|
120
|
+
<line style="opacity: 50%" x1="14.205" y1="7.5" x2="13.001" y2="7.5"/>
|
|
121
|
+
<line style="opacity: 50%" x1="21.795" y1="7.5" x2="23" y2="7.5"/>
|
|
122
|
+
<line style="opacity: 50%" x1="15.316" y1="10.184" x2="14.464" y2="11.036"/>
|
|
123
|
+
<line style="opacity: 50%" x1="20.711" y1="4.789" x2="21.563" y2="3.937"/>
|
|
124
|
+
<circle style="opacity: 50%" cx="18" cy="7.5" r="2.169"/>
|
|
125
|
+
</svg>
|
|
126
|
+
</symbol>
|
|
127
|
+
<symbol id="svg-pencil" viewBox="0 0 24 24">
|
|
128
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
|
129
|
+
stroke-width="1" stroke-linecap="round" stroke-linejoin="round" class="icon-tabler-pencil-code">
|
|
130
|
+
<path d="M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4" />
|
|
131
|
+
<path d="M13.5 6.5l4 4" />
|
|
132
|
+
<path d="M20 21l2 -2l-2 -2" />
|
|
133
|
+
<path d="M17 17l-2 2l2 2" />
|
|
134
|
+
</svg>
|
|
135
|
+
</symbol>
|
|
136
|
+
<symbol id="svg-eye" viewBox="0 0 24 24">
|
|
137
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
|
138
|
+
stroke-width="1" stroke-linecap="round" stroke-linejoin="round" class="icon-tabler-eye-code">
|
|
139
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
140
|
+
<path d="M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0" />
|
|
141
|
+
<path
|
|
142
|
+
d="M11.11 17.958c-3.209 -.307 -5.91 -2.293 -8.11 -5.958c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6c-.21 .352 -.427 .688 -.647 1.008" />
|
|
143
|
+
<path d="M20 21l2 -2l-2 -2" />
|
|
144
|
+
<path d="M17 17l-2 2l2 2" />
|
|
145
|
+
</svg>
|
|
146
|
+
</symbol>
|
|
147
|
+
</svg>
|
|
148
|
+
|
|
149
|
+
<input type="checkbox" class="sidebar-toggle" name="__navigation" id="__navigation" aria-label="Toggle site navigation sidebar">
|
|
150
|
+
<input type="checkbox" class="sidebar-toggle" name="__toc" id="__toc" aria-label="Toggle table of contents sidebar">
|
|
151
|
+
<label class="overlay sidebar-overlay" for="__navigation"></label>
|
|
152
|
+
<label class="overlay toc-overlay" for="__toc"></label>
|
|
153
|
+
|
|
154
|
+
<a class="skip-to-content muted-link" href="#furo-main-content">Skip to content</a>
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
<div class="page">
|
|
159
|
+
<header class="mobile-header">
|
|
160
|
+
<div class="header-left">
|
|
161
|
+
<label class="nav-overlay-icon" for="__navigation">
|
|
162
|
+
<span class="icon"><svg><use href="#svg-menu"></use></svg></span>
|
|
163
|
+
</label>
|
|
164
|
+
</div>
|
|
165
|
+
<div class="header-center">
|
|
166
|
+
<a href="index.html"><div class="brand">IBM Envizi - Emissions API Node.js SDK documentation</div></a>
|
|
167
|
+
</div>
|
|
168
|
+
<div class="header-right">
|
|
169
|
+
<div class="theme-toggle-container theme-toggle-header">
|
|
170
|
+
<button class="theme-toggle" aria-label="Toggle Light / Dark / Auto color theme">
|
|
171
|
+
<svg class="theme-icon-when-auto-light"><use href="#svg-sun-with-moon"></use></svg>
|
|
172
|
+
<svg class="theme-icon-when-auto-dark"><use href="#svg-moon-with-sun"></use></svg>
|
|
173
|
+
<svg class="theme-icon-when-dark"><use href="#svg-moon"></use></svg>
|
|
174
|
+
<svg class="theme-icon-when-light"><use href="#svg-sun"></use></svg>
|
|
175
|
+
</button>
|
|
176
|
+
</div>
|
|
177
|
+
<label class="toc-overlay-icon toc-header-icon" for="__toc">
|
|
178
|
+
<span class="icon"><svg><use href="#svg-toc"></use></svg></span>
|
|
179
|
+
</label>
|
|
180
|
+
</div>
|
|
181
|
+
</header>
|
|
182
|
+
<aside class="sidebar-drawer">
|
|
183
|
+
<div class="sidebar-container">
|
|
184
|
+
|
|
185
|
+
<div class="sidebar-sticky"><a class="sidebar-brand" href="index.html">
|
|
186
|
+
|
|
187
|
+
<span class="sidebar-brand-text">IBM Envizi - Emissions API Node.js SDK documentation</span>
|
|
188
|
+
|
|
189
|
+
</a><form class="sidebar-search-container" method="get" action="search.html" role="search">
|
|
190
|
+
<input class="sidebar-search" placeholder="Search" name="q" aria-label="Search">
|
|
191
|
+
<input type="hidden" name="check_keywords" value="yes">
|
|
192
|
+
<input type="hidden" name="area" value="default">
|
|
193
|
+
</form>
|
|
194
|
+
<div id="searchbox"></div><div class="sidebar-scroll"><div class="sidebar-tree">
|
|
195
|
+
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
|
|
196
|
+
<ul class="current">
|
|
197
|
+
<li class="toctree-l1"><a class="reference internal" href="getting_started.html">Getting Started</a></li>
|
|
198
|
+
<li class="toctree-l1 current has-children"><a class="reference internal" href="sdk.html">SDK</a><input aria-label="Toggle navigation of SDK" checked="" class="toctree-checkbox" id="toctree-checkbox-1" name="toctree-checkbox-1" role="switch" type="checkbox"/><label for="toctree-checkbox-1"><span class="icon"><svg><use href="#svg-arrow-right"></use></svg></span></label><ul class="current">
|
|
199
|
+
<li class="toctree-l2 current current-page"><a class="current reference internal" href="#">Client</a></li>
|
|
200
|
+
<li class="toctree-l2"><a class="reference internal" href="authentication.html">Authentication</a></li>
|
|
201
|
+
</ul>
|
|
202
|
+
</li>
|
|
203
|
+
<li class="toctree-l1"><a class="reference internal" href="reference.html">Reference</a></li>
|
|
204
|
+
</ul>
|
|
205
|
+
|
|
206
|
+
</div>
|
|
207
|
+
</div>
|
|
208
|
+
|
|
209
|
+
</div>
|
|
210
|
+
|
|
211
|
+
</div>
|
|
212
|
+
</aside>
|
|
213
|
+
<div class="main">
|
|
214
|
+
<div class="content">
|
|
215
|
+
<div class="article-container">
|
|
216
|
+
<a href="#" class="back-to-top muted-link">
|
|
217
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
218
|
+
<path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8v12z"></path>
|
|
219
|
+
</svg>
|
|
220
|
+
<span>Back to top</span>
|
|
221
|
+
</a>
|
|
222
|
+
<div class="content-icon-container">
|
|
223
|
+
<div class="view-this-page">
|
|
224
|
+
<a class="muted-link" href="_sources/client.rst.txt" title="View this page">
|
|
225
|
+
<svg><use href="#svg-eye"></use></svg>
|
|
226
|
+
<span class="visually-hidden">View this page</span>
|
|
227
|
+
</a>
|
|
228
|
+
</div>
|
|
229
|
+
<div class="theme-toggle-container theme-toggle-content">
|
|
230
|
+
<button class="theme-toggle" aria-label="Toggle Light / Dark / Auto color theme">
|
|
231
|
+
<svg class="theme-icon-when-auto-light"><use href="#svg-sun-with-moon"></use></svg>
|
|
232
|
+
<svg class="theme-icon-when-auto-dark"><use href="#svg-moon-with-sun"></use></svg>
|
|
233
|
+
<svg class="theme-icon-when-dark"><use href="#svg-moon"></use></svg>
|
|
234
|
+
<svg class="theme-icon-when-light"><use href="#svg-sun"></use></svg>
|
|
235
|
+
</button>
|
|
236
|
+
</div>
|
|
237
|
+
<label class="toc-overlay-icon toc-content-icon" for="__toc">
|
|
238
|
+
<span class="icon"><svg><use href="#svg-toc"></use></svg></span>
|
|
239
|
+
</label>
|
|
240
|
+
</div>
|
|
241
|
+
<article role="main" id="furo-main-content">
|
|
242
|
+
<section id="client">
|
|
243
|
+
<h1>Client<a class="headerlink" href="#client" title="Link to this heading">¶</a></h1>
|
|
244
|
+
<section id="overview">
|
|
245
|
+
<h2>Overview<a class="headerlink" href="#overview" title="Link to this heading">¶</a></h2>
|
|
246
|
+
<p>The Client is the central component of the IBM Envizi - Emissions API Node.js SDK. It handles authentication, maintains connections to the API, and provides a unified interface for all API operations.</p>
|
|
247
|
+
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>+----------------------+
|
|
248
|
+
| Application |<-----------+
|
|
249
|
+
+----------------------+ |
|
|
250
|
+
| |
|
|
251
|
+
v |
|
|
252
|
+
+----------------------+ |
|
|
253
|
+
| Client |<-----------+
|
|
254
|
+
+----------------------+ |
|
|
255
|
+
| |
|
|
256
|
+
v |
|
|
257
|
+
+----------------------+ +----------------------+
|
|
258
|
+
| Authentication |---->| API Module Requests |
|
|
259
|
+
+----------------------+ +----------------------+
|
|
260
|
+
</pre></div>
|
|
261
|
+
</div>
|
|
262
|
+
</section>
|
|
263
|
+
<section id="client-initialization">
|
|
264
|
+
<h2>Client Initialization<a class="headerlink" href="#client-initialization" title="Link to this heading">¶</a></h2>
|
|
265
|
+
<p>The Client is designed as a singleton to ensure consistent authentication across your application. Initialize it once at application startup:</p>
|
|
266
|
+
<ol class="arabic simple">
|
|
267
|
+
<li><p>Managed token (SDK fetches & refreshes)</p></li>
|
|
268
|
+
</ol>
|
|
269
|
+
<div class="highlight-javascript notranslate"><div class="highlight"><pre><span></span><span class="k">import</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">Client</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="kr">from</span><span class="w"> </span><span class="s1">'emissions-api-sdk'</span><span class="p">;</span>
|
|
270
|
+
|
|
271
|
+
<span class="k">await</span><span class="w"> </span><span class="nx">Client</span><span class="p">.</span><span class="nx">getClient</span><span class="p">({</span>
|
|
272
|
+
<span class="w"> </span><span class="nx">apiKey</span><span class="o">:</span><span class="w"> </span><span class="nx">process</span><span class="p">.</span><span class="nx">env</span><span class="p">.</span><span class="nx">ENVIZI_API_KEY</span><span class="p">,</span>
|
|
273
|
+
<span class="w"> </span><span class="nx">clientId</span><span class="o">:</span><span class="w"> </span><span class="nx">process</span><span class="p">.</span><span class="nx">env</span><span class="p">.</span><span class="nx">ENVIZI_CLIENT_ID</span><span class="p">,</span>
|
|
274
|
+
<span class="w"> </span><span class="nx">orgId</span><span class="o">:</span><span class="w"> </span><span class="nx">process</span><span class="p">.</span><span class="nx">env</span><span class="p">.</span><span class="nx">ENVIZI_ORG_ID</span>
|
|
275
|
+
<span class="p">});</span>
|
|
276
|
+
</pre></div>
|
|
277
|
+
</div>
|
|
278
|
+
<ol class="arabic simple" start="2">
|
|
279
|
+
<li><p>User-provided token (SDK will <strong>not</strong> refresh it)</p></li>
|
|
280
|
+
</ol>
|
|
281
|
+
<div class="highlight-javascript notranslate"><div class="highlight"><pre><span></span><span class="k">import</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">Client</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="kr">from</span><span class="w"> </span><span class="s2">"emissions-api-sdk"</span><span class="p">;</span>
|
|
282
|
+
|
|
283
|
+
<span class="k">await</span><span class="w"> </span><span class="nx">Client</span><span class="p">.</span><span class="nx">getClient</span><span class="p">({</span>
|
|
284
|
+
<span class="w"> </span><span class="nx">clientId</span><span class="o">:</span><span class="w"> </span><span class="nx">process</span><span class="p">.</span><span class="nx">env</span><span class="p">.</span><span class="nx">ENVIZI_CLIENT_ID</span><span class="p">,</span>
|
|
285
|
+
<span class="w"> </span><span class="nx">token</span><span class="o">:</span><span class="w"> </span><span class="nx">process</span><span class="p">.</span><span class="nx">env</span><span class="p">.</span><span class="nx">TOKEN</span>
|
|
286
|
+
<span class="p">});</span>
|
|
287
|
+
</pre></div>
|
|
288
|
+
</div>
|
|
289
|
+
</section>
|
|
290
|
+
<section id="configuration-options">
|
|
291
|
+
<h2>Configuration Options<a class="headerlink" href="#configuration-options" title="Link to this heading">¶</a></h2>
|
|
292
|
+
<p>The Client accepts the following configuration parameters:</p>
|
|
293
|
+
<div class="table-wrapper colwidths-given docutils container">
|
|
294
|
+
<table class="docutils align-default">
|
|
295
|
+
<colgroup>
|
|
296
|
+
<col style="width: 20.0%" />
|
|
297
|
+
<col style="width: 15.0%" />
|
|
298
|
+
<col style="width: 65.0%" />
|
|
299
|
+
</colgroup>
|
|
300
|
+
<thead>
|
|
301
|
+
<tr class="row-odd"><th class="head"><p>Parameter</p></th>
|
|
302
|
+
<th class="head"><p>Required</p></th>
|
|
303
|
+
<th class="head"><p>Description</p></th>
|
|
304
|
+
</tr>
|
|
305
|
+
</thead>
|
|
306
|
+
<tbody>
|
|
307
|
+
<tr class="row-even"><td><p>apiKey</p></td>
|
|
308
|
+
<td><p>Yes*</p></td>
|
|
309
|
+
<td><p>API key for authentication (required unless using token)</p></td>
|
|
310
|
+
</tr>
|
|
311
|
+
<tr class="row-odd"><td><p>clientId</p></td>
|
|
312
|
+
<td><p>Yes</p></td>
|
|
313
|
+
<td><p>Client ID for API access</p></td>
|
|
314
|
+
</tr>
|
|
315
|
+
<tr class="row-even"><td><p>orgId</p></td>
|
|
316
|
+
<td><p>Yes*</p></td>
|
|
317
|
+
<td><p>Organization ID (required with apiKey)</p></td>
|
|
318
|
+
</tr>
|
|
319
|
+
<tr class="row-odd"><td><p>token</p></td>
|
|
320
|
+
<td><p>Yes*</p></td>
|
|
321
|
+
<td><p>Pre-generated token (required if not using apiKey)</p></td>
|
|
322
|
+
</tr>
|
|
323
|
+
<tr class="row-even"><td><p>host</p></td>
|
|
324
|
+
<td><p>No</p></td>
|
|
325
|
+
<td><p>Custom API endpoint (defaults to production)</p></td>
|
|
326
|
+
</tr>
|
|
327
|
+
<tr class="row-odd"><td><p>authUrl</p></td>
|
|
328
|
+
<td><p>No</p></td>
|
|
329
|
+
<td><p>Custom authentication endpoint (defaults to production)</p></td>
|
|
330
|
+
</tr>
|
|
331
|
+
</tbody>
|
|
332
|
+
</table>
|
|
333
|
+
</div>
|
|
334
|
+
<div class="admonition note">
|
|
335
|
+
<p class="admonition-title">Note</p>
|
|
336
|
+
<p>Either <code class="docutils literal notranslate"><span class="pre">apiKey+orgId</span></code> OR <code class="docutils literal notranslate"><span class="pre">token</span></code> is required</p>
|
|
337
|
+
</div>
|
|
338
|
+
</section>
|
|
339
|
+
<section id="client-responsibilities">
|
|
340
|
+
<h2>Client Responsibilities<a class="headerlink" href="#client-responsibilities" title="Link to this heading">¶</a></h2>
|
|
341
|
+
<p>The Client handles several key responsibilities:</p>
|
|
342
|
+
<ol class="arabic simple">
|
|
343
|
+
<li><p><strong>Singleton Management</strong>: Ensures only one Client instance exists</p></li>
|
|
344
|
+
<li><p><strong>Configuration Validation</strong>: Verifies required parameters</p></li>
|
|
345
|
+
<li><p><strong>Token Generation</strong>: Obtains tokens from the authentication service</p></li>
|
|
346
|
+
<li><p><strong>Token Refreshing</strong>: Automatically refreshes tokens before expiration</p></li>
|
|
347
|
+
<li><p><strong>Request Authentication</strong>: Adds proper headers to all API requests</p></li>
|
|
348
|
+
</ol>
|
|
349
|
+
</section>
|
|
350
|
+
<section id="error-handling">
|
|
351
|
+
<h2>Error Handling<a class="headerlink" href="#error-handling" title="Link to this heading">¶</a></h2>
|
|
352
|
+
<p>Handle authentication errors gracefully:</p>
|
|
353
|
+
<div class="highlight-javascript notranslate"><div class="highlight"><pre><span></span><span class="k">try</span><span class="w"> </span><span class="p">{</span>
|
|
354
|
+
<span class="w"> </span><span class="k">await</span><span class="w"> </span><span class="nx">Client</span><span class="p">.</span><span class="nx">getClient</span><span class="p">({</span>
|
|
355
|
+
<span class="w"> </span><span class="nx">apiKey</span><span class="o">:</span><span class="w"> </span><span class="nx">process</span><span class="p">.</span><span class="nx">env</span><span class="p">.</span><span class="nx">ENVIZI_API_KEY</span><span class="p">,</span>
|
|
356
|
+
<span class="w"> </span><span class="nx">clientId</span><span class="o">:</span><span class="w"> </span><span class="nx">process</span><span class="p">.</span><span class="nx">env</span><span class="p">.</span><span class="nx">ENVIZI_CLIENT_ID</span><span class="p">,</span>
|
|
357
|
+
<span class="w"> </span><span class="nx">orgId</span><span class="o">:</span><span class="w"> </span><span class="nx">process</span><span class="p">.</span><span class="nx">env</span><span class="p">.</span><span class="nx">ENVIZI_ORG_ID</span>
|
|
358
|
+
<span class="w"> </span><span class="p">});</span>
|
|
359
|
+
<span class="p">}</span><span class="w"> </span><span class="k">catch</span><span class="w"> </span><span class="p">(</span><span class="nx">error</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
|
|
360
|
+
<span class="w"> </span><span class="nx">console</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="s2">"Authentication error:"</span><span class="p">,</span><span class="w"> </span><span class="nx">error</span><span class="p">.</span><span class="nx">message</span><span class="p">);</span>
|
|
361
|
+
<span class="w"> </span><span class="c1">// Implement appropriate error handling</span>
|
|
362
|
+
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">error</span><span class="p">.</span><span class="nx">response</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
|
|
363
|
+
<span class="w"> </span><span class="c1">// Handle specific HTTP error responses</span>
|
|
364
|
+
<span class="w"> </span><span class="nx">console</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="s2">"Status:"</span><span class="p">,</span><span class="w"> </span><span class="nx">error</span><span class="p">.</span><span class="nx">response</span><span class="p">.</span><span class="nx">status</span><span class="p">);</span>
|
|
365
|
+
<span class="w"> </span><span class="nx">console</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="s2">"Details:"</span><span class="p">,</span><span class="w"> </span><span class="nx">error</span><span class="p">.</span><span class="nx">response</span><span class="p">.</span><span class="nx">data</span><span class="p">);</span>
|
|
366
|
+
<span class="w"> </span><span class="p">}</span>
|
|
367
|
+
<span class="p">}</span>
|
|
368
|
+
</pre></div>
|
|
369
|
+
</div>
|
|
370
|
+
</section>
|
|
371
|
+
<section id="best-practices">
|
|
372
|
+
<h2>Best Practices<a class="headerlink" href="#best-practices" title="Link to this heading">¶</a></h2>
|
|
373
|
+
<p>For optimal Client usage:</p>
|
|
374
|
+
<ol class="arabic simple">
|
|
375
|
+
<li><p><strong>Initialize once</strong> at application startup</p></li>
|
|
376
|
+
<li><p><strong>Store credentials securely</strong> using environment variables</p></li>
|
|
377
|
+
<li><p><strong>Implement proper error handling</strong> for authentication failures</p></li>
|
|
378
|
+
<li><p><strong>Let the SDK handle</strong> token refreshing automatically</p></li>
|
|
379
|
+
<li><p><strong>Reuse the Client instance</strong> across your application</p></li>
|
|
380
|
+
</ol>
|
|
381
|
+
</section>
|
|
382
|
+
<section id="authentication-integration">
|
|
383
|
+
<h2>Authentication Integration<a class="headerlink" href="#authentication-integration" title="Link to this heading">¶</a></h2>
|
|
384
|
+
<p>The Client works closely with the Authentication module to manage tokens. For detailed information about the authentication process, supported methods, and security best practices, see the <a class="reference internal" href="authentication.html"><span class="doc">Authentication</span></a> page.</p>
|
|
385
|
+
</section>
|
|
386
|
+
</section>
|
|
387
|
+
|
|
388
|
+
</article>
|
|
389
|
+
</div>
|
|
390
|
+
<footer>
|
|
391
|
+
|
|
392
|
+
<div class="related-pages">
|
|
393
|
+
<a class="next-page" href="authentication.html">
|
|
394
|
+
<div class="page-info">
|
|
395
|
+
<div class="context">
|
|
396
|
+
<span>Next</span>
|
|
397
|
+
</div>
|
|
398
|
+
<div class="title">Authentication</div>
|
|
399
|
+
</div>
|
|
400
|
+
<svg class="furo-related-icon"><use href="#svg-arrow-right"></use></svg>
|
|
401
|
+
</a>
|
|
402
|
+
<a class="prev-page" href="sdk.html">
|
|
403
|
+
<svg class="furo-related-icon"><use href="#svg-arrow-right"></use></svg>
|
|
404
|
+
<div class="page-info">
|
|
405
|
+
<div class="context">
|
|
406
|
+
<span>Previous</span>
|
|
407
|
+
</div>
|
|
408
|
+
|
|
409
|
+
<div class="title">SDK</div>
|
|
410
|
+
|
|
411
|
+
</div>
|
|
412
|
+
</a>
|
|
413
|
+
</div>
|
|
414
|
+
<div class="bottom-of-page">
|
|
415
|
+
<div class="left-details">
|
|
416
|
+
<div class="copyright">
|
|
417
|
+
Copyright © 2025, IBM Corporation
|
|
418
|
+
</div>
|
|
419
|
+
Made with <a href="https://www.sphinx-doc.org/">Sphinx</a> and <a class="muted-link" href="https://pradyunsg.me">@pradyunsg</a>'s
|
|
420
|
+
|
|
421
|
+
<a href="https://github.com/pradyunsg/furo">Furo</a>
|
|
422
|
+
|
|
423
|
+
</div>
|
|
424
|
+
<div class="right-details">
|
|
425
|
+
|
|
426
|
+
</div>
|
|
427
|
+
</div>
|
|
428
|
+
|
|
429
|
+
</footer>
|
|
430
|
+
</div>
|
|
431
|
+
<aside class="toc-drawer">
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
<div class="toc-sticky toc-scroll">
|
|
435
|
+
<div class="toc-title-container">
|
|
436
|
+
<span class="toc-title">
|
|
437
|
+
On this page
|
|
438
|
+
</span>
|
|
439
|
+
</div>
|
|
440
|
+
<div class="toc-tree-container">
|
|
441
|
+
<div class="toc-tree">
|
|
442
|
+
<ul>
|
|
443
|
+
<li><a class="reference internal" href="#">Client</a><ul>
|
|
444
|
+
<li><a class="reference internal" href="#overview">Overview</a></li>
|
|
445
|
+
<li><a class="reference internal" href="#client-initialization">Client Initialization</a></li>
|
|
446
|
+
<li><a class="reference internal" href="#configuration-options">Configuration Options</a></li>
|
|
447
|
+
<li><a class="reference internal" href="#client-responsibilities">Client Responsibilities</a></li>
|
|
448
|
+
<li><a class="reference internal" href="#error-handling">Error Handling</a></li>
|
|
449
|
+
<li><a class="reference internal" href="#best-practices">Best Practices</a></li>
|
|
450
|
+
<li><a class="reference internal" href="#authentication-integration">Authentication Integration</a></li>
|
|
451
|
+
</ul>
|
|
452
|
+
</li>
|
|
453
|
+
</ul>
|
|
454
|
+
|
|
455
|
+
</div>
|
|
456
|
+
</div>
|
|
457
|
+
</div>
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
</aside>
|
|
461
|
+
</div>
|
|
462
|
+
</div><script src="_static/documentation_options.js?v=5929fcd5"></script>
|
|
463
|
+
<script src="_static/doctools.js?v=9bcbadda"></script>
|
|
464
|
+
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
|
|
465
|
+
<script src="_static/scripts/furo.js?v=46bd48cc"></script>
|
|
466
|
+
</body>
|
|
467
|
+
</html>
|