Service
public struct Service<Adapter: HTTPAdapter>
A struct which wraps interaction with a remote API. It delegates all the HTTP requests to the underlying adapter.
-
The handler function for service calls which return a collection of resources.
Declaration
Swift
public typealias CollectionHandler<R: IdentifiableResource, M> = (Response<R, CollectionPath, M, R.Collection>) -> Void
-
The handler function for service calls which return single resources.
Declaration
Swift
public typealias SingularHandler<R: Resource, M> = (Response<R, SingularPath, M, R.Singular>) -> Void
-
The root URL for the remote API. All requests will be made relative to this.
Declaration
Swift
public let host: URL
-
The default configuration that will be applied to every request.
Declaration
Swift
public let options: Options
-
Makes a
GET
request to an endpoint which returns a collection.Declaration
Swift
public func call<R: IdentifiableResource>(_ path: Path<R, CollectionPath, GET>, options: Options = Options(), handler: @escaping CollectionHandler<R, GET>)
-
Makes a
POST
request to an endpoint which returns a resource.Declaration
Swift
public func call<R: Resource>(_ path: Path<R, SingularPath, POST>, options: Options = Options(), handler: @escaping SingularHandler<R, POST>)
-
Makes a
GET
request to an endpoint which returns a resource.Declaration
Swift
public func call<R: Resource>(_ path: Path<R, SingularPath, GET>, options: Options = Options(), handler: @escaping SingularHandler<R, GET>)
-
Makes a
PUT
request to an endpoint which returns a resource.Declaration
Swift
public func call<R: Resource>(_ path: Path<R, SingularPath, PUT>, options: Options = Options(), handler: @escaping SingularHandler<R, PUT>)
-
Makes a
PATCH
request to an endpoint which returns a resource.Declaration
Swift
public func call<R: Resource>(_ path: Path<R, SingularPath, PATCH>, options: Options = Options(), handler: @escaping SingularHandler<R, PATCH>)
-
Makes a
DELETE
request to an endpoint which returns a resource.Declaration
Swift
public func call<R: Resource>(_ path: Path<R, SingularPath, DELETE>, options: Options = Options(), handler: @escaping SingularHandler<R, DELETE>)