From 92748b3fe91f1cd527a6222a95a5ca5648df08a1 Mon Sep 17 00:00:00 2001 From: Mikael Fangel <34864484+MikaelFangel@users.noreply.github.com> Date: Sat, 27 Apr 2024 20:10:09 +0200 Subject: [PATCH] incident_api: added possible assignee function --- lib/incident_api.ex | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/incident_api.ex b/lib/incident_api.ex index 62a15dd..6f67159 100644 --- a/lib/incident_api.ex +++ b/lib/incident_api.ex @@ -56,12 +56,20 @@ defmodule LogpointApi.IncidentApi do def add_comments(ip, credential, %IncidentCommentData{} = incident_comment_data), do: update_incident_state(ip, "/add_incident_comment", credential, incident_comment_data) + @spec assign_incidents(String.t(), Credential.t(), IncidentIDs.t(), String.t()) :: + {:ok, map()} | {:error, String.t()} + def assign_incidents(ip, credential, %IncidentIDs{} = incident_ids, assignee_id) do + payload = Map.put(incident_ids, :new_assignee, assignee_id) + update_incident_state(ip, "/assign_incident", credential, payload) + end + @spec resolve_incidents(String.t(), Credential.t(), IncidentIDs.t()) :: {:ok, map()} | {:error, String.t()} def resolve_incidents(ip, credential, %IncidentIDs{} = incident_ids), do: update_incident_state(ip, "/resolve_incident", credential, incident_ids) - @spec update_incident_state(String.t(), String.t(), Credential.t(), map()) :: {:ok, map()} | {:error, String.t()} + @spec update_incident_state(String.t(), String.t(), Credential.t(), map()) :: + {:ok, map()} | {:error, String.t()} defp update_incident_state(ip, path, %Credential{} = credential, request_data) do payload = %{ "username" => credential.username,