ServiceRequest

open class ServiceRequest : Request

Class represents HTTP Request to Virgil Service

  • HTTP header key for Authorization

    Declaration

    Swift

    public static let accessTokenHeader: String
  • HTTP header prefix for Virgil JWT

    Declaration

    Swift

    public static let accessTokenPrefix: String
  • Initializer

    Throws

    • ServiceRequestError.getQueryWithDecodableIsNotSupported, if GET query with params
    • Rethrows from JSONEncoder

    Declaration

    Swift

    public init<T: Encodable>(url: URL, method: Method, params: T? = nil,
                              headers: [String: String] = [:]) throws

    Parameters

    url

    Request url

    method

    Request method

    accessToken

    Access token

    params

    Encodable request body

    headers

    Http headers

  • Initializer

    Throws

    • ServiceRequestError.invalidGetRequestParameters, if GET request is initialized and params are not [String: String]
    • ServiceRequestError.urlComponentsConvertingFailed, if error occured while building url from components during GET request
    • Rethrows from JSONSerialization

    Declaration

    Swift

    public init(url: URL, method: Method, params: Any? = nil,
                headers: [String: String] = [:]) throws

    Parameters

    url

    Request url

    method

    Request method

    accessToken

    Access token

    params

    JSON-encodable object

    headers

    Http headers

  • Undocumented

    Declaration

    Swift

    public func setAccessToken(_ accessToken: String)