Msg.Pagination (msg v0.3.8)

Shared pagination utilities for Microsoft Graph API list operations.

Summary

Functions

Recursively fetches all pages following @odata.nextLink.

Fetches a single page from the Graph API.

Functions

fetch_all_pages(client, next_link, acc)

@spec fetch_all_pages(Req.Request.t(), String.t() | nil, [map()]) ::
  {:ok, [map()]} | {:error, term()}

Recursively fetches all pages following @odata.nextLink.

Parameters

  • client - Authenticated Req.Request client
  • next_link - Next page URL (or nil to stop)
  • acc - Accumulated items from previous pages

Returns

  • {:ok, [item]} - All items from all pages
  • {:error, term} - Error

fetch_page(client, path, query_params)

@spec fetch_page(Req.Request.t(), String.t(), keyword()) ::
  {:ok, %{items: [map()], next_link: String.t() | nil}} | {:error, term()}

Fetches a single page from the Graph API.

Parameters

  • client - Authenticated Req.Request client
  • path - API path to fetch
  • query_params - List of query parameter tuples

Returns

  • {:ok, %{items: [item], next_link: url | nil}} - Page data with optional next link

  • {:error, term} - Error