HTTPMethod

public enum HTTPMethod: String

An enumeration of the supported methods

  • Will generate POST requests for a given Restable

    Declaration

    Swift

    case post = "POST"
  • get

    Will generate GET requests for a given Restable

    Declaration

    Swift

    case get = "GET"
  • put

    Will gneerate a PUT request for a given Restable

    Declaration

    Swift

    case put = "PUT"
  • Will generate a PATCH request for a given Restable

    Declaration

    Swift

    case patch = "PATCH"
  • Will generate a DELETE request for a given restable

    Declaration

    Swift

    case delete = "DELETE"
  • Creates a URLRequest appropriate for this instance

    Throws

    An HTTPMethodError.invalidURL if the URLRequest could not be created.

    Declaration

    Swift

    public func makeURLRequest<T>(`for` restable: T) throws -> URLRequest where T: Restable

    Parameters

    restable

    The Restable for which a URLRequest is to be created

    Return Value

    The URLRequest for this Restable

  • Creates a URLRequest for this instance and uses the JSON Encoded data of this instance as the request’s body.

    Throws

    • An HTTPMethodError.invalidURL if the URLRequest could not be created.
    • An HTTPMethodError.jsonSerializationFailed(error: Error) if the Restable fails to encode.

    Declaration

    Swift

    public func makeURLRequest<T>(`for` restable: T) throws -> URLRequest where T: Restable & Encodable

    Parameters

    restable

    The Restable for which a URLRequest is to be created

    Return Value

    The URLRequest for this Restable

  • Creates a URLRequest for this instance and uses this instance’s data value as the request’s body.

    Throws

    An HTTPMethodError.invalidURL if the URLRequest could not be created.

    Declaration

    Swift

    public func makeURLRequest<T>(`for` restable: T) throws -> URLRequest where T: Restable & PreEncoded

    Parameters

    restable

    The Restable for which a URLRequest is to be created

    Return Value

    The URLRequest for this Restable

  • JSON encodes the Encodable instance.

    Throws

    throws an error based on the type of problem:
    • The value fails to encode, or contains a nested value that fails to encode—this method throws the corresponding error.
    • The value can’t be encoded as a JSON array or JSON object—this method throws the invalidValue error.
    • The value contains an exceptional floating-point number (such as infinity or nan) and you’re using the default JSONEncoder.NonConformingFloatEncodingStrategy—this method throws the invalidValue error.

    Declaration

    Swift

    public func encode<T>(_ instance: T) throws -> Data where T: Encodable

    Parameters

    instance

    The Encodable to be encoded

    Return Value

    The encoded data of instance

  • JSON encodes the Encodable instance.

    Throws

    throws an error based on the type of problem:
    • The value fails to encode, or contains a nested value that fails to encode—this method throws the corresponding error.
    • The value can’t be encoded as a JSON array or JSON object—this method throws the invalidValue error.
    • The value contains an exceptional floating-point number (such as infinity or nan) and you’re using the default JSONEncoder.NonConformingFloatEncodingStrategy—this method throws the invalidValue error.

    Declaration

    Swift

    public func encode<T>(_ instance: T) throws -> Data where T: Encodable & Restable

    Parameters

    instance

    The Encodable to be encoded

    Return Value

    The encoded data of instance