New methods to manage notifications
parent
87e3d7bae6
commit
ddf464fb72
|
@ -14,6 +14,8 @@ defmodule Hunter.Notification do
|
|||
* `status` - The `Hunter.Status` associated with the notification, if applicable
|
||||
|
||||
"""
|
||||
@hunter_api Application.get_env(:hunter, :hunter_api)
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
id: String.t,
|
||||
type: String.t,
|
||||
|
@ -24,4 +26,44 @@ defmodule Hunter.Notification do
|
|||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [:id, :type, :created_at, :account, :status]
|
||||
|
||||
@doc """
|
||||
Retrieve user's notifications
|
||||
|
||||
## Parameters
|
||||
|
||||
* `conn` - connection credentials
|
||||
|
||||
"""
|
||||
@spec notifications(Hunter.Client.t) :: [Hunter.Notification.t]
|
||||
def notifications(conn) do
|
||||
@hunter_api.notifications(conn)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Retrieve single notification
|
||||
|
||||
## Parameters
|
||||
|
||||
* `conn` - connection credentials
|
||||
* `id` - notification identifier
|
||||
|
||||
"""
|
||||
@spec notification(Hunter.Client.t, non_neg_integer) :: Hunter.Notification.t
|
||||
def notification(conn, id) do
|
||||
@hunter_api.notification(conn, id)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Deletes all notifications from the Mastodon server for the authenticated user
|
||||
|
||||
## Parameters
|
||||
|
||||
* `conn` - connection credentials
|
||||
|
||||
"""
|
||||
@spec clear_notifications(Hunter.Client.t) :: map
|
||||
def clear_notifications(conn) do
|
||||
@hunter_api.clear_notifications(conn)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue