Protocols
The following protocols are available globally.
-
A type that provides an interface to create requests to an API.
Overview
For each API, create a type that conforms to
RequestProviding
and implement the base URL of the API. Using this type you can createRequest
s for the different endpoints of the API using the construction methods provided by the protocol.You can optionally implement the
request(to:using:)
method to customize the default request provided by the other construction methods.See also
AnonymousRequestProvider
Declaration
Swift
public protocol RequestProviding
-
A type that can convert itself into a Foundation
URLRequest
.Overview
Conforming types provide all the information needed to create a
URLRequest
for aResource
from an API. The associatedResource
type is the type encoded in the body of the response to the request. Conforming types provide aResponseDecoder<Resource>
that is responsible for transforming the raw response data into the associatedResource
for the request.Conforming to the
RequestConvertible
ProtocolConforming to the
RequestConvertible
protocol requires you specify an associatedResource
type and declare:- The base URL for the request.
- The endpoint for the request.
- The HTTP method for the request.
- The decoder for the associated resource type.
Default implementations of other properties are provided using the values defined in
DefaultValue
. Where it can be inferred from theResource
type, a defaultResponseDecoder
is also provided.Note
If your request does not expect a response body, set the associatedResource
type toVoid
.Declaration
Swift
public protocol RequestConvertible : CustomStringConvertible