Module: DBLista::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)
  DBLista._validate_id id
  raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless DBLista::User::Client::ALLOWED_TYPES.include?(type)

  DBLista._delete("/#{type}s/#{id}/rate/#{target_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)
  DBLista._validate_id id
  raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless DBLista::User::Client::ALLOWED_TYPES.include?(type)

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