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 initialized URLRequest generated by the endpoint.

    Declaration

    Swift

    var headers: HTTPHeaders? { get }
  • An optional Body.

    Declaration

    Swift

    var httpBody: Body? { get }
  • A HTTPMethod to use when initializing a URLRequest generated by the endpoint.

    Declaration

    Swift

    var httpMethod: HTTPMethod { get }
  • A String defining the path component of the endpoint URL (i.e. appended after the host component).

    Declaration

    Swift

    var path: String { get }
  • An optional array of URLQueryItems to use for the query 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.