File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -10,15 +10,18 @@ export type {
1010 ScwFile ,
1111 TimeSeries ,
1212} from './scw/custom-types'
13+ export { Decimal } from './scw/custom-types'
1314export {
1415 marshalScwFile ,
1516 marshalMoney ,
1617 marshalTimeSeries ,
18+ marshalDecimal ,
1719 unmarshalMoney ,
1820 unmarshalScwFile ,
1921 unmarshalServiceInfo ,
2022 unmarshalTimeSeries ,
2123 unmarshalTimeSeriesPoint ,
24+ unmarshalDecimal ,
2225} from './scw/custom-marshalling'
2326export { enrichForPagination } from './scw/fetch/resource-paginator'
2427export type { Region , Zone } from './scw/locality'
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import type {
77 TimeSeries ,
88 TimeSeriesPoint ,
99} from './custom-types'
10+ import { Decimal } from './custom-types'
1011
1112/**
1213 * Unmarshals {@link Money}
@@ -107,6 +108,21 @@ export const unmarshalTimeSeries = (data: unknown) => {
107108 } as TimeSeries
108109}
109110
111+ /**
112+ * Unmarshals {@link Decimal}
113+ *
114+ * @internal
115+ */
116+ export const unmarshalDecimal = ( data : unknown ) => {
117+ if ( ! ( typeof data === 'string' ) ) {
118+ throw new TypeError (
119+ `Unmarshalling the type 'Decimal' failed as data isn't a string.` ,
120+ )
121+ }
122+
123+ return new Decimal ( data )
124+ }
125+
110126/**
111127 * Marshals {@link ScwFile}.
112128 *
@@ -153,3 +169,10 @@ export const marshalTimeSeries = (
153169 name : obj . name ,
154170 points : obj . points . map ( elt => marshalTimeSeriesPoint ( elt ) ) ,
155171} )
172+
173+ /**
174+ * Marshals {@link Decimal}
175+ *
176+ * @internal
177+ */
178+ export const marshalDecimal = ( obj : Decimal ) : string => obj . toString ( )
You can’t perform that action at this time.
0 commit comments