@@ -19,6 +19,55 @@ import type {
1919 ListTaxesResponseTax ,
2020} from './types.gen'
2121
22+ const unmarshalDiscountCoupon = ( data : unknown ) : DiscountCoupon => {
23+ if ( ! isJSONObject ( data ) ) {
24+ throw new TypeError (
25+ `Unmarshalling the type 'DiscountCoupon' failed as data isn't a dictionary.` ,
26+ )
27+ }
28+
29+ return {
30+ description : data . description ,
31+ } as DiscountCoupon
32+ }
33+
34+ const unmarshalDiscountFilter = ( data : unknown ) : DiscountFilter => {
35+ if ( ! isJSONObject ( data ) ) {
36+ throw new TypeError (
37+ `Unmarshalling the type 'DiscountFilter' failed as data isn't a dictionary.` ,
38+ )
39+ }
40+
41+ return {
42+ exclude : data . exclude ,
43+ type : data . type ,
44+ value : data . value ,
45+ } as DiscountFilter
46+ }
47+
48+ export const unmarshalDiscount = ( data : unknown ) : Discount => {
49+ if ( ! isJSONObject ( data ) ) {
50+ throw new TypeError (
51+ `Unmarshalling the type 'Discount' failed as data isn't a dictionary.` ,
52+ )
53+ }
54+
55+ return {
56+ coupon : data . coupon ? unmarshalDiscountCoupon ( data . coupon ) : undefined ,
57+ creationDate : unmarshalDate ( data . creation_date ) ,
58+ description : data . description ,
59+ filters : unmarshalArrayOfObject ( data . filters , unmarshalDiscountFilter ) ,
60+ id : data . id ,
61+ mode : data . mode ,
62+ organizationId : data . organization_id ,
63+ startDate : unmarshalDate ( data . start_date ) ,
64+ stopDate : unmarshalDate ( data . stop_date ) ,
65+ value : data . value ,
66+ valueRemaining : data . value_remaining ,
67+ valueUsed : data . value_used ,
68+ } as Discount
69+ }
70+
2271export const unmarshalInvoice = ( data : unknown ) : Invoice => {
2372 if ( ! isJSONObject ( data ) ) {
2473 throw new TypeError (
@@ -94,55 +143,6 @@ export const unmarshalListConsumptionsResponse = (
94143 } as ListConsumptionsResponse
95144}
96145
97- const unmarshalDiscountCoupon = ( data : unknown ) : DiscountCoupon => {
98- if ( ! isJSONObject ( data ) ) {
99- throw new TypeError (
100- `Unmarshalling the type 'DiscountCoupon' failed as data isn't a dictionary.` ,
101- )
102- }
103-
104- return {
105- description : data . description ,
106- } as DiscountCoupon
107- }
108-
109- const unmarshalDiscountFilter = ( data : unknown ) : DiscountFilter => {
110- if ( ! isJSONObject ( data ) ) {
111- throw new TypeError (
112- `Unmarshalling the type 'DiscountFilter' failed as data isn't a dictionary.` ,
113- )
114- }
115-
116- return {
117- exclude : data . exclude ,
118- type : data . type ,
119- value : data . value ,
120- } as DiscountFilter
121- }
122-
123- const unmarshalDiscount = ( data : unknown ) : Discount => {
124- if ( ! isJSONObject ( data ) ) {
125- throw new TypeError (
126- `Unmarshalling the type 'Discount' failed as data isn't a dictionary.` ,
127- )
128- }
129-
130- return {
131- coupon : data . coupon ? unmarshalDiscountCoupon ( data . coupon ) : undefined ,
132- creationDate : unmarshalDate ( data . creation_date ) ,
133- description : data . description ,
134- filters : unmarshalArrayOfObject ( data . filters , unmarshalDiscountFilter ) ,
135- id : data . id ,
136- mode : data . mode ,
137- organizationId : data . organization_id ,
138- startDate : unmarshalDate ( data . start_date ) ,
139- stopDate : unmarshalDate ( data . stop_date ) ,
140- value : data . value ,
141- valueRemaining : data . value_remaining ,
142- valueUsed : data . value_used ,
143- } as Discount
144- }
145-
146146export const unmarshalListDiscountsResponse = (
147147 data : unknown ,
148148) : ListDiscountsResponse => {
0 commit comments