APIotaCodableEndpoint
public protocol APIotaCodableEndpoint
Defines an API endpoint for a Client.
The definition must include a path
and a httpMethod
.
It can also optionaly include definitions for headers
, httpBody
and queryItems
.
-
A type alias for the decoded object for the successful response to a
URLRequest
.Declaration
Swift
associatedtype SuccessResponse : Decodable
-
A type alias for the decoded object for the error response to a
URLRequest
.Declaration
Swift
associatedtype ErrorResponse : Decodable
-
A type alias for the encoded data attached to the body of a
URLRequest
.Declaration
Swift
associatedtype Body : Encodable
-
A
JSONEncoder
to use for encoding body data to the requests generated by the receiver.Declaration
Swift
var encoder: JSONEncoder { get }
-
A
HTTPHeaders
instance used for configuring the HTTP headers attached to an initializedURLRequest
generated by the endpoint.Declaration
Swift
var headers: HTTPHeaders? { get }
-
A
HTTPMethod
to use when initializing aURLRequest
generated by the endpoint.Declaration
Swift
var httpMethod: HTTPMethod { get }
-
A
String
defining thepath
component of the endpoint URL (i.e. appended after thehost
component).Declaration
Swift
var path: String { get }
-
An optional array of
URLQueryItem
s to use for thequery
component of the endpoint URL.Declaration
Swift
var queryItems: [URLQueryItem]? { get }
-
request(baseUrlComponents:
Default implementation) Generates a
URLRequest
ready for use.Default Implementation
Declaration
Swift
func request(baseUrlComponents: URLComponents) throws -> URLRequest
Parameters
baseUrlComponents
URLComponents
defining the base URL of the API Client.Return Value
A
URLRequest
configured according to the receiver’s definition.