Eiffel.framework.api_client_response.mustache Maven / Gradle / Ivy
{{>noteinfo}}
class
API_CLIENT_RESPONSE
create
make
feature {NONE} -- Initialization
make (a_response: detachable HTTP_CLIENT_RESPONSE; a_error: detachable API_ERROR; a_custom_deserializer: detachable FUNCTION [TUPLE [STRING, STRING, TYPE [detachable ANY]], detachable ANY])
do
response := a_response
error := a_error
deserializer := a_custom_deserializer
end
feature -- Access
has_error: BOOLEAN
-- has error?
do
Result := response = Void and then attached error
end
status: INTEGER
do
if attached response as l_response then
Result := l_response.status
end
end
feature -- Data
data (a_type: TYPE [detachable ANY]): detachable ANY
-- Data representation of the HTTP Response
do
if
attached response as l_response and then
attached deserializer as l_deserializer and then
attached l_response.body as l_body and then
attached l_response.header ("Content-Type") as l_content_type
then
Result := (create {API_DESERIALIZER}).deserializer (l_deserializer, l_content_type, l_body, a_type)
end
end
feature -- Error
error: detachable API_ERROR
-- Internal client error.
feature {NONE} -- Implementation
response: detachable HTTP_CLIENT_RESPONSE
-- Low level response returned by the API call.
deserializer: detachable FUNCTION [TUPLE [STRING, STRING, TYPE [detachable ANY]], detachable ANY]
-- function to map a response body with a given content type to the target
-- in the domain model.
end
© 2015 - 2024 Weber Informatics LLC | Privacy Policy