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
import Foundation | |
struct User: Codable { | |
let id: String? | |
let name: String | |
let email: String | |
let phoneNumber: String | |
let password: String | |
let status: String? |
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
class NetworkRequest { | |
static let shared = NetworkRequest() | |
private init() {} | |
func fetchJson<T: Decodable>(method: String = "GET",withUrl url: URL,json: Data? = nil, completion: @escaping (T) -> Void, error: ((String) -> Void)? = nil ) { | |
var request = URLRequest(url: url) | |
request.httpMethod = method |
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
struct NetworkRequest<T: Decodable> { | |
public enum FetchResults { | |
case success(response: T) | |
case error(error: String) | |
} | |
static func fetchJson(with url: URL, completion: @escaping (FetchResults) -> Void) { | |