Last active
May 23, 2021 08:01
-
-
Save bharathreddys77/b7e0a810b002ce35bbbd7e0f2f3a01c6 to your computer and use it in GitHub Desktop.
Create a network protocol which will be the blue print of all API methods. This file also has a network error Error type which provides possible fails of the API.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol NetworkingController { | |
func loginUser(request:LoginRequest,completion:@escaping(_ result:Result<LoginResponse,NetworkControllerError>) -> Void) | |
func forgotPassword(request:ForgotPasswordRequest,completion:@escaping(_ result:Result<ForgotPwdResponse,NetworkControllerError>) -> Void) | |
} | |
enum NetworkControllerError:Error { | |
case Non200StatusCodeError(NetworkError) | |
case NoNetworkError | |
case BadURLError | |
case UnParsableError | |
case UnknownError | |
case NoDataAvailableInResponseError | |
case customError(message:String) | |
} | |
struct NetworkError:Decodable { | |
let message:Bool? | |
let error:String? | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment