Msg.Request (msg v0.3.8)

Provides helpers for performing Microsoft Graph API requests using Req.

Handles common behaviors like parsing JSON, extracting errors, and optionally paginating across @odata.nextLink.

Summary

Functions

Converts a map with snake_case atom keys to camelCase string keys for the Graph API.

Performs a simple GET request to the given Graph API path.

Types

client()

@type client() :: Req.Request.t()

Functions

convert_keys(map)

@spec convert_keys(map()) :: map()

Converts a map with snake_case atom keys to camelCase string keys for the Graph API.

Handles special OData keys by converting _odata_ to @odata..

Examples

iex> Msg.Request.convert_keys(%{display_name: "Test", mail_enabled: true})
%{"displayName" => "Test", "mailEnabled" => true}

iex> Msg.Request.convert_keys(%{owners_odata_bind: ["user-1"]})
%{"owners@odata.bind" => ["user-1"]}

get(client, path)

@spec get(client(), String.t()) :: {:ok, map()} | {:error, any()}

Performs a simple GET request to the given Graph API path.

Example

Msg.Request.get(client, "/me")