Skip to content

Latest commit

 

History

History
76 lines (48 loc) · 1.47 KB

README.md

File metadata and controls

76 lines (48 loc) · 1.47 KB

AlamofireHelperLayer

Very Clean and managed structure

Helper to Call Webservice with ease (You need approx 15 Mins to make it run)

How to install

  1. Drag and drop API Helpers in your project
  2. 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": "tukadiyaprashant@gmail.com",
 	 "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 ?

Donation

If this project help you reduce time to develop, you can give me a cup of coffee :)

paypal