SkillAgentSearch skills...

WebService

Basic HTTP request classes in Swift

Install / Use

/learn @kansaraprateek/WebService
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

WebService

[![CI Status](http://img.shields.io/travis/Prateek Kansara/WebService.svg?style=flat)](https://travis-ci.org/Prateek Kansara/WebService) Version License Platform

Requirements

  • iOS 8.0+
  • Xcode 7.3.1+

Installation

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

pod "WebService"

##Usage

// Import webService class


import WebService

// Basic Header Dictionary


var httpHeaderRequestDict : NSMutableDictionary!{
    get{
        let mutableDict : NSMutableDictionary = NSMutableDictionary()
        mutableDict.setValue("AUTHKEY", forKey: "Authorization")
        mutableDict.setValue("application/json", forKey: "Content-Type")
        return mutableDict
    }
}

// Create webService object
    var webServiceObject : WebService = WebService()
    
// Set header value for all request
    webServiceObject.setDefaultHeaders(httpHeaderRequestDict)



*  use webServiceObject.httpHeaders to set different headers required for this call.


webServiceObject.sendRequest(URLString, parameters: params, requestType: .GET, success: {
(response : NSHTTPURLResponse?, dictionary : AnyObject) in

// Handle data when request Success

}, failed: {
(response : NSHTTPURLResponse?, ResponseDict : AnyObject?) in

// Handle data when request fails

}, encoded: false)

Example

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

Author

Prateek Kansara, prateek@kansara.in

License

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

View on GitHub
GitHub Stars5
CategoryDevelopment
Updated5y ago
Forks1

Languages

Swift

Security Score

70/100

Audited on Jun 26, 2020

No findings