daily pastebin goal
17%
SHARE
TWEET

Untitled

a guest Jan 20th, 2017 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. struct RestfulApi {
  2.  
  3.     public static let sessionManager: SessionManager = {
  4.         var defaultHeaders = SessionManager.defaultHTTPHeaders
  5.         defaultHeaders["app-version"] = "1.0"
  6.         defaultHeaders["DNT"] = "1 (Do Not TrackEnabled)"
  7.  
  8.         let configuration = URLSessionConfiguration.default
  9.         configuration.httpAdditionalHeaders = defaultHeaders
  10.  
  11.         return SessionManager(configuration: configuration)
  12.     }()
  13.  
  14.     public func doLogin(username: String, password:String, deviceID: String) {
  15.         let parameters: Parameters = ["email": username,
  16.                                       "password": password,
  17.                                       "deviceID": deviceID]
  18.         RestfulApi.sessionManager.request(ServerConstants.getRestfulActionURL(action: .login), method: .post, parameters: parameters, encoding: JSONEncoding.default)
  19.             .response {
  20.                 response in
  21.                 log.verbose(response)
  22.             }
  23.     }
  24. }
  25.    
  26. DefaultDataResponse(request: Optional(https://example.com/signin), response: Optional(<NSHTTPURLResponse: 0x60000022ff60> { URL:
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top