How to install
- Drag and drop API Helpers in your project
- Goto APIRouter and add your webservice caes like added in example for login
Call like below
For Json
{
"Message": "Login Success",
"Status": true,
"Data": {
"Username": "[email protected]",
"IsvalidUser": "True",
"token": "isrpe"
}
}
Optional Create Codable general class
import Foundation
struct GeneralResponse<T:Codable>: Codable {
let message: String
let status: Bool
let data: T
enum CodingKeys: String, CodingKey {
case message = "Message"
case status = "Status"
case data = "Data"
}
}
And Create Your API Codable Class I used https://app.quicktype.io/
import Foundation
struct User: Codable {
let username, isvalidUser, token: String
enum CodingKeys: String, CodingKey {
case username = "Username"
case isvalidUser = "IsvalidUser"
case token
}
}
Call it with
func callWSToLogin() {
APIClient.login(userName: "test", password: "test") { (test:GeneralResponse<User>?, error:Error?) in
}
}
Easy right ?
If this project help you reduce time to develop, you can give me a cup of coffee :)