Functions for transforming API responses.
Summary
Functions
Extracts the body as a map from an API response structure.
Extracts a value from the response body by key.
Extracts and transforms a collection of resources from a response.
Extracts resources and metadata from a paginated collection response.
Functions
@spec from_response(DSpace.API.HTTP.Response.t() | term()) :: map()
Extracts the body as a map from an API response structure.
Extracts a value from the response body by key.
@spec transform( DSpace.API.HTTP.Response.t() | map(), keyword() ) :: [term()]
Extracts and transforms a collection of resources from a response.
Parameters
map- A map orDSpace.API.HTTP.Response.t/0containing the resource(s)options- A keyword list with the following keys::extract- A path to navigate to the resource(s) (defaults tonil):transform- A function to process each resource (defaults to identity)
Extracts resources and metadata from a paginated collection response.
Returns a three-element tuple {data, meta, next}:
data- List of transformed resourcesmeta- Meta information from the API responsenext- URL for next page or nil if no more pages
Parameters
map- A map orDSpace.API.HTTP.Response.t/0containing the resource collectionoptions- A keyword list with the following keys::extract- A path to navigate to the resources (required):next- A path to navigate to the continuation token (defaults to["_links", "next", "href"]):transform- A function to process each resource (defaults to identity)