mirror of
https://github.com/ash-project/ash_json_api_wrapper.git
synced 2024-09-21 13:52:59 +12:00
24 lines
634 B
Elixir
24 lines
634 B
Elixir
defmodule AshJsonApiWrapper.Paginator.ContinuationProperty do
|
|
use AshJsonApiWrapper.Paginator
|
|
|
|
def continue(_response, [], _), do: :halt
|
|
|
|
def continue(response, _entities, opts) do
|
|
case ExJSONPath.eval(response, opts[:get]) do
|
|
{:ok, [value | _]} when not is_nil(value) ->
|
|
if opts[:header] do
|
|
{:ok, %{headers: %{opts[:header] => value}}}
|
|
else
|
|
if opts[:param] do
|
|
{:ok,
|
|
%{params: AshJsonApiWrapper.Helpers.put_at_path(%{}, List.wrap(opts[:param]), value)}}
|
|
else
|
|
:halt
|
|
end
|
|
end
|
|
|
|
_ ->
|
|
:halt
|
|
end
|
|
end
|
|
end
|