PayAPIClient

public class PayAPIClient

Manages and sends APIRequests

  • Undocumented

    Declaration

    Swift

    public static var `default`: PayAPIClient
  • A list of RequestBehaviours that can be used to monitor and alter all requests

    Declaration

    Swift

    public var behaviours: [PayAPIRequestBehaviour]
  • The base url prepended before every request path

    Declaration

    Swift

    public var baseURL: String
  • The UrlSession used for each request

    Declaration

    Swift

    public var session: URLSession
  • These headers will get added to every request

    Declaration

    Swift

    public var defaultHeaders: [String : String]
  • Undocumented

    Declaration

    Swift

    public var jsonDecoder: JSONDecoder
  • Undocumented

    Declaration

    Swift

    public var jsonEncoder: JSONEncoder
  • Undocumented

    Declaration

    Swift

    public var decodingQueue: DispatchQueue
  • Undocumented

    Declaration

    Swift

    public init(baseURL: String, configuration: URLSessionConfiguration = .default, defaultHeaders: [String : String] = [:], behaviours: [PayAPIRequestBehaviour] = [])
  • Makes a network request

    Declaration

    Swift

    @discardableResult
    public func makeRequest<T>(_ request: PayAPIRequest<T>, behaviours: [PayAPIRequestBehaviour] = [], completionQueue: DispatchQueue = DispatchQueue.main, complete: @escaping (PayAPIResponse<T>) -> Void) -> CancellablePayAPIRequest? where T : APIResponseValue

    Parameters

    request

    The API request to make

    behaviours

    A list of behaviours that will be run for this request. Merged with APIClient.behaviours

    completionQueue

    The queue that complete will be called on

    complete

    A closure that gets passed the PayAPIResponse

    Return Value

    A cancellable request. Not that cancellation will only work after any validation RequestBehaviours have run

  • Undocumented

    Declaration

    Swift

    static var custom: PayAPIClient