Module: DList::User::Notifications

Included in:
Client
Defined in:
lib/dblista/user/notifications.rb

Overview

User client - notifications

Instance Method Summary collapse

Instance Method Details

#clear_notificationsBoolean

Clears user notifications

Returns:

  • (Boolean)

    true if operation succeded



16
17
18
19
# File 'lib/dblista/user/notifications.rb', line 16

def clear_notifications
  DList._get('/users/me/notifications/clear', @token)
  true
end

#notificationsHash

Fetches user notifications

Returns:

  • (Hash)

    raw data from DList



9
10
11
# File 'lib/dblista/user/notifications.rb', line 9

def notifications
  DList._get('/users/me/notifications/read', @token)
end

#send_group_notification(rank, details, url = '#') ⇒ Boolean

Sends notification to specified group (rank) Available only for DList staff

Parameters:

  • rank (Integer)

    rank ID

  • details (String)

    details (content)

  • url (String) (defaults to: '#')

    url to redirect if clicked

Returns:

  • (Boolean)

    true if operation succeded



44
45
46
47
48
49
50
# File 'lib/dblista/user/notifications.rb', line 44

def send_group_notification(rank, details, url = '#')
  DList._post("/users/group/#{rank}/notifications", {
                  text: details,
                  url: url || '#'
                }, @token)
  true
end

#send_notification(id, details, url = '#') ⇒ Boolean

Sends notification to specified user Available only for DList staff

Parameters:

  • rank (Integer)

    user ID

  • details (String)

    details (content)

  • url (String) (defaults to: '#')

    url to redirect if clicked

Returns:

  • (Boolean)

    true if operation succeded



28
29
30
31
32
33
34
35
# File 'lib/dblista/user/notifications.rb', line 28

def send_notification(id, details, url = '#')
  DList._validate_id id
  DList._post("/users/#{id}/notifications", {
                  text: details,
                  url: url || '#'
                }, @token)
  true
end