APIEndpoint

public protocol APIEndpoint

Protocol describing API endpoint. API Endpoint describes one URI with all the data and parameters which are sent to it.

Recommended conformance of this protocol is implemented using struct. It is of course possible using enum or class. Endpoints are are not designed to be referenced and used instantly after creation, so no memory usage is required. The case for not using enums is long-term sustainability. Enums tend to have many cases and information about one endpoint is spreaded all over the files. Also, structs offer us generated initializers, which is very helpful

  • URL path component without base URI.

    Declaration

    Swift

    var path: String { get }
  • parameters Default implementation

    URL parameters is string dictionary sent either as URL query, multipart, JSON parameters or URL/Base64 encoded body. The type parameter of APIEndpoint protocol describes the way how to send the parameters.

    Default Implementation

    Declaration

    Swift

    var parameters: HTTPParameters { get }
  • method Default implementation

    HTTP method/verb describing the action.

    Default Implementation

    Declaration

    Swift

    var method: HTTPMethod { get }
  • type Default implementation

    Type of the request describing how the parameters and data should be encoded and sent to the server. If additional data (not only parameters) are sent, then they are returned as an associated value of the type.

    Default Implementation

    Declaration

    Swift

    var type: RequestType { get }
  • authorized Default implementation

    Boolean marking whether the endpoint should be signed and authorization is required.

    This value is not used inside the framework. This value should be checked and handled accordingly when signing using the APIAdapterDelegate.

    Default Implementation

    Declaration

    Swift

    var authorized: Bool { get }