QueryParameterEncoder
public class QueryParameterEncoder
An object that encodes Encodable
objects into an array of URLQueryItem
.
-
Defines available strategies to use when encoding key names.
See moreDeclaration
Swift
public enum KeyEncodingStrategy
-
Defines available strategies when encoding
See moreDate
instances.Declaration
Swift
public enum DateEncodingStrategy
-
Defines available strategies when encoding
See moreData
instances.Declaration
Swift
public enum DataEncodingStrategy
-
The strategy to use for encoding key names. Defaults to
KeyEncodingStrategy.useDefaultKeys
.Declaration
Swift
public var keyEncodingStrategy: KeyEncodingStrategy { get set }
-
The strategy to use for encoding
Date
instances. Defaults toDateEncodingStrategy.deferredToDate
.Declaration
Swift
public var dateEncodingStrategy: DateEncodingStrategy { get set }
-
The strategy to use for encoding
Data
instances. Defaults toDataEncodingStrategy.base64
.Declaration
Swift
public var dataEncodingStrategy: DataEncodingStrategy { get set }
-
Creates a new
QueryParameterEncoder
.Declaration
Swift
public init()
-
Encodes an
Encodable
into an array ofURLQueryItem
.Throws
EncodingError.invalidValue(_:,_:)
if the object can’t be encoded for some reason.Declaration
Swift
public func encode<T>(_ value: T) throws -> [URLQueryItem] where T : Encodable
Parameters
value
The object to encode.
Return Value
An array of
URLQueryItem
that representsvalue
.