New methods to manage notifications

master
Milton Mazzarri 2017-04-10 21:44:58 -05:00
parent 87e3d7bae6
commit ddf464fb72
No known key found for this signature in database
GPG Key ID: CF3DE6E356E17F1E
1 changed files with 42 additions and 0 deletions

View File

@ -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