Skip to content

arzrasel/AlamofireKit

Repository files navigation

AlamofireKit

Rz Rasel CI Status Version License Platform GitHub release Swift Xcode

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • iOS 11
  • Swift 5
  • Xcode 12

Installation

AlamofireKit is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'AlamofireKit'

or

pod 'AlamofireKit', '~> 1.0'

Integration In Project

import AlamofireKit

HTTP Request

AlamofireKit.request({ (success, data, error) in
    if success {
        guard let data = data else {
            return
        }
        self.apiModel = data
    } else {
        print("ERROR: \(String(describing: error))")
    }
}, dataModel: ApiModel.self, "https://api-url", method: .get, parameters: parameters)
let alamofireKit = AlamofireKit()
    .headers(headers: ["Authorization": self.rawUserLoginInfo.token])
    .addParameter(key: "type", value: "AVATAR")
    .method(method: .post)
    .withImageName(imageName: "file")
    .withImageFileName(imageFileName: "file.jpg")
    .withUIButton(uiButton: self.userImageButton, imageQuality: 100)
alamofireKit.uploadImage({success, data, error in
    if success {
        print("DATA: \(data?.jsonString())")
    }
}, dataModel: ModelApiRootUploadImage.self, "https://api-url", cropSize: CGSize(width: 512, height: 512))

Author

Md. Rashed - Uz - Zaman (Rz Rasel)

License

AlamofireKit is available under the MIT license. See the LICENSE file for more info.