Request

public struct Request<Model> : Requestable where Model : Decodable

Request representation returned by CoinpaprikaAPI methods. To perform request use .perform() method. It will call callback with error reason or

  • Declaration

    Swift

    public enum Method : String
  • Declaration

    Swift

    public typealias Params = [String : Any]
  • Declaration

    Swift

    public enum BodyEncoding
  • Declaration

    Swift

    public enum AuthorisationMethod
  • Request initializer that may be used if you want to extend client API with another methods

    Declaration

    Swift

    public init(baseUrl: URL, method: Method, path: String, params: Params?, userAgent: String = "Coinpaprika API Client - Swift", bodyEncoding: BodyEncoding = .json, authorisation: AuthorisationMethod = .none)

    Parameters

    baseUrl

    Base URL containing base path for API, like https://api.coinpaprika.com/v1/

    method

    HTTP Method

    path

    endpoint path like tickers/btc-bitcoin

    params

    array of parameters appended in URL Query

  • Perform API request

    Declaration

    Swift

    public func perform(responseQueue: DispatchQueue? = nil, cachePolicy: URLRequest.CachePolicy? = nil, _ callback: @escaping (Result<Model, Error>) -> Void)

    Parameters

    responseQueue

    The queue on which the completion handler is dispatched

    cachePolicy

    cache policy that should be used in this request

    callback

    Completion handler triggered on request success & failure

  • Declaration

    Swift

    public var description: String { get }