Class: DBLista::User::Client

Inherits:
Object
  • Object
show all
Includes:
Actions, Boosting, Notifications, Rating, Verification, Voting
Defined in:
lib/dblista/user/client.rb

Overview

DBLista user client

Examples:

Server voting

client = DBLista::User::Client.new "USER_TOKEN"
client.vote(123456789012345678, :server)

Bot rating

client = DBLista::User::Client.new "USER_TOKEN"
client.rate(123456789012345678, 5, 'Nice bot')

Constant Summary collapse

ALLOWED_TYPES =

Allowed entity types to use

i[bot server].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Verification

#approve, #reject, #set_pending

Methods included from Notifications

#clear_notifications, #notifications, #send_group_notification, #send_notification

Methods included from Rating

#delete_rate, #rate

Methods included from Boosting

#boost, #delete_boost

Methods included from Actions

#add, #delete, #edit, #manage_user

Methods included from Voting

#vote

Constructor Details

#initialize(token) ⇒ Client

Returns a new instance of Client.

Raises:



34
35
36
37
38
39
40
# File 'lib/dblista/user/client.rb', line 34

def initialize(token)
  raise DBLista::Error, DBLista::Errors::TOKEN_NOT_PROVIDED unless token

  @token = token

  me
end

Instance Attribute Details

#tokenObject

Returns the value of attribute token.



32
33
34
# File 'lib/dblista/user/client.rb', line 32

def token
  @token
end

Instance Method Details

#guildsHash

Fetches current user guilds

Returns:

  • (Hash)

    raw data from DBLista



52
53
54
# File 'lib/dblista/user/client.rb', line 52

def guilds
  DBLista._get('/users/me/guilds', @token)
end

#meHash

Fetches information about current user

Returns:

  • (Hash)

    raw data from DBLista



45
46
47
# File 'lib/dblista/user/client.rb', line 45

def me
  DBLista._get('/users/me', @token)
end