@@ -46,8 +46,8 @@ internal struct StudyplusAPIRequest {
46
46
} , failure: { statusCode, response in
47
47
48
48
DispatchQueue . main. async {
49
- if let message: String = response ? [ " message " ] as? String , let error = StudyplusError ( statusCode , message ) {
50
- failure ( error )
49
+ if let message: String = response ? [ " message " ] as? String {
50
+ failure ( StudyplusError ( statusCode , message ) )
51
51
} else {
52
52
failure ( . unknownReason( " Not connected to the network or StudyplusAPIRequest Error " ) )
53
53
}
@@ -88,37 +88,37 @@ internal struct StudyplusAPIRequest {
88
88
if httpResponse. statusCode == 200 || httpResponse. statusCode == 201 || httpResponse. statusCode == 202 {
89
89
90
90
if let data = data {
91
- do {
92
- let jsonObject = try JSONSerialization . jsonObject ( with: data, options: . allowFragments)
93
- success ( jsonObject as? [ String : Any ] )
94
- return
95
- } catch {
96
- #if DEBUG
97
- print ( " -- StudyplusAPIRequest Json Error Path: \( url. absoluteString) , Method: \( method) , Description: \( error. localizedDescription) -- " )
98
- #endif
99
- failure ( httpResponse. statusCode, [ " message " : error. localizedDescription] )
100
- }
91
+ do {
92
+ let jsonObject = try JSONSerialization . jsonObject ( with: data, options: . allowFragments)
93
+ success ( jsonObject as? [ String : Any ] )
94
+ return
95
+ } catch {
96
+ #if DEBUG
97
+ print ( " -- StudyplusAPIRequest Json Error Path: \( url. absoluteString) , Method: \( method) , Description: \( error. localizedDescription) -- " )
98
+ #endif
99
+ failure ( httpResponse. statusCode, [ " message " : error. localizedDescription] )
100
+ }
101
101
}
102
102
103
103
} else if httpResponse. statusCode == 204 {
104
- success ( nil )
105
- return
104
+ success ( nil )
105
+ return
106
106
107
107
} else {
108
- #if DEBUG
109
- print ( " -- StudyplusAPIRequest Path: \( url. absoluteString) , Method: \( method) , StatusCode: \( httpResponse. statusCode) -- " )
110
- #endif
108
+ #if DEBUG
109
+ print ( " -- StudyplusAPIRequest Path: \( url. absoluteString) , Method: \( method) , StatusCode: \( httpResponse. statusCode) -- " )
110
+ #endif
111
111
if let data = data {
112
- do {
113
- let jsonObject = try JSONSerialization . jsonObject ( with: data, options: . allowFragments)
114
- failure ( httpResponse. statusCode, jsonObject as? [ String : Any ] )
115
- return
116
-
117
- } catch let jsonError {
118
- failure ( httpResponse. statusCode, [ " message " : jsonError. localizedDescription] )
119
- }
120
- }
121
- }
112
+ do {
113
+ let jsonObject = try JSONSerialization . jsonObject ( with: data, options: . allowFragments)
114
+ failure ( httpResponse. statusCode, jsonObject as? [ String : Any ] )
115
+ return
116
+
117
+ } catch let jsonError {
118
+ failure ( httpResponse. statusCode, [ " message " : jsonError. localizedDescription] )
119
+ }
120
+ }
121
+ }
122
122
}
123
123
}
124
124
0 commit comments