@@ -57,6 +57,10 @@ public struct APIConfiguration<T,S> where T: ResponseBodyParsable, S: ErrorRespo
57
57
58
58
/// The timeout value for the request wait time.
59
59
public var timeOut : Int
60
+
61
+ /// The date decoding strategy. Default is .defferedToDate
62
+ public var dateDecodingStrategy : JSONDecoder . DateDecodingStrategy
63
+
60
64
61
65
/**
62
66
Initializes Configuration with the host URL and endpoint separately.
@@ -72,6 +76,7 @@ public struct APIConfiguration<T,S> where T: ResponseBodyParsable, S: ErrorRespo
72
76
- parameter body: Request body for the API request.
73
77
- parameter responseBodyObject: Type of the Response Object to create.
74
78
- parameter autoCache: To use that, override `cachingEndsAt:` method of Response Body Object.
79
+ - parameter dateDecodingStrategy: The JSON date decoding strategy. Default is `.defferedToDate`
75
80
Then specified custom caching will be applied for that request.
76
81
*/
77
82
public init ? ( hostURL: String , endPoint: String ,
@@ -84,7 +89,8 @@ public struct APIConfiguration<T,S> where T: ResponseBodyParsable, S: ErrorRespo
84
89
cachingTime: NetworkLayer . CachingTime = NetworkLayer . CachingTime ( seconds: 60 * 60 ) ,
85
90
isMainOperation: Bool = false ,
86
91
autoCache: Bool = false ,
87
- timeOut: Int = 30 ) {
92
+ timeOut: Int = 30 ,
93
+ dateDecodingStrategy: JSONDecoder . DateDecodingStrategy = . deferredToDate) {
88
94
89
95
var url = URL ( string: hostURL)
90
96
url? . appendPathComponent ( endPoint)
@@ -100,7 +106,8 @@ public struct APIConfiguration<T,S> where T: ResponseBodyParsable, S: ErrorRespo
100
106
cachingTime: cachingTime,
101
107
isMainOperation: isMainOperation,
102
108
autoCache: autoCache,
103
- timeOut: timeOut)
109
+ timeOut: timeOut,
110
+ dateDecodingStrategy: dateDecodingStrategy)
104
111
}
105
112
106
113
/**
@@ -115,6 +122,7 @@ public struct APIConfiguration<T,S> where T: ResponseBodyParsable, S: ErrorRespo
115
122
- parameter body: Request body for the API request.
116
123
- parameter responseBodyObject: Type of the Response Object to create.
117
124
- parameter autoCache: To use that, override `cachingEndsAt:` method of Response Body Object.
125
+ - parameter dateDecodingStrategy: The JSON date decoding strategy. Default is `.defferedToDate`
118
126
Then specified custom caching will be applied for that request.
119
127
*/
120
128
public init ( url: URL ,
@@ -127,7 +135,8 @@ public struct APIConfiguration<T,S> where T: ResponseBodyParsable, S: ErrorRespo
127
135
cachingTime: NetworkLayer . CachingTime = NetworkLayer . CachingTime ( seconds: 60 * 60 ) ,
128
136
isMainOperation: Bool = false ,
129
137
autoCache: Bool = false ,
130
- timeOut: Int = 30 ) {
138
+ timeOut: Int = 30 ,
139
+ dateDecodingStrategy: JSONDecoder . DateDecodingStrategy = . deferredToDate) {
131
140
132
141
self . requestURL = url
133
142
self . requestType = requestType
@@ -140,6 +149,7 @@ public struct APIConfiguration<T,S> where T: ResponseBodyParsable, S: ErrorRespo
140
149
self . autoCache = autoCache
141
150
self . timeOut = timeOut
142
151
self . errorResponseBodyObject = errorType
152
+ self . dateDecodingStrategy = dateDecodingStrategy
143
153
}
144
154
145
155
/// Tries to create URL request by specified parameters.
@@ -204,6 +214,7 @@ public extension APIConfiguration where T: ResponseBodyParsable, S == DefaultAPI
204
214
- parameter body: Request body for the API request.
205
215
- parameter responseBodyObject: Type of the Response Object to create.
206
216
- parameter autoCache: To use that, override `cachingEndsAt:` method of Response Body Object.
217
+ - parameter dateDecodingStrategy: The JSON date decoding strategy. Default is `.defferedToDate`
207
218
Then specified custom caching will be applied for that request.
208
219
*/
209
220
init ? ( hostURL: String , endPoint: String ,
@@ -215,7 +226,8 @@ public extension APIConfiguration where T: ResponseBodyParsable, S == DefaultAPI
215
226
cachingTime: NetworkLayer . CachingTime = NetworkLayer . CachingTime ( seconds: 60 * 60 ) ,
216
227
isMainOperation: Bool = false ,
217
228
autoCache: Bool = false ,
218
- timeOut: Int = 30 ) {
229
+ timeOut: Int = 30 ,
230
+ dateDecodingStrategy: JSONDecoder . DateDecodingStrategy = . deferredToDate) {
219
231
220
232
self . init ( hostURL: hostURL,
221
233
endPoint: endPoint,
@@ -228,7 +240,8 @@ public extension APIConfiguration where T: ResponseBodyParsable, S == DefaultAPI
228
240
cachingTime: cachingTime,
229
241
isMainOperation: isMainOperation,
230
242
autoCache: autoCache,
231
- timeOut: timeOut)
243
+ timeOut: timeOut,
244
+ dateDecodingStrategy: dateDecodingStrategy)
232
245
}
233
246
234
247
/**
@@ -243,6 +256,7 @@ public extension APIConfiguration where T: ResponseBodyParsable, S == DefaultAPI
243
256
- parameter body: Request body for the API request.
244
257
- parameter responseBodyObject: Type of the Response Object to create.
245
258
- parameter autoCache: To use that, override `cachingEndsAt:` method of Response Body Object.
259
+ - parameter dateDecodingStrategy: The JSON date decoding strategy. Default is `.defferedToDate`
246
260
Then specified custom caching will be applied for that request.
247
261
*/
248
262
init ( url: URL ,
@@ -254,7 +268,8 @@ public extension APIConfiguration where T: ResponseBodyParsable, S == DefaultAPI
254
268
cachingTime: NetworkLayer . CachingTime = NetworkLayer . CachingTime ( seconds: 60 * 60 ) ,
255
269
isMainOperation: Bool = false ,
256
270
autoCache: Bool = false ,
257
- timeOut: Int = 30 ) {
271
+ timeOut: Int = 30 ,
272
+ dateDecodingStrategy: JSONDecoder . DateDecodingStrategy = . deferredToDate) {
258
273
259
274
self . init ( url: url,
260
275
requestType: requestType,
@@ -266,6 +281,7 @@ public extension APIConfiguration where T: ResponseBodyParsable, S == DefaultAPI
266
281
cachingTime: cachingTime,
267
282
isMainOperation: isMainOperation,
268
283
autoCache: autoCache,
269
- timeOut: timeOut)
284
+ timeOut: timeOut,
285
+ dateDecodingStrategy: dateDecodingStrategy)
270
286
}
271
287
}
0 commit comments