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
//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
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
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 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
<html>Simple <b>Java</b> application that includes a class with <code>main()</code> method</html> |
NewerOlder