1
- /*
2
- * The version of the OpenAPI document: v1
3
- *
4
- *
5
- * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
6
- * https://openapi-generator.tech
7
- * Do not edit this class manually.
8
- */
1
+ export * from "./serviceError"
2
+ export * from "./subjectErasureByPspReferenceRequest"
3
+ export * from "./subjectErasureResponse"
9
4
10
-
11
- export * from './serviceError' ;
12
- export * from './subjectErasureByPspReferenceRequest' ;
13
- export * from './subjectErasureResponse' ;
14
-
15
-
16
- import { ServiceError } from './serviceError' ;
17
- import { SubjectErasureByPspReferenceRequest } from './subjectErasureByPspReferenceRequest' ;
18
- import { SubjectErasureResponse } from './subjectErasureResponse' ;
19
-
20
- /* tslint:disable:no-unused-variable */
21
- let primitives = [
22
- "string" ,
23
- "boolean" ,
24
- "double" ,
25
- "integer" ,
26
- "long" ,
27
- "float" ,
28
- "number" ,
29
- "any"
30
- ] ;
31
-
32
- let enumsMap : { [ index : string ] : any } = {
33
- "SubjectErasureResponse.ResultEnum" : SubjectErasureResponse . ResultEnum ,
34
- }
35
-
36
- let typeMap : { [ index : string ] : any } = {
37
- "ServiceError" : ServiceError ,
38
- "SubjectErasureByPspReferenceRequest" : SubjectErasureByPspReferenceRequest ,
39
- "SubjectErasureResponse" : SubjectErasureResponse ,
40
- }
41
-
42
- export class ObjectSerializer {
43
- public static findCorrectType ( data : any , expectedType : string ) {
44
- if ( data == undefined ) {
45
- return expectedType ;
46
- } else if ( primitives . indexOf ( expectedType . toLowerCase ( ) ) !== - 1 ) {
47
- return expectedType ;
48
- } else if ( expectedType === "Date" ) {
49
- return expectedType ;
50
- } else {
51
- if ( enumsMap [ expectedType ] ) {
52
- return expectedType ;
53
- }
54
-
55
- if ( ! typeMap [ expectedType ] ) {
56
- return expectedType ; // w/e we don't know the type
57
- }
58
-
59
- // Check the discriminator
60
- let discriminatorProperty = typeMap [ expectedType ] . discriminator ;
61
- if ( discriminatorProperty == null ) {
62
- return expectedType ; // the type does not have a discriminator. use it.
63
- } else {
64
- if ( data [ discriminatorProperty ] ) {
65
- var discriminatorType = data [ discriminatorProperty ] ;
66
- if ( typeMap [ discriminatorType ] ) {
67
- return discriminatorType ; // use the type given in the discriminator
68
- } else {
69
- return expectedType ; // discriminator did not map to a type
70
- }
71
- } else {
72
- return expectedType ; // discriminator was not present (or an empty string)
73
- }
74
- }
75
- }
76
- }
77
-
78
- public static serialize ( data : any , type : string ) {
79
- if ( data == undefined ) {
80
- return data ;
81
- } else if ( primitives . indexOf ( type . toLowerCase ( ) ) !== - 1 ) {
82
- return data ;
83
- } else if ( type . lastIndexOf ( "Array<" , 0 ) === 0 ) { // string.startsWith pre es6
84
- let subType : string = type . replace ( "Array<" , "" ) ; // Array<Type> => Type>
85
- subType = subType . substring ( 0 , subType . length - 1 ) ; // Type> => Type
86
- let transformedData : any [ ] = [ ] ;
87
- for ( let index = 0 ; index < data . length ; index ++ ) {
88
- let datum = data [ index ] ;
89
- transformedData . push ( ObjectSerializer . serialize ( datum , subType ) ) ;
90
- }
91
- return transformedData ;
92
- } else if ( type === "Date" ) {
93
- return data . toISOString ( ) ;
94
- } else if ( type === "SaleToAcquirerData" ) {
95
- const dataString = JSON . stringify ( data ) ;
96
- return Buffer . from ( dataString ) . toString ( "base64" ) ;
97
- } else {
98
- if ( enumsMap [ type ] ) {
99
- return data ;
100
- }
101
- if ( ! typeMap [ type ] ) { // in case we dont know the type
102
- return data ;
103
- }
104
-
105
- // Get the actual type of this object
106
- type = this . findCorrectType ( data , type ) ;
107
-
108
- // get the map for the correct type.
109
- let attributeTypes = typeMap [ type ] . getAttributeTypeMap ( ) ;
110
- let instance : { [ index : string ] : any } = { } ;
111
- for ( let index = 0 ; index < attributeTypes . length ; index ++ ) {
112
- let attributeType = attributeTypes [ index ] ;
113
- instance [ attributeType . baseName ] = ObjectSerializer . serialize ( data [ attributeType . name ] , attributeType . type ) ;
114
- }
115
- return instance ;
116
- }
117
- }
118
-
119
- public static deserialize ( data : any , type : string ) {
120
- // polymorphism may change the actual type.
121
- type = ObjectSerializer . findCorrectType ( data , type ) ;
122
- if ( data == undefined ) {
123
- return data ;
124
- } else if ( primitives . indexOf ( type . toLowerCase ( ) ) !== - 1 ) {
125
- return data ;
126
- } else if ( type . lastIndexOf ( "Array<" , 0 ) === 0 ) { // string.startsWith pre es6
127
- let subType : string = type . replace ( "Array<" , "" ) ; // Array<Type> => Type>
128
- subType = subType . substring ( 0 , subType . length - 1 ) ; // Type> => Type
129
- let transformedData : any [ ] = [ ] ;
130
- for ( let index = 0 ; index < data . length ; index ++ ) {
131
- let datum = data [ index ] ;
132
- transformedData . push ( ObjectSerializer . deserialize ( datum , subType ) ) ;
133
- }
134
- return transformedData ;
135
- } else if ( type === "Date" ) {
136
- return new Date ( data ) ;
137
- } else {
138
- if ( enumsMap [ type ] ) { // is Enum
139
- return data ;
140
- }
141
-
142
- if ( ! typeMap [ type ] ) { // dont know the type
143
- return data ;
144
- }
145
- let instance = new typeMap [ type ] ( ) ;
146
- let attributeTypes = typeMap [ type ] . getAttributeTypeMap ( ) ;
147
- for ( let index = 0 ; index < attributeTypes . length ; index ++ ) {
148
- let attributeType = attributeTypes [ index ] ;
149
- instance [ attributeType . name ] = ObjectSerializer . deserialize ( data [ attributeType . baseName ] , attributeType . type ) ;
150
- }
151
- return instance ;
152
- }
153
- }
154
- }
5
+ // serializing and deserializing typed objects
6
+ export * from "./objectSerializer"
0 commit comments