|
|
@ -18,17 +18,18 @@ public class EventsRest { |
|
|
|
completion(.failure(AnyError(response.error!))) |
|
|
|
completion(.failure(AnyError(response.error!))) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
guard let jsonData = response.data else { |
|
|
|
// TODO: Fix this |
|
|
|
completion(.failure(AnyError(RestError.invalidResponse("JSON is invalid")))) |
|
|
|
// guard let jsonData = response.data else { |
|
|
|
return |
|
|
|
// completion(.failure(AnyError(RestError.invalidResponse("JSON is invalid")))) |
|
|
|
} |
|
|
|
// return |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
if 200...299 ~= statusCode { // success |
|
|
|
if 200...299 ~= statusCode { // success |
|
|
|
guard let events: [Event] = Event.from(data: jsonData) else { |
|
|
|
// guard let events: [Event] = Event.from(data: jsonData) else { |
|
|
|
completion(.failure(AnyError(RestError.invalidResponse("Could not parse data")))) |
|
|
|
// completion(.failure(AnyError(RestError.invalidResponse("Could not parse data")))) |
|
|
|
return |
|
|
|
// return |
|
|
|
} |
|
|
|
// } |
|
|
|
completion(.success(events)) |
|
|
|
completion(.success([])) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
completion(.failure(AnyError(RestError.invalidResponse("Could not parse data")))) |
|
|
|
completion(.failure(AnyError(RestError.invalidResponse("Could not parse data")))) |
|
|
|
} |
|
|
|
} |
|
|
|