FHIRServerJSONResponse

open class FHIRServerJSONResponse: FHIRServerDataResponse

Encapsulates a server response with JSON response body, if any.

  • The response body, decoded into a FHIRJSON

    Declaration

    Swift

    open var json: FHIRJSON?
  • If the status is >= 400, the response body is checked for an OperationOutcome and its first issue item is turned into an error message.

    Declaration

    Swift

    public required init(handler: FHIRRequestHandler, response: URLResponse, data inData: Data?, error: Error?)
  • Undocumented

    Declaration

    Swift

    open class FHIRServerJSONResponse: FHIRServerDataResponse
  • Uses FHIRElement’s factory method to instantiate the resource of the given type from the response.

    Throws

    Errors if there was no response, if it was of a different type or if there were errors in the data

    Declaration

    Swift

    override open func responseResource<T: Resource>(ofType: T.Type) throws -> T

    Parameters

    ofType

    The type of resource to extract

    Return Value

    The resource that was found in the response if it is of the desired type

  • The response’s body data is used to update the resource by calling resource.populateFrom(json: ). Will throw FHIRError.responseNoResourceReceived if body is nil.

    This method must not be called if the response has a non-nil error.

    Declaration

    Swift

    override open func applyBody(to resource: Resource) throws

    Parameters

    resource

    The resource to apply the response data to