Module: DList::User::Rating

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

Overview

User client - rating

Instance Method Summary collapse

Instance Method Details

#delete_rate(id, target_id = nil, type = :bot) ⇒ Boolean

Removes rate for a selected bot/server

Parameters:

  • id (Integer)

    entity ID

  • target_id (Integer) (defaults to: nil)

    target user to remove rate from (for owners only)

  • type (Symbol) (defaults to: :bot)

    type of entity (bot/server)

Returns:

  • (Boolean)

    true if operation succeded

Raises:



30
31
32
33
34
35
36
# File 'lib/dblista/user/rating.rb', line 30

def delete_rate(id, target_id = nil, type = :bot)
  DList._validate_id id
  raise DList::Error, DList::Errors::TYPE_NOT_ALLOWED unless DList::User::Client::ALLOWED_TYPES.include?(type)

  DList._delete("/#{type}s/#{id}/rate/#{target_id}", nil, @token)
  true
end

#delete_report(id, type = :bot) ⇒ Hash

Deletes rate report

Parameters:

  • id (Integer)

    report ID

Returns:

  • (Hash)

    raw data from DList

Raises:



66
67
68
69
70
71
# File 'lib/dblista/user/rating.rb', line 66

def delete_report(id, type = :bot)
  raise DList::Error, DList::Errors::TYPE_NOT_ALLOWED unless DList::User::Client::ALLOWED_TYPES.include?(type)

  DList._delete("/reports/#{id}", nil, @token)
  true
end

#rate(id, rating, details, type = :bot) ⇒ Boolean

Sends rate for a selected bot/server

Parameters:

  • id (Integer)

    entity ID

  • rating (Integer)

    rating from 0 to 5

  • details (String)

    details (description)

  • type (Symbol) (defaults to: :bot)

    type of entity (bot/server)

Returns:

  • (Boolean)

    true if operation succeded

Raises:



13
14
15
16
17
18
19
20
21
22
# File 'lib/dblista/user/rating.rb', line 13

def rate(id, rating, details, type = :bot)
  DList._validate_id id
  raise DList::Error, DList::Errors::TYPE_NOT_ALLOWED unless DList::User::Client::ALLOWED_TYPES.include?(type)

  DList._post("/#{type}s/#{id}/rate", {
                  rating: rating,
                  details: details
                }, @token)
  true
end

#report_rate(id, rate_id, report_reason = 'Brak powodu', type = :bot) ⇒ Boolean

Reports rate of a selected bot/server

Parameters:

  • id (Integer)

    ID

  • target_id (Integer)

    target user to remove rate from (for owners only)

  • report_reason (String) (defaults to: 'Brak powodu')

    reason of report (details)

  • type (Symbol) (defaults to: :bot)

    type of entity (bot/server)

Returns:

  • (Boolean)

    true if operation succeded

Raises:



45
46
47
48
49
50
51
52
53
# File 'lib/dblista/user/rating.rb', line 45

def report_rate(id, rate_id, report_reason = 'Brak powodu', type = :bot)
  DList._validate_id id
  raise DList::Error, DList::Errors::TYPE_NOT_ALLOWED unless DList::User::Client::ALLOWED_TYPES.include?(type)

  DList._post("/#{type}s/#{id}/ratings/#{rate_id}/report", {
                                                               reportReason: report_reason.to_s
                                                             }, @token)
  true
end

#reportsHash

Fetches all rate reports

Returns:

  • (Hash)

    raw data from DList



58
59
60
# File 'lib/dblista/user/rating.rb', line 58

def reports
  DList._get('/reports')
end