Client
open class Client: NSObject, URLSessionDataDelegate
                A Client handles HTTP requests, cookie management, and logging in to Stack Exchange chat.
- 
                  
                  
Undocumented
Declaration
Swift
open class Client: NSObject, URLSessionDataDelegate - 
                  
                  
Pretty self explanatory
Declaration
Swift
open var cookies = [HTTPCookie]() - 
                  
                  
Indicates whether the client is logged in or not.
Declaration
Swift
open var loggedIn = false - 
                  
                  
Errors which can happen while making a request
See moreDeclaration
Swift
public enum RequestError: Error - 
                  
                  
Indicates the duration of a timeout
Declaration
Swift
open var timeoutDuration: TimeInterval = 30 
- 
                  
                  
Adds cookies.
Declaration
Swift
open func addCookies(_ newCookies: [HTTPCookie], forHost host: String)Parameters
newCookiesThe cookies to add.
hostThe host which set the cookies..
 - 
                  
                  
Checks whether a cookie matches a domain.
Declaration
Swift
open func cookieHost(_ host: String, matchesDomain domain: String) -> BoolParameters
hostThe host of the cookie.
domainThe domain.
 - 
                  
                  
Returns the cookie headers for the specified URL.
Declaration
Swift
open func cookieHeaders(forURL url: URL) -> [String:String] 
- 
                  
                  
Undocumented
Declaration
Swift
open class Client: NSObject, URLSessionDataDelegate - 
                  
                  
Undocumented
Declaration
Swift
open class Client: NSObject, URLSessionDataDelegate - 
                  
                  
Undocumented
Declaration
Swift
open class Client: NSObject, URLSessionDataDelegate - 
                  
                  
Undocumented
Declaration
Swift
open class Client: NSObject, URLSessionDataDelegate 
- 
                  
                  
Performs an
URLRequest.Declaration
Swift
open func performRequest(_ request: URLRequest) throws -> (Data, HTTPURLResponse)Parameters
requestThe request to perform.
Return Value
The
DataandHTTPURLResponsereturned by the request. - 
                  
                  
Performs a GET request.
- paramter url: The URL to make the request to.
 
Declaration
Swift
open func get(_ url: String) throws -> (Data, HTTPURLResponse)Return Value
The
DataandHTTPURLResponsereturned by the request. - 
                  
                  
Performs a POST request.
Declaration
Swift
open func post(_ url: String, data: Data, contentType: String? = nil) throws -> (Data, HTTPURLResponse)Parameters
urlThe URL to make the request to.
dataThe body of the POST request.
Return Value
The
DataandHTTPURLResponsereturned by the request. - 
                  
                  
Performs a POST request.
Declaration
Swift
open func post(_ url: String, _ data: [String:String]) throws -> (Data, HTTPURLResponse)Parameters
urlThe URL to make the request to.
dataThe fields to include in the POST request.
Return Value
The
DataandHTTPURLResponsereturned by the request. - 
                  
                  
Performs an URLRequest.
Declaration
Swift
open func performRequest(_ request: URLRequest) throws -> StringParameters
requestThe request to perform.
Return Value
The UTF-8 string returned by the request.
 - 
                  
                  
Performs a GET request.
- paramter url: The URL to make the request to.
 
Declaration
Swift
open func get(_ url: String) throws -> StringReturn Value
The UTF-8 string returned by the request.
 - 
                  
                  
Performs a POST request.
Declaration
Swift
open func post(_ url: String, _ fields: [String:String]) throws -> StringParameters
urlThe URL to make the request to.
dataThe fields to include in the POST request.
Return Value
The UTF-8 string returned by the request.
 - 
                  
                  
Performs a POST request.
Declaration
Swift
open func post(_ url: String, data: Data, contentType: String? = nil) throws -> StringParameters
urlThe URL to make the request to.
dataThe body of the POST request.
Return Value
The UTF-8 string returned by the request.
 - 
                  
                  
Parses a JSON string.
Declaration
Swift
open func parseJSON(_ json: String) throws -> Any 
- 
                  
                  
Initializes a Client.
Declaration
Swift
override public init()Parameters
hostThe chat host to log in to.
 - 
                  
                  
Errors which can occur while logging in.
See moreDeclaration
Swift
public enum LoginError: Error - 
                  
                  
Logs in to Stack Exchange.
Declaration
Swift
open func login(email: String, password: String) throws 
        Client Class Reference