WLResourceRequestSwift

public class WLResourceRequestSwift : NSObject

This class encapsulates a resource request. The resource may be an adapter on the MobileFirst server, or an external resource. The class provides several ‘send’ methods, with different inputs for the body of a request.

  • GET constant for the request method

    Declaration

    Swift

    public static let WLHttpMethodGet: String
  • POST constant for the request method

    Declaration

    Swift

    public static let WLHttpMethodPost: String
  • PUT constant for the request method

    Declaration

    Swift

    public static let WLHttpMethodPut: String
  • DELETE constant for the request method

    Declaration

    Swift

    public static let WLHttpMethodDelete: String
  • Undocumented

    Declaration

    Swift

    override init()
  • Creates an instance of WLResourceRequestSwift with the specified URL and method

    Declaration

    Swift

    public init(url: URL, method: String)

    Parameters

    url

    URL of the request (full or relative to MobileFirst Server)

    method

    Method of the request (POST, GET,…)

  • Creates an instance of WLResourceRequestSwift with the specified URL, method and scope

    Declaration

    Swift

    public init(url: URL, method: String, scope: String)

    Parameters

    url

    URL of the request (full or relative to MobileFirst Server)

    method

    Method of the request (POST, GET,…)

    scope

    The scope that this protected resource requires

  • Creates an instance of WLResourceRequestSwift with the specified URL, method and timeout

    Declaration

    Swift

    public init(url: URL, method: String, timeout: TimeInterval)

    Parameters

    url

    URL of the request (full or relative to MobileFirst Server)

    method

    Method of the request (POST, GET,…)

    timeout

    Timeout for the request in seconds

  • Creates an instance of WLResourceRequestSwift with the specified URL, method, timeout and scope.

    Declaration

    Swift

    public init(url: URL, method: String, timeout: TimeInterval, scope: String)

    Parameters

    url

    URL of the request (full or relative to MobileFirst Server)

    method

    Method of the request (POST, GET,…)

    timout

    Timeout for the request in seconds

    scope

    The scope that this protected resource requires

  • Sets query parameter value

    If the query parameter with the same name already exists, it is overridden.

    Declaration

    Swift

    public func setQueryParameterValue(parameterValue: String, forName: String)

    Parameters

    parameterValue

    Parameter value

    forName

    Parameter name

  • Returns the query parameters as string

    Declaration

    Swift

    public func getQueryString() -> String

    Return Value

    Query parameter

  • Returns header names as an array of strings

    Declaration

    Swift

    public func headerNames() -> Array<Any>

    Return Value

    Returns the header names as array

  • Returns header name as an array of strings

    For a single header name, there can be several values separated by commas. If there is only one value, the method returns an array with one element.

    Declaration

    Swift

    public func headers(forName: String) -> Array<Any>

    Parameters

    forName

    Header name

  • Returns first header with matching name

    Declaration

    Swift

    public func header(forName: String) -> String

    Parameters

    forName

    Name of the header

  • Sets the header for the request

    Declaration

    Swift

    public func setHeaderValue(value: NSObject, forName: String)

    Parameters

    value

    Header value

    forName

    Header name

  • Adds the header to the request

    If a header with the same name already exists, the values are concatenated and separated by commas.

    Note: The header name is case insensitive.

    Declaration

    Swift

    public func addHeaderValue(value: NSObject, forName: String)

    Parameters

    value

    Header value

    forName

    Header name

  • Removes the header from the request

    Declaration

    Swift

    public func removeHeaders(forName: String)

    Parameters

    forName

    Header name

  • Sends a request and uses the closure callback to handle the response

    Declaration

    Swift

    public func send(onCompletion: @escaping(WLResponseSwift?,Error?) -> Void)

    Parameters

    onCompletion

    Closure with WLResponseSwift and Error gets called when a response has been recieved.

  • Sends a request and uses the closure callback to handle the response.

    Declaration

    Swift

    public func send(withQueue:DispatchQueue ,onCompletion: @escaping(WLResponseSwift?,Error?) -> Void)

    Parameters

    withQueue

    Private queue to specify callback queue for closure block

    onCompletion

    Closure with WLResponseSwift and Error gets called when a response has been recieved.

  • Sends a request and uses a delegate to handle the response

    Declaration

    Swift

    public func send(withDelegate: Any)

    Parameters

    withDelegate

    Delegate that conforms to both NSURLSessionDataDelegate and NSURLSessionTaskDelegate protocols. Note: The delegate must implement both NSURLSessionDataDelegate and NSURLSessionTaskDelegate protocols.

  • Sends a request and uses a delegate to handle the response

    Declaration

    Swift

    public func send(responseQueue: DispatchQueue, withDelegate: Any)

    Parameters

    responseQueue

    Private queue to specify callback queue for delegate

    withDelegate

    Delegate that conforms to both NSURLSessionDataDelegate and NSURLSessionTaskDelegate protocols. Note: The delegate must implement both NSURLSessionDataDelegate and NSURLSessionTaskDelegate protocols.

  • Sends a request with the provided text as a request body and uses a completionHandler block to handle the response

    Declaration

    Swift

    public func send(withBody:String, onCompletion: @escaping(WLResponseSwift?,Error?) -> Void)

    Parameters

    withBody

    Request body. Note: Using methods other than POST or PUT will omit the request body.

    onCompletion

    Closure with WLResponseSwift and Error gets called when a response has been recieved.

  • Sends a request with the provided text as a request body and uses a completionHandler block to handle the response

    Declaration

    Swift

    public func send(withBody:String, responseQueue:DispatchQueue, onCompletion: @escaping(WLResponseSwift?,Error?) -> Void)

    Parameters

    withBody

    Request body. Note: Using methods other than POST or PUT will omit the request body.

    responseQueue

    Private queue to specify callback queue for closure block

    onCompletion

    Closure with WLResponseSwift and Error gets called when a response has been recieved. Note: Using methods other than POST or PUT will omit the request body.

  • Sends a request with the provided text as a request body and uses a delegate to handle the response

    Declaration

    Swift

    public func send(withBody: String, delegate: Any)

    Parameters

    withBody

    Request body. Note: Using methods other than POST or PUT will omit the request body.

    delegate

    Delegate that conforms to both NSURLSessionDataDelegate and NSURLSessionTaskDelegate protocols. Note: The delegate must implement both NSURLSessionDataDelegate and NSURLSessionTaskDelegate protocols.

  • Sends a request with the provided text as a request body and uses a delegate to handle the response

    Declaration

    Swift

    public func send(withBody: String, responseQueue: DispatchQueue, delegate: Any)

    Parameters

    withBody

    Request body. Note: Using methods other than POST or PUT will omit the request body.

    responseQueue

    Private queue to specify callback queue for delegate

    delegate

    Delegate that conforms to both NSURLSessionDataDelegate and NSURLSessionTaskDelegate protocols. Note: The delegate must implement both NSURLSessionDataDelegate and NSURLSessionTaskDelegate protocols.

  • Sends a request with form parameters as a request body and uses a closure block to handle the response

    Declaration

    Swift

    public func send(withFormParameters:[AnyHashable : Any], onCompletion: @escaping(WLResponseSwift?,Error?) -> Void )

    Parameters

    withFormParameters

    Dictionary of form parameters. Note: Using methods other than POST or PUT will omit the request body.

    onCompletion

    Closure with WLResponseSwift and Error gets called when a response has been recieved.

  • Sends a request with form parameters as a request body and uses a closure block to handle the response

    Declaration

    Swift

    public func send(withFormParameters:[AnyHashable : Any], responseQueue:DispatchQueue, onCompletion: @escaping(WLResponseSwift?,Error?) -> Void)

    Parameters

    withFormParameters

    Dictionary of form parameters. Note: Using methods other than POST or PUT will omit the request body.

    responseQueue

    Private queue to specify callback queue for closure

    onCompletion

    Closure with WLResponseSwift and Error gets called when a response has been recieved.

  • Sends a request with form parameters as a request body and uses a delegate to handle the response

    Declaration

    Swift

    public func send(withFormParameters: [AnyHashable : Any], delegate: Any)

    Parameters

    withFormParameters

    Dictionary of form parameters. Note: Using methods other than POST or PUT will omit the request body.

    delegate

    Delegate that conforms to both NSURLSessionDataDelegate and NSURLSessionTaskDelegate protocols. Note: The delegate must implement both NSURLSessionDataDelegate and NSURLSessionTaskDelegate protocols.

  • Sends a request with form parameters as a request body and uses a delegate to handle the response

    Declaration

    Swift

    public func send(withFormParameters: [AnyHashable : Any], responseQueue: DispatchQueue, delegate: Any)

    Parameters

    withFormParameters

    Dictionary of form parameters

    responseQueue

    Private queue to specify callback queue for delegate

    delegate

    Delegate that conforms to both NSURLSessionDataDelegate and NSURLSessionTaskDelegate protocols. Note: The delegate must implement both NSURLSessionDataDelegate and NSURLSessionTaskDelegate protocols.

  • Sends a request with the provided JSON and uses a closure block to handle the response

    Declaration

    Swift

    public func send(withJSON:[AnyHashable : Any] ,  onCompletion: @escaping(WLResponseSwift?,Error?) -> Void)

    Parameters

    withJSON

    Json Data. Note: Using methods other than POST or PUT will omit the request body.

    onCompletion

    Closure with WLResponseSwift and Error gets called when a response has been recieved.

  • Sends a request with the provided JSON and uses a closure block to handle the response

    Declaration

    Swift

    public func send(withJSON:[AnyHashable : Any] ,responseQueue: DispatchQueue, onCompletion: @escaping(WLResponseSwift?,Error?) -> Void)

    Parameters

    withJSON

    Json Data. Note: Using methods other than POST or PUT will omit the request body.

    responseQueue

    Private queue to specify callback queue for closure

    onCompletion

    Closure with WLResponseSwift and Error gets called when a response has been recieved.

  • Sends a request with the provided JSON and uses a delegate to handle the response

    Declaration

    Swift

    public func send(withJSON: [AnyHashable : Any], delegate: Any)

    Parameters

    withJSON

    Json Data. Note: Using methods other than POST or PUT will omit the request body.

    delegate

    Delegate that conforms to both NSURLSessionDataDelegate and NSURLSessionTaskDelegate protocols. Note: The delegate must implement both NSURLSessionDataDelegate and NSURLSessionTaskDelegate protocols.

  • Sends a request with the provided JSON and uses a delegate to handle the response

    Declaration

    Swift

    public func send(withJSON: [AnyHashable : Any], responseQueue: DispatchQueue, delegate: Any)

    Parameters

    withJSON

    Json Data. Note: Using methods other than POST or PUT will omit the request body.

    responseQueue

    Private queue to specify callback queue for delegate

    delegate

    Delegate that conforms to both NSURLSessionDataDelegate and NSURLSessionTaskDelegate protocols. Note: The delegate must implement both NSURLSessionDataDelegate and NSURLSessionTaskDelegate protocols.

  • Sends a request with the provided request data and uses a closure block to handle the response.

    Declaration

    Swift

    public func send(withData:Data , onCompletion: @escaping(WLResponseSwift?,Error?) -> Void)

    Parameters

    withData

    Request Data. Note: Using methods other than POST or PUT will omit the request body.

    responseQueue

    Private queue to specify callback queue for closure

    onCompletion

    Closure with WLResponseSwift and Error gets called when a response has been recieved.

  • Sends a request with the provided request data and uses a closure block to handle the response.

    Declaration

    Swift

    public func send(withData:Data ,responseQueue:DispatchQueue, onCompletion: @escaping(WLResponseSwift?,Error?) -> Void)

    Parameters

    withData

    Request Data. Note: Using methods other than POST or PUT will omit the request body.

    responseQueue

    Private queue to specify callback queue for closure

    onCompletion

    Closure with WLResponseSwift and Error gets called when a response has been recieved.

  • Sends a request with the provided request data and uses a delegate to handle the response

    Declaration

    Swift

    public func send(withData: Data, delegate: Any)

    Parameters

    withData

    Request Data. Note: Using methods other than POST or PUT will omit the request body.

    delegate

    Delegate that conforms to both NSURLSessionDataDelegate and NSURLSessionTaskDelegate protocols. Note: The delegate must implement both NSURLSessionDataDelegate and NSURLSessionTaskDelegate protocols.

  • Sends a request with the provided request data and uses a delegate to handle the response

    Declaration

    Swift

    public func send(withData: Data, responseQueue: DispatchQueue, delegate: Any)

    Parameters

    withData

    Request Data. Note: Using methods other than POST or PUT will omit the request body.

    responseQueue

    Private queue to specify callback queue for delegate

    delegate

    Delegate that conforms to both NSURLSessionDataDelegate and NSURLSessionTaskDelegate protocols. Note: The delegate must implement both NSURLSessionDataDelegate and NSURLSessionTaskDelegate protocols.