Created
June 13, 2018 20:50
-
-
Save ARamy23/7fe16d8d868b0fdfa9a0ff21e9dd34be to your computer and use it in GitHub Desktop.
This file contains hidden or 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
enum UserRequest: URLRequestBuilder { | |
case login(email: String, password: String) | |
case register(name: String, email: String, password: String, phone: String) | |
case userInfo | |
// MARK: - Path | |
internal var path: ServerPaths { | |
switch self { | |
case .login: | |
return .login | |
case .register: | |
return .register | |
case .userInfo: | |
return .userInfo | |
} | |
} | |
// MARK: - Parameters | |
internal var parameters: Parameters? { | |
var params = defaultParams | |
switch self { | |
case .login(let email, let password): | |
params["email"] = email | |
params["password"] = password | |
case let .register(fullname, email, password, phone): | |
params["email"] = email | |
params["password"] = password | |
params["password_confirmation"] = password | |
params["phone"] = phone | |
params["name"] = fullname | |
params["mobile_id"] = deviceId | |
default: break | |
} | |
return params | |
} | |
// MARK: - Methods | |
internal var method: HTTPMethod { | |
return .post | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment