-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathmodels.ts
318 lines (303 loc) · 15 KB
/
models.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
/*
* The version of the OpenAPI document: v2
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit this class manually.
*/
export * from './accountHolder';
export * from './accountHolderCapability';
export * from './accountHolderNotificationData';
export * from './accountHolderNotificationRequest';
export * from './accountSupportingEntityCapability';
export * from './address';
export * from './amount';
export * from './authentication';
export * from './balance';
export * from './balanceAccount';
export * from './balanceAccountNotificationData';
export * from './balanceAccountNotificationRequest';
export * from './balancePlatformNotificationResponse';
export * from './bankAccountDetails';
export * from './bulkAddress';
export * from './capabilityProblem';
export * from './capabilityProblemEntity';
export * from './capabilityProblemEntityRecursive';
export * from './capabilitySettings';
export * from './card';
export * from './cardConfiguration';
export * from './cardOrderItem';
export * from './cardOrderItemDeliveryStatus';
export * from './cardOrderNotificationRequest';
export * from './contactDetails';
export * from './deliveryAddress';
export * from './deliveryContact';
export * from './expiry';
export * from './ibanAccountIdentification';
export * from './name';
export * from './paymentInstrument';
export * from './paymentInstrumentNotificationData';
export * from './paymentNotificationRequest';
export * from './phone';
export * from './phoneNumber';
export * from './platformPaymentConfiguration';
export * from './remediatingAction';
export * from './resource';
export * from './sweepConfigurationNotificationData';
export * from './sweepConfigurationNotificationRequest';
export * from './sweepConfigurationV2';
export * from './sweepCounterparty';
export * from './sweepSchedule';
export * from './verificationDeadline';
export * from './verificationError';
export * from './verificationErrorRecursive';
import { AccountHolder } from './accountHolder';
import { AccountHolderCapability } from './accountHolderCapability';
import { AccountHolderNotificationData } from './accountHolderNotificationData';
import { AccountHolderNotificationRequest } from './accountHolderNotificationRequest';
import { AccountSupportingEntityCapability } from './accountSupportingEntityCapability';
import { Address } from './address';
import { Amount } from './amount';
import { Authentication } from './authentication';
import { Balance } from './balance';
import { BalanceAccount } from './balanceAccount';
import { BalanceAccountNotificationData } from './balanceAccountNotificationData';
import { BalanceAccountNotificationRequest } from './balanceAccountNotificationRequest';
import { BalancePlatformNotificationResponse } from './balancePlatformNotificationResponse';
import { BankAccountDetails } from './bankAccountDetails';
import { BulkAddress } from './bulkAddress';
import { CapabilityProblem } from './capabilityProblem';
import { CapabilityProblemEntity } from './capabilityProblemEntity';
import { CapabilityProblemEntityRecursive } from './capabilityProblemEntityRecursive';
import { CapabilitySettings } from './capabilitySettings';
import { Card } from './card';
import { CardConfiguration } from './cardConfiguration';
import { CardOrderItem } from './cardOrderItem';
import { CardOrderItemDeliveryStatus } from './cardOrderItemDeliveryStatus';
import { CardOrderNotificationRequest } from './cardOrderNotificationRequest';
import { ContactDetails } from './contactDetails';
import { DeliveryAddress } from './deliveryAddress';
import { DeliveryContact } from './deliveryContact';
import { Expiry } from './expiry';
import { IbanAccountIdentification } from './ibanAccountIdentification';
import { Name } from './name';
import { PaymentInstrument } from './paymentInstrument';
import { PaymentInstrumentNotificationData } from './paymentInstrumentNotificationData';
import { PaymentNotificationRequest } from './paymentNotificationRequest';
import { Phone } from './phone';
import { PhoneNumber } from './phoneNumber';
import { PlatformPaymentConfiguration } from './platformPaymentConfiguration';
import { RemediatingAction } from './remediatingAction';
import { Resource } from './resource';
import { SweepConfigurationNotificationData } from './sweepConfigurationNotificationData';
import { SweepConfigurationNotificationRequest } from './sweepConfigurationNotificationRequest';
import { SweepConfigurationV2 } from './sweepConfigurationV2';
import { SweepCounterparty } from './sweepCounterparty';
import { SweepSchedule } from './sweepSchedule';
import { VerificationDeadline } from './verificationDeadline';
import { VerificationError } from './verificationError';
import { VerificationErrorRecursive } from './verificationErrorRecursive';
/* tslint:disable:no-unused-variable */
let primitives = [
"string",
"boolean",
"double",
"integer",
"long",
"float",
"number",
"any"
];
let enumsMap: {[index: string]: any} = {
"AccountHolder.StatusEnum": AccountHolder.StatusEnum,
"AccountHolderCapability.AllowedLevelEnum": AccountHolderCapability.AllowedLevelEnum,
"AccountHolderCapability.RequestedLevelEnum": AccountHolderCapability.RequestedLevelEnum,
"AccountHolderCapability.VerificationStatusEnum": AccountHolderCapability.VerificationStatusEnum,
"AccountHolderNotificationRequest.TypeEnum": AccountHolderNotificationRequest.TypeEnum,
"AccountSupportingEntityCapability.AllowedLevelEnum": AccountSupportingEntityCapability.AllowedLevelEnum,
"AccountSupportingEntityCapability.RequestedLevelEnum": AccountSupportingEntityCapability.RequestedLevelEnum,
"AccountSupportingEntityCapability.VerificationStatusEnum": AccountSupportingEntityCapability.VerificationStatusEnum,
"BalanceAccount.StatusEnum": BalanceAccount.StatusEnum,
"BalanceAccountNotificationRequest.TypeEnum": BalanceAccountNotificationRequest.TypeEnum,
"CapabilityProblemEntity.TypeEnum": CapabilityProblemEntity.TypeEnum,
"CapabilityProblemEntityRecursive.TypeEnum": CapabilityProblemEntityRecursive.TypeEnum,
"CapabilitySettings.FundingSourceEnum": CapabilitySettings.FundingSourceEnum,
"CapabilitySettings.IntervalEnum": CapabilitySettings.IntervalEnum,
"Card.FormFactorEnum": Card.FormFactorEnum,
"CardOrderItemDeliveryStatus.StatusEnum": CardOrderItemDeliveryStatus.StatusEnum,
"CardOrderNotificationRequest.TypeEnum": CardOrderNotificationRequest.TypeEnum,
"IbanAccountIdentification.TypeEnum": IbanAccountIdentification.TypeEnum,
"PaymentInstrument.StatusEnum": PaymentInstrument.StatusEnum,
"PaymentInstrument.StatusReasonEnum": PaymentInstrument.StatusReasonEnum,
"PaymentInstrument.TypeEnum": PaymentInstrument.TypeEnum,
"PaymentNotificationRequest.TypeEnum": PaymentNotificationRequest.TypeEnum,
"Phone.TypeEnum": Phone.TypeEnum,
"PhoneNumber.PhoneTypeEnum": PhoneNumber.PhoneTypeEnum,
"SweepConfigurationNotificationRequest.TypeEnum": SweepConfigurationNotificationRequest.TypeEnum,
"SweepConfigurationV2.CategoryEnum": SweepConfigurationV2.CategoryEnum,
"SweepConfigurationV2.PrioritiesEnum": SweepConfigurationV2.PrioritiesEnum,
"SweepConfigurationV2.ReasonEnum": SweepConfigurationV2.ReasonEnum,
"SweepConfigurationV2.StatusEnum": SweepConfigurationV2.StatusEnum,
"SweepConfigurationV2.TypeEnum": SweepConfigurationV2.TypeEnum,
"SweepSchedule.TypeEnum": SweepSchedule.TypeEnum,
"VerificationDeadline.CapabilitiesEnum": VerificationDeadline.CapabilitiesEnum,
"VerificationError.CapabilitiesEnum": VerificationError.CapabilitiesEnum,
"VerificationError.TypeEnum": VerificationError.TypeEnum,
"VerificationErrorRecursive.CapabilitiesEnum": VerificationErrorRecursive.CapabilitiesEnum,
"VerificationErrorRecursive.TypeEnum": VerificationErrorRecursive.TypeEnum,
}
let typeMap: {[index: string]: any} = {
"AccountHolder": AccountHolder,
"AccountHolderCapability": AccountHolderCapability,
"AccountHolderNotificationData": AccountHolderNotificationData,
"AccountHolderNotificationRequest": AccountHolderNotificationRequest,
"AccountSupportingEntityCapability": AccountSupportingEntityCapability,
"Address": Address,
"Amount": Amount,
"Authentication": Authentication,
"Balance": Balance,
"BalanceAccount": BalanceAccount,
"BalanceAccountNotificationData": BalanceAccountNotificationData,
"BalanceAccountNotificationRequest": BalanceAccountNotificationRequest,
"BalancePlatformNotificationResponse": BalancePlatformNotificationResponse,
"BankAccountDetails": BankAccountDetails,
"BulkAddress": BulkAddress,
"CapabilityProblem": CapabilityProblem,
"CapabilityProblemEntity": CapabilityProblemEntity,
"CapabilityProblemEntityRecursive": CapabilityProblemEntityRecursive,
"CapabilitySettings": CapabilitySettings,
"Card": Card,
"CardConfiguration": CardConfiguration,
"CardOrderItem": CardOrderItem,
"CardOrderItemDeliveryStatus": CardOrderItemDeliveryStatus,
"CardOrderNotificationRequest": CardOrderNotificationRequest,
"ContactDetails": ContactDetails,
"DeliveryAddress": DeliveryAddress,
"DeliveryContact": DeliveryContact,
"Expiry": Expiry,
"IbanAccountIdentification": IbanAccountIdentification,
"Name": Name,
"PaymentInstrument": PaymentInstrument,
"PaymentInstrumentNotificationData": PaymentInstrumentNotificationData,
"PaymentNotificationRequest": PaymentNotificationRequest,
"Phone": Phone,
"PhoneNumber": PhoneNumber,
"PlatformPaymentConfiguration": PlatformPaymentConfiguration,
"RemediatingAction": RemediatingAction,
"Resource": Resource,
"SweepConfigurationNotificationData": SweepConfigurationNotificationData,
"SweepConfigurationNotificationRequest": SweepConfigurationNotificationRequest,
"SweepConfigurationV2": SweepConfigurationV2,
"SweepCounterparty": SweepCounterparty,
"SweepSchedule": SweepSchedule,
"VerificationDeadline": VerificationDeadline,
"VerificationError": VerificationError,
"VerificationErrorRecursive": VerificationErrorRecursive,
}
export class ObjectSerializer {
public static findCorrectType(data: any, expectedType: string) {
if (data == undefined) {
return expectedType;
} else if (primitives.indexOf(expectedType.toLowerCase()) !== -1) {
return expectedType;
} else if (expectedType === "Date") {
return expectedType;
} else {
if (enumsMap[expectedType]) {
return expectedType;
}
if (!typeMap[expectedType]) {
return expectedType; // w/e we don't know the type
}
// Check the discriminator
let discriminatorProperty = typeMap[expectedType].discriminator;
if (discriminatorProperty == null) {
return expectedType; // the type does not have a discriminator. use it.
} else {
if (data[discriminatorProperty]) {
var discriminatorType = data[discriminatorProperty];
if(typeMap[discriminatorType]){
return discriminatorType; // use the type given in the discriminator
} else {
return expectedType; // discriminator did not map to a type
}
} else {
return expectedType; // discriminator was not present (or an empty string)
}
}
}
}
public static serialize(data: any, type: string) {
if (data == undefined) {
return data;
} else if (primitives.indexOf(type.toLowerCase()) !== -1) {
return data;
} else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6
let subType: string = type.replace("Array<", ""); // Array<Type> => Type>
subType = subType.substring(0, subType.length - 1); // Type> => Type
let transformedData: any[] = [];
for (let index = 0; index < data.length; index++) {
let datum = data[index];
transformedData.push(ObjectSerializer.serialize(datum, subType));
}
return transformedData;
} else if (type === "Date") {
return data.toISOString();
} else if (type === "SaleToAcquirerData") {
const dataString = JSON.stringify(data);
return Buffer.from(dataString).toString("base64");
} else {
if (enumsMap[type]) {
return data;
}
if (!typeMap[type]) { // in case we dont know the type
return data;
}
// Get the actual type of this object
type = this.findCorrectType(data, type);
// get the map for the correct type.
let attributeTypes = typeMap[type].getAttributeTypeMap();
let instance: {[index: string]: any} = {};
for (let index = 0; index < attributeTypes.length; index++) {
let attributeType = attributeTypes[index];
instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type);
}
return instance;
}
}
public static deserialize(data: any, type: string) {
// polymorphism may change the actual type.
type = ObjectSerializer.findCorrectType(data, type);
if (data == undefined) {
return data;
} else if (primitives.indexOf(type.toLowerCase()) !== -1) {
return data;
} else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6
let subType: string = type.replace("Array<", ""); // Array<Type> => Type>
subType = subType.substring(0, subType.length - 1); // Type> => Type
let transformedData: any[] = [];
for (let index = 0; index < data.length; index++) {
let datum = data[index];
transformedData.push(ObjectSerializer.deserialize(datum, subType));
}
return transformedData;
} else if (type === "Date") {
return new Date(data);
} else {
if (enumsMap[type]) {// is Enum
return data;
}
if (!typeMap[type]) { // dont know the type
return data;
}
let instance = new typeMap[type]();
let attributeTypes = typeMap[type].getAttributeTypeMap();
for (let index = 0; index < attributeTypes.length; index++) {
let attributeType = attributeTypes[index];
instance[attributeType.name] = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type);
}
return instance;
}
}
}