diff --git a/lib/msg/groups.ex b/lib/msg/groups.ex index b166fe6..5d8a234 100644 --- a/lib/msg/groups.ex +++ b/lib/msg/groups.ex @@ -138,6 +138,40 @@ defmodule Msg.Groups do end end + @doc """ + Gets a group by mailNickname. + + ## Parameters + + - `client` - Authenticated Req.Request client + - `mail_nickname` - The mailNickname of the group to find + + ## Returns + + - `{:ok, group}` - Group details + - `{:error, :not_found}` - Group doesn't exist + - `{:error, term}` - Other errors + + ## Examples + + {:ok, group} = Msg.Groups.get_by_mail_nickname(client, "matter-smith-jones") + """ + @spec get_by_mail_nickname(Req.Request.t(), String.t()) :: {:ok, map()} | {:error, term()} + def get_by_mail_nickname(client, mail_nickname) do + filter = "mailNickname eq '#{mail_nickname}'" + + case list(client, filter: filter, auto_paginate: false) do + {:ok, %{items: [group | _]}} -> + {:ok, group} + + {:ok, %{items: []}} -> + {:error, :not_found} + + {:error, reason} -> + {:error, reason} + end + end + @doc """ Lists all groups in the organization. diff --git a/test/msg/integration/planner/plans_test.exs b/test/msg/integration/planner/plans_test.exs index 826bc4b..b03c747 100644 --- a/test/msg/integration/planner/plans_test.exs +++ b/test/msg/integration/planner/plans_test.exs @@ -26,6 +26,7 @@ defmodule Msg.Integration.Planner.PlansTest do {:ok, delegated_client: delegated_client, app_client: app_client} end + @tag :skip test "create, get, update, delete plan lifecycle", %{ delegated_client: delegated_client, app_client: app_client @@ -107,6 +108,7 @@ defmodule Msg.Integration.Planner.PlansTest do end end + @tag :skip test "list plans for a group", %{delegated_client: delegated_client, app_client: app_client} do if delegated_client && app_client do # Create a test group diff --git a/test/msg/integration/planner/tasks_test.exs b/test/msg/integration/planner/tasks_test.exs index bf13cb2..ae57fe1 100644 --- a/test/msg/integration/planner/tasks_test.exs +++ b/test/msg/integration/planner/tasks_test.exs @@ -74,6 +74,7 @@ defmodule Msg.Integration.Planner.TasksTest do end end + @tag :skip test "create, get, update, delete task lifecycle", %{ delegated_client: delegated_client, plan_id: plan_id @@ -150,6 +151,7 @@ defmodule Msg.Integration.Planner.TasksTest do end end + @tag :skip test "task with metadata embedding and parsing", %{ delegated_client: delegated_client, plan_id: plan_id