RestfulPropertyKit Documentation Beta

Protocol Rest​Query

@dynamicMemberLookup public protocol RestQuery: AnyObject where QueryParent: Codable, QueryValue: Codable 

The protocol all rest query implementations should conform to.

RestQuery RestQuery AnyObject AnyObject RestQuery->AnyObject RestQueryImpl RestQueryImpl RestQueryImpl->RestQuery

Conforms To

AnyObject

Types Conforming to Rest​Query

RestQueryImpl

An implementation of RestQuery protocol.

Default Implementations

subscript(dynamic​Member:​)

subscript<Subject>(dynamicMember keyPath: KeyPath<QueryValue, Subject>) -> Binding<Subject> 

Lazily creates and stores bindings for the properties of the request return type as part of the query metadata.

Parameters

dynamic​Member Key​Path<Query​Value, Subject>

The read-only property key path.

subscript(dynamic​Member:​)

subscript<Subject>(dynamicMember keyPath: WritableKeyPath<QueryValue, Subject>) -> Binding<Subject> 

Lazily creates and stores bindings for the properties of the request return type as part of the query metadata.

Parameters

dynamic​Member Writable​Key​Path<Query​Value, Subject>

The writable property key path.

Requirements

Query​Parent

associatedtype QueryParent

The parent type.

Query​Value

associatedtype QueryValue

The value type.

metadata

var metadata: RestQueryMetadata<QueryParent, QueryValue> 

The metadata associated with this query.

wrapped​Value

var wrappedValue: QueryValue 

The value wrapped by the property attached to this query.

projected​Value

var projectedValue: Binding<QueryValue> 

A binding for the wrapped value.

cancellable

var cancellable: Set<AnyCancellable> 

init(current:​params:​)

init(current: Self, params: [String: String])

Creates a copy of the provided current query with a different params component.

Parameters

current Self

The current query.

params [String:​ String]

The new params for the query copy.

get(prop:​)

func get(prop: Bool) -> Future<QueryValue, RestQueryError>

Sends a get request based on the metadata associated with this query.

Parameters

prop Bool

True if the property key should be used on the parent request result to unwrap the value.

Returns

A future that will resolve to the request result or an error.

post(prop:​new​Value:​)

func post(prop: Bool, newValue: QueryValue) -> Future<QueryValue, RestQueryError>

Sends a post request based on the metadata associated with this query.

Parameters

prop Bool

True if the property key should be used on the parent request result to unwrap the value.

new​Value Query​Value

The value that should be sent as the body part of the HTTPS request.

Returns

A future that will resolve to the new value or an error.