Exspotify.Structs.Paging (Exspotify v0.1.0)
View SourceRepresents Spotify's standard paging object used for paginated responses.
This structure is used across many endpoints that return lists of items with pagination support.
Summary
Functions
Creates a Paging struct from a map, with support for parsing items using a custom parser function.
Types
@type t() :: %Exspotify.Structs.Paging{ href: String.t() | nil, items: [any()], limit: non_neg_integer(), next: String.t() | nil, offset: non_neg_integer(), previous: String.t() | nil, total: non_neg_integer() }
Functions
Creates a Paging struct from a map, with support for parsing items using a custom parser function.
Parameters
map
: The raw map from the API responseitem_parser
: A function that takes a map and returns a parsed item (optional)
Examples
iex> from_map(%{"limit" => 20, "offset" => 0, "total" => 100, "items" => []})
%Paging{limit: 20, offset: 0, total: 100, items: []}
iex> from_map(%{"limit" => 20, "offset" => 0, "total" => 100, "items" => [%{"id" => "123"}]}, fn item -> item["id"] end)
%Paging{limit: 20, offset: 0, total: 100, items: ["123"]}