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
<html>Simple <b>Java</b> application that includes a class with <code>main()</code> method</html> |
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 Constants: String | |
{ | |
case mainURLString = "https://dev.wifimetropolis.com:8060/api/" | |
case voucherEndPoint = "getVouchers?user_id=AHP100-7605-1" | |
case threadsEndPoint = "messaging/threads" | |
} |
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
func getData<T: Codable>(endpoint: String, method: HTTPMethod?, params: [String: Any]?, headers: [String: String]?, model: T.Type, completion: @escaping (T?, URLResponse?, Error?) -> Void) | |
{ | |
//1 | |
guard let url = URL(string: Constants.mainURLString.rawValue + endpoint) else {print("error with creating url"); return;} | |
var request = URLRequest(url: url) | |
//2 | |
request.httpMethod = method?.rawValue ?? "GET" | |
//3 |
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 HTTPMethod: String | |
{ | |
case get = "GET" | |
case post = "POST" | |
case delete = "DELETE" | |
} |
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
//1 | |
enum TodoRouter: URLRequestConvertible { | |
//2 | |
static let baseURLString = "https://jsonplaceholder.typicode.com/" | |
//3 | |
case get(Int) | |
case create([String: Any]) | |
case delete(Int) | |
func asURLRequest() throws -> URLRequest { |
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
import Foundation | |
import Alamofire | |
protocol URLRequestBuilder: URLRequestConvertible { | |
var mainURL: URL { get } | |
var requestURL: URL { get } | |
// MARK: - Path | |
var path: ServerPaths { get } |
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 ServerPaths: String { | |
case login | |
case register | |
case phoneActivation = "phone_activation" | |
case resendPhoneActivation = "resend_phone_activation_code" | |
case resendEmailLink = "send_reset_link_email" | |
case resetPassword = "reset_password" | |
case userInfo = "get_account_info" | |
case updateInfo = "update_account_info" | |
case userBalance = "get_user_internal_balance" |
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: |
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 { | |
// 1 | |
case login(email: String, password: String) | |
case register(name: String, email: String, password: String, phone: String) | |
case userInfo | |
// MARK: - Path | |
internal var path: ServerPaths { | |
// 2 |
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
/// Response completion handler beautified. | |
typealias CallResponse<T> = ((ServerResponse<T>) -> Void)? | |
/// API protocol, The alamofire wrapper | |
protocol APIRequestHandler: HandleAlamoResponse { | |
/// Calling network layer via (Alamofire), this implementation can be replaced anytime in one place which is the protocol itself, applied anywhere. |
OlderNewer