Request
open class Request<Parameters> : Validatable where Parameters : Encodable
The Request class should be inherited by any class that represents an API
request and sent through the send function in Session.
Only classes that aren’t expecting any data back in the response should
directly inherit this class. If data is expected, then ModeledRequest
should be used instead.
-
A
Boolindicating if the request supports theOn-behalf-of
header.Declaration
Swift
open var supportsImpersonation: Bool { get } -
The HTTP verb to use in the call.
Declaration
Swift
open var method: HTTPMethod -
The headers to be included in the request.
Declaration
Swift
open var headers: [String : String] -
The decoding strategy.
Declaration
Swift
open var decodingStrategy: DecodingStrategy -
The encoding strategy.
Declaration
Swift
open var encodingStrategy: EncodingStrategy -
The path component of the API endpoint. This should start with a
/, for example/v3/mail/send
.Declaration
Swift
open var path: String -
The parameters that should be sent with the API call. These parameters will either be encoded into the body of the request or the query items of the request
Declaration
Swift
open var parameters: Parameters?
-
Initializes the request.
Declaration
Swift
public init(method: HTTPMethod, path: String, parameters: Parameters? = nil, encodingStrategy: EncodingStrategy = EncodingStrategy(), decodingStrategy: DecodingStrategy = DecodingStrategy())Parameters
methodThe HTTP verb to use in the API call.
parametersOptional parameters to include in the API call.
pathThe path portion of the API endpoint, such as
/v3/mail/send
. The path must start with a forward slash (/).parametersOptional parameters to include in the API call.
encodingThe encoding strategy for the parameters.
decodingThe decoding strategy for the response.
-
Retrieves a the value of a specific header, or
nilif it doesn’t exist.Declaration
Swift
open func headerValue(named name: String) -> String?Parameters
nameThe name of the header to look for.
Return Value
The value, or
nilif it doesn’t exist. -
Validates that the content and accept types are valid.
Declaration
Swift
open func validate() throws -
Before a
Sessioninstance makes an API call, it will call this method to double check that the auth method it’s about to use is supported by the endpoint. In general, this will always returntrue, however some endpoints, such as the mail send endpoint, only support API keys.Declaration
Swift
open func supports(auth: Authentication) -> BoolParameters
authThe
Authenticationinstance that’s about to be used.Return Value
A
Boolindicating if the authentication method is supported.
-
The description of the request, represented as an API Blueprint
Declaration
Swift
public var description: String { get }
View on GitHub
Request Class Reference