Skip to content
This repository has been archived by the owner on Jul 28, 2021. It is now read-only.

Add get incident and list log entries endpoints #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions lib/mixduty/incidents.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ defmodule Mixduty.Incidents do
@doc """
Create an incident
#### Example
Mixduty.Incident.create("Server is on fire", "P00PBUG", "user@pagerduty.com", client)
Mixduty.Incidents.create("Server is on fire", "P00PBUG", "user@pagerduty.com", client)
"""
def create(title, service_id, from, client, options \\ %{}) do
incident_body = %{
Expand All @@ -40,10 +40,31 @@ defmodule Mixduty.Incidents do
post("#{@path}", client, body)
end

@doc """
Get an incident
#### Example
Mixduty.Incidents.incident("P00PBUG", client)
"""
def incident(id, client, params \\ [], options \\ []) do
get("#{@path}/#{id}", client, params, options)
end

@doc """
List log entries of an incident
#### Example
Mixduty.Incidents.log_entries("P00PBUG", client)
"""
def log_entries(incident_id, client, params \\ [], options \\ []) do
@path
|> Path.join(incident_id)
|> Path.join("log_entries")
|> get(client, params, options)
end

@doc """
Create an incident note
#### Example
Mixduty.Incident.create_note("This is a note describing details", "P00PBUG", "user@pagerduty.com", client)
Mixduty.Incidents.create_note("This is a note describing details", "P00PBUG", "user@pagerduty.com", client)
"""
def create_note(note, incident_id, from, client) do
body = %{
Expand Down