dblista 0.1.5 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a8a9f1ef63473322f8f5cfb544e460fe77740bfba0bf6e767be8d583f2906cb6
4
- data.tar.gz: 855aeed578c2e189b9c57098e1978b24c1a38a2225ddb232fa84959f6ac2c264
3
+ metadata.gz: 7a839df00612d366d1a0184c647cdce72895f1ee02d71c25deb2e76ae78c7026
4
+ data.tar.gz: 4922b94a22e10332f564ef628058664204c3904c794e1381cab452478c24af8f
5
5
  SHA512:
6
- metadata.gz: cc04945b098ae8850aac02baec8cc6d20fc8f6388ec60e86a8ac6533d00b85d6439613ea7da5ba5a0dc097f95bba79c4f09b3a718fda7954215723d1ab887bb3
7
- data.tar.gz: 3c94d344e3c0e5f61a0114daa40845dfd8d83d60baaa2f2ec942b7618e37c0d6bd5143dfaf1b3b110f5721daa6e38b62df84617695f899477eed4119ff0b9723
6
+ metadata.gz: c9131862894f3adfaba7fb2a0add9f7fb31f423a8a94ebbd19efb8d1f84f8c14e8ee9acec3c1742a3eef0cc2e02cb8f228f5ab3eb98b5e6ebe8de0427b4f2d14
7
+ data.tar.gz: 3105e3459bea2a2c8f33f1f4470ead0d103d6757396bdde267e4b323cd5839e573d90d63d47ab6b3756083cf0e5f9a18740b2a844629ddc06ceca51ea6ab6150
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dblista (0.1.5)
4
+ dblista (0.3.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -33,7 +33,7 @@ Pobieranie topki botów:
33
33
 
34
34
  ```ruby
35
35
  top = DBLista::List::Bot.top
36
- puts top['data'].inspect
36
+ puts top
37
37
  ```
38
38
 
39
39
  ## Licencja
@@ -12,6 +12,8 @@ require_relative 'dblista/errors'
12
12
  require_relative 'dblista/list/bot'
13
13
  require_relative 'dblista/list/server'
14
14
  require_relative 'dblista/user/client'
15
+ require_relative 'dblista/helpers'
16
+ require_relative 'dblista/constants'
15
17
 
16
18
  # Main module
17
19
  module DBLista
@@ -36,7 +38,8 @@ module DBLista
36
38
  response = _https(uri).request(req)
37
39
  result = JSON.parse response.body
38
40
  raise DBLista::Error, result['error'].capitalize unless result['status'] == 'success'
39
- result
41
+
42
+ result['data']
40
43
  end
41
44
 
42
45
  # @!visibility private
@@ -76,4 +79,9 @@ module DBLista
76
79
  def self._page_integer(input)
77
80
  raise DBLista::Error, DBLista::Errors::PAGE_INTEGER unless input.is_a?(Integer)
78
81
  end
82
+
83
+ # @!visibility private
84
+ def self._limit_integer(input)
85
+ raise DBLista::Error, DBLista::Errors::LIMIT_INTEGER unless input.is_a?(Integer)
86
+ end
79
87
  end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DBLista
4
+ # Tags
5
+ module Tags
6
+ # Bot tags
7
+ module Bot
8
+ MODERATION = :moderacja
9
+ TOOLS = :narzędzia
10
+ MUSIC = :muzyka
11
+ DASHBOARD = :panel
12
+ FUN = :rozrywka
13
+ LEVELS = :poziomy
14
+ GAMES = :gry
15
+ ROLEPLAY = :roleplay
16
+ ECONOMY = :ekonomia
17
+ ANIME = :anime
18
+ NSFW = :nsfw
19
+ OTHER = :inne
20
+ end
21
+ # Server tags
22
+ module Server
23
+ COMMUNITY = :community
24
+ PROGRAMMING = :programowanie
25
+ GAMES = :gry
26
+ YOUTUBE = :youtube
27
+ HOBBY = :hobby
28
+ ANIME = :anime
29
+ ROLEPLAY = :roleplay
30
+ OTHER = :inne
31
+ end
32
+ end
33
+ # Permissions
34
+ module Permissions
35
+ USER = 0
36
+ MODERATOR = 1
37
+ BIG_MODERATOR = 2
38
+ ADMINISTRATOR = 3
39
+ end
40
+ end
@@ -6,6 +6,10 @@ module DBLista::Errors
6
6
  ID_NEEDED = 'You need to enter ID'
7
7
  # Raised when provided page is not an integer
8
8
  PAGE_INTEGER = 'Page must be an integer'
9
+ # Raised when rank is not an integer
10
+ RANK_INTEGER = 'Rank must be an integer'
11
+ # Raised when provided limit is not an integer
12
+ LIMIT_INTEGER = 'Limit must be an integer'
9
13
  # Raised when token is not provided
10
14
  TOKEN_NOT_PROVIDED = 'Token is not provided'
11
15
  # Raised when type symbol is invalid
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Helper methods
4
+ module DBLista::Helpers
5
+ # Crafts avatar url from user ID and avatar hash
6
+ #
7
+ # @param id [Integer] user ID
8
+ # @param hash [String] avatar hash
9
+ # @param size [Integer] avatar width (defaults to 2048)
10
+ # @return [Hash] raw data from DBLista
11
+ def self.get_avatar(id, hash, size = 2048)
12
+ "https://cdn.discordapp.com/avatars/#{id}/#{hash}?size=#{size}"
13
+ end
14
+ end
@@ -8,7 +8,7 @@ module DBLista
8
8
  #
9
9
  # @example Checking DBLista user information
10
10
  # info = DBLista::Information.user 123456789012345678
11
- # puts info['data']
11
+ # puts info
12
12
  module Information
13
13
  # Fetches DBLista bot information
14
14
  #
@@ -8,26 +8,30 @@ require 'cgi'
8
8
  #
9
9
  # @example Fetch top 25 bots
10
10
  # top = DBLista::List::Bot.top
11
- # puts top['data'].inspect
11
+ # puts top
12
12
  module DBLista::List
13
13
  # Bot lists
14
14
  module Bot
15
15
  # Fetches top bots
16
16
  #
17
17
  # @param page [Integer] page
18
+ # @param limit [Integer] limit of bots per page
18
19
  # @return [Hash] raw data from DBLista
19
- def self.top(page = 0)
20
+ def self.top(page = 0, limit = 10)
20
21
  DBLista._page_integer page
21
- DBLista._get("/bots/list/top/#{page}")
22
+ DBLista._limit_integer limit
23
+ DBLista._get("/bots/list/top/#{page}?limit=#{limit}")
22
24
  end
23
25
 
24
26
  # Fetches premium bots
25
27
  #
26
28
  # @param page [Integer] page
29
+ # @param limit [Integer] limit of bots per page
27
30
  # @return [Hash] raw data from DBLista
28
- def self.premium(page = 0)
31
+ def self.premium(page = 0, limit = 10)
29
32
  DBLista._page_integer page
30
- DBLista._get("/bots/list/premium/#{page}")
33
+ DBLista._limit_integer limit
34
+ DBLista._get("/bots/list/premium/#{page}?limit=#{limit}")
31
35
  end
32
36
 
33
37
  # Fetches unverified bots
@@ -44,6 +48,13 @@ module DBLista::List
44
48
  DBLista._get('/bots/list/rejected')
45
49
  end
46
50
 
51
+ # Fetches all bots
52
+ #
53
+ # @return [Array] array of raw bot data from DBLista
54
+ def self.all
55
+ DBLista::List::Bot.top(0, 100_000_000)
56
+ end
57
+
47
58
  # Bot search
48
59
  #
49
60
  # @param query [String] query search
@@ -51,7 +62,7 @@ module DBLista::List
51
62
  def self.search(query)
52
63
  raise DBLista::Error, DBLista::Errors::QUERY_NOT_PROVIDED unless query
53
64
 
54
- DBLista._get("/bots/search/#{CGI.escape query}")
65
+ DBLista._get("/bots/search/#{CGI.escape query.to_s}")
55
66
  end
56
67
  end
57
68
  end
@@ -8,19 +8,30 @@ module DBLista::List
8
8
  # Fetches top servers
9
9
  #
10
10
  # @param page [Integer] page
11
+ # @param limit [Integer] limit of servers per page
11
12
  # @return [Hash] raw data from DBLista
12
- def self.top(page = 0)
13
+ def self.top(page = 0, limit = 10)
13
14
  DBLista._page_integer page
14
- DBLista._get("/servers/list/top/#{page}")
15
+ DBLista._limit_integer limit
16
+ DBLista._get("/servers/list/top/#{page}?limit=#{limit}")
15
17
  end
16
18
 
17
19
  # Fetches premium servers
18
20
  #
19
21
  # @param page [Integer] page
22
+ # @param limit [Integer] limit of servers per page
20
23
  # @return [Hash] raw data from DBLista
21
- def self.premium(page = 0)
24
+ def self.premium(page = 0, limit = 10)
22
25
  DBLista._page_integer page
23
- DBLista._get("/servers/list/premium/#{page}")
26
+ DBLista._limit_integer limit
27
+ DBLista._get("/servers/list/premium/#{page}?limit=#{limit}")
28
+ end
29
+
30
+ # Fetches all servers
31
+ #
32
+ # @return [Array] array of raw server data from DBLista
33
+ def self.all
34
+ DBLista::List::Server.top(0, 100_000_000)
24
35
  end
25
36
 
26
37
  # Server search
@@ -30,7 +41,7 @@ module DBLista::List
30
41
  def self.search(query)
31
42
  raise DBLista::Error, DBLista::Errors::QUERY_NOT_PROVIDED unless query
32
43
 
33
- DBLista._get("/servers/search/#{CGI.escape query}")
44
+ DBLista._get("/servers/search/#{CGI.escape query.to_s}")
34
45
  end
35
46
  end
36
47
  end
@@ -5,40 +5,58 @@ require 'json'
5
5
  module DBLista::User
6
6
  # User client - actions
7
7
  module Actions
8
- # Adds bot/server to DBLista
9
- #
10
- # @param body [Hash] raw body to send
11
- # @param type [Symbol] type of entity (bot/server)
12
- # @return [Hash] raw data from DBLista
13
- def add(body, type = 'bot')
14
- raise DBLista::Error, DBLista::Errors::BODY_HASH unless body.is_a?(Hash)
15
- raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless ALLOWED_TYPES.include?(type)
16
-
17
- DBLista._post("/#{type}s", body, @token)
18
- end
8
+ # Adds bot/server to DBLista
9
+ #
10
+ # @param body [Hash] raw body to send
11
+ # @param type [Symbol] type of entity (bot/server)
12
+ # @return [Boolean] true if operation succeded
13
+ def add(body, type = 'bot')
14
+ raise DBLista::Error, DBLista::Errors::BODY_HASH unless body.is_a?(Hash)
15
+ raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless DBLista::User::Client::ALLOWED_TYPES.include?(type)
19
16
 
20
- # Edits bot/server in DBLista
21
- #
22
- # @param body [Hash] raw body to send
23
- # @param type [Symbol] type of entity (bot/server)
24
- # @return [Hash] raw data from DBLista
25
- def edit(body, type = :bot)
26
- raise DBLista::Error, DBLista::Errors::BODY_HASH unless body.is_a?(Hash)
27
- raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless DBLista::User::Client::ALLOWED_TYPES.include?(type)
17
+ DBLista._post("/#{type}s", body, @token)
18
+ true
19
+ end
28
20
 
29
- DBLista._put("/#{type}s", body, @token)
30
- end
21
+ # Edits bot/server in DBLista
22
+ #
23
+ # @param body [Hash] raw body to send
24
+ # @param type [Symbol] type of entity (bot/server)
25
+ # @return [Boolean] true if operation succeded
26
+ def edit(body, type = :bot)
27
+ raise DBLista::Error, DBLista::Errors::BODY_HASH unless body.is_a?(Hash)
28
+ raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless DBLista::User::Client::ALLOWED_TYPES.include?(type)
31
29
 
32
- # Deletes bot/server from DBLista
33
- #
34
- # @param id [Integer] entity ID
35
- # @param type [Symbol] type of entity (bot/server)
36
- # @return [Hash] raw data from DBLista
37
- def delete(id, type = :bot)
38
- DBLista._validate_id id
39
- raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless DBLista::User::Client::ALLOWED_TYPES.include?(type)
30
+ DBLista._put("/#{type}s", body, @token)
31
+ true
32
+ end
40
33
 
41
- DBLista._delete("/#{type}s/#{id}", nil, @token)
42
- end
34
+ # Deletes bot/server from DBLista
35
+ #
36
+ # @param id [Integer] entity ID
37
+ # @param type [Symbol] type of entity (bot/server)
38
+ # @return [Boolean] true if operation succeded
39
+ def delete(id, type = :bot)
40
+ DBLista._validate_id id
41
+ raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless DBLista::User::Client::ALLOWED_TYPES.include?(type)
42
+
43
+ DBLista._delete("/#{type}s/#{id}", nil, @token)
44
+ true
45
+ end
46
+
47
+ # Manages user (bans or adds premium)
48
+ # Available only for DBLista staff
49
+ #
50
+ # @param id [Integer] user ID
51
+ # @param banned [Boolean] user ban status
52
+ # @param premium [Integer] days for premium
53
+ # @return [Boolean] true if operation succeded
54
+ def manage_user(id, banned = false, premium = 0)
55
+ DBLista._post("/users/#{id}/manage", {
56
+ premium: premium,
57
+ ban: banned
58
+ }, @token)
59
+ true
60
+ end
43
61
  end
44
62
  end
@@ -3,28 +3,30 @@
3
3
  module DBLista::User
4
4
  # User client - boosting
5
5
  module Boosting
6
- # Boosts selected bot/server
7
- #
8
- # @param id [Integer] entity ID
9
- # @param type [Symbol] type of entity (bot/server)
10
- # @return [Hash] raw data from DBLista
11
- def boost(id, type = :bot)
12
- DBLista._validate_id id
13
- raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless ALLOWED_TYPES.include?(type)
6
+ # Boosts selected bot/server
7
+ #
8
+ # @param id [Integer] entity ID
9
+ # @param type [Symbol] type of entity (bot/server)
10
+ # @return [Boolean] true if operation succeded
11
+ def boost(id, type = :bot)
12
+ DBLista._validate_id id
13
+ raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless DBLista::User::Client::ALLOWED_TYPES.include?(type)
14
14
 
15
- DBLista._post("/#{type}s/#{id}/boost", nil, @token)
16
- end
15
+ DBLista._post("/#{type}s/#{id}/boost", nil, @token)
16
+ true
17
+ end
17
18
 
18
- # Removes boost from a selected bot/server
19
- #
20
- # @param id [Integer] entity ID
21
- # @param type [Symbol] type of entity (bot/server)
22
- # @return [Hash] raw data from DBLista
23
- def delete_boost(id, type = :bot)
24
- DBLista._validate_id id
25
- raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless DBLista::User::Client::ALLOWED_TYPES.include?(type)
19
+ # Removes boost from a selected bot/server
20
+ #
21
+ # @param id [Integer] entity ID
22
+ # @param type [Symbol] type of entity (bot/server)
23
+ # @return [Boolean] true if operation succeded
24
+ def delete_boost(id, type = :bot)
25
+ DBLista._validate_id id
26
+ raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless DBLista::User::Client::ALLOWED_TYPES.include?(type)
26
27
 
27
- DBLista._delete("/#{type}s/#{id}/boost", nil, @token)
28
- end
28
+ DBLista._delete("/#{type}s/#{id}/boost", nil, @token)
29
+ true
30
+ end
29
31
  end
30
32
  end
@@ -5,6 +5,7 @@ require_relative './boosting'
5
5
  require_relative './rating'
6
6
  require_relative './voting'
7
7
  require_relative './notifications'
8
+ require_relative './verification'
8
9
 
9
10
  # User module - client + client modules
10
11
  module DBLista::User
@@ -12,17 +13,18 @@ module DBLista::User
12
13
  #
13
14
  # @example Server voting
14
15
  # client = DBLista::User::Client.new "USER_TOKEN"
15
- # response = client.vote(123456789012345678, :server)
16
+ # client.vote(123456789012345678, :server)
16
17
  #
17
18
  # @example Bot rating
18
19
  # client = DBLista::User::Client.new "USER_TOKEN"
19
- # response = client.rate(123456789012345678, 5, 'Nice bot')
20
+ # client.rate(123456789012345678, 5, 'Nice bot')
20
21
  class Client
21
22
  include DBLista::User::Voting
22
23
  include DBLista::User::Actions
23
24
  include DBLista::User::Boosting
24
25
  include DBLista::User::Rating
25
26
  include DBLista::User::Notifications
27
+ include DBLista::User::Verification
26
28
 
27
29
  # Allowed entity types to use
28
30
  ALLOWED_TYPES = %i[bot server].freeze
@@ -34,7 +36,7 @@ module DBLista::User
34
36
 
35
37
  @token = token
36
38
 
37
- raise DBLista::Error, DBLista::Errors::INVALID_TOKEN unless me['status'] == 'success'
39
+ me
38
40
  end
39
41
 
40
42
  # Fetches information about current user
@@ -3,18 +3,50 @@
3
3
  module DBLista::User
4
4
  # User client - notifications
5
5
  module Notifications
6
- # Fetches user notifications
7
- #
8
- # @return [Hash] raw data from DBLista
9
- def notifications
10
- DBLista._get('/users/me/notifications/read', @token)
11
- end
6
+ # Fetches user notifications
7
+ #
8
+ # @return [Hash] raw data from DBLista
9
+ def notifications
10
+ DBLista._get('/users/me/notifications/read', @token)
11
+ end
12
12
 
13
- # Clears user notifications
14
- #
15
- # @return [Hash] raw data from DBLista
16
- def clear_notifications
17
- DBLista._get('/users/me/notifications/clear', @token)
18
- end
13
+ # Clears user notifications
14
+ #
15
+ # @return [Boolean] true if operation succeded
16
+ def clear_notifications
17
+ DBLista._get('/users/me/notifications/clear', @token)
18
+ true
19
+ end
20
+
21
+ # Sends notification to specified user
22
+ # Available only for DBLista staff
23
+ #
24
+ # @param rank [Integer] user ID
25
+ # @param details [String] details (content)
26
+ # @param url [String] url to redirect if clicked
27
+ # @return [Boolean] true if operation succeded
28
+ def send_notification(id, details, url = '#')
29
+ DBLista._validate_id id
30
+ DBLista._post("/users/#{id}/notifications", {
31
+ text: details,
32
+ url: url || '#'
33
+ }, @token)
34
+ true
35
+ end
36
+
37
+ # Sends notification to specified group (rank)
38
+ # Available only for DBLista staff
39
+ #
40
+ # @param rank [Integer] rank ID
41
+ # @param details [String] details (content)
42
+ # @param url [String] url to redirect if clicked
43
+ # @return [Boolean] true if operation succeded
44
+ def send_group_notification(rank, details, url = '#')
45
+ DBLista._post("/users/group/#{rank}/notifications", {
46
+ text: details,
47
+ url: url || '#'
48
+ }, @token)
49
+ true
50
+ end
19
51
  end
20
52
  end
@@ -3,34 +3,36 @@
3
3
  module DBLista::User
4
4
  # User client - rating
5
5
  module Rating
6
- # Sends rate for a selected bot/server
7
- #
8
- # @param id [Integer] entity ID
9
- # @param rating [Integer] rating from 0 to 5
10
- # @param details [String] details (description)
11
- # @param type [Symbol] type of entity (bot/server)
12
- # @return [Hash] raw data from DBLista
13
- def rate(id, rating, details, type = :bot)
14
- DBLista._validate_id id
15
- raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless ALLOWED_TYPES.include?(type)
6
+ # Sends rate for a selected bot/server
7
+ #
8
+ # @param id [Integer] entity ID
9
+ # @param rating [Integer] rating from 0 to 5
10
+ # @param details [String] details (description)
11
+ # @param type [Symbol] type of entity (bot/server)
12
+ # @return [Boolean] true if operation succeded
13
+ def rate(id, rating, details, type = :bot)
14
+ DBLista._validate_id id
15
+ raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless DBLista::User::Client::ALLOWED_TYPES.include?(type)
16
16
 
17
- DBLista._post("/#{type}s/#{id}/rate", {
18
- rating: rating,
19
- details: details
20
- }, @token)
21
- end
17
+ DBLista._post("/#{type}s/#{id}/rate", {
18
+ rating: rating,
19
+ details: details
20
+ }, @token)
21
+ true
22
+ end
22
23
 
23
- # Removes rate for a selected bot/server
24
- #
25
- # @param id [Integer] entity ID
26
- # @param target_id [Integer] target user to remove rate from (for owners only)
27
- # @param type [Symbol] type of entity (bot/server)
28
- # @return [Hash] raw data from DBLista
29
- def delete_rate(id, target_id = nil, type = :bot)
30
- DBLista._validate_id id
31
- raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless DBLista::User::Client::ALLOWED_TYPES.include?(type)
24
+ # Removes rate for a selected bot/server
25
+ #
26
+ # @param id [Integer] entity ID
27
+ # @param target_id [Integer] target user to remove rate from (for owners only)
28
+ # @param type [Symbol] type of entity (bot/server)
29
+ # @return [Boolean] true if operation succeded
30
+ def delete_rate(id, target_id = nil, type = :bot)
31
+ DBLista._validate_id id
32
+ raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless DBLista::User::Client::ALLOWED_TYPES.include?(type)
32
33
 
33
- DBLista._delete("/#{type}s/#{id}/rate/#{target_id}", nil, @token)
34
- end
34
+ DBLista._delete("/#{type}s/#{id}/rate/#{target_id}", nil, @token)
35
+ true
36
+ end
35
37
  end
36
38
  end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cgi'
4
+
5
+ module DBLista::User
6
+ # User client - verification (only for staff)
7
+ module Verification
8
+ # Approves specified bot
9
+ #
10
+ # @param id [Integer] bot ID
11
+ # @param reason [String] reason for approving
12
+ # @return [Boolean] true if operation succeded
13
+ def approve(id, reason = 'Brak powodu')
14
+ DBLista._validate_id id
15
+
16
+ DBLista._post("/bots/#{id}/approve?reason=#{CGI.escape reason}", nil, @token)
17
+ true
18
+ end
19
+
20
+ # Rejects specified bot
21
+ #
22
+ # @param id [Integer] bot ID
23
+ # @param reason [String] reason for rejecting
24
+ # @return [Boolean] true if operation succeded
25
+ def reject(id, reason = 'Brak powodu')
26
+ DBLista._validate_id id
27
+
28
+ DBLista._post("/bots/#{id}/reject?reason=#{CGI.escape reason}", nil, @token)
29
+ true
30
+ end
31
+
32
+ # Sets specified bot verification status to pending
33
+ #
34
+ # @param id [Integer] bot ID
35
+ # @return [Boolean] true if operation succeded
36
+ def set_pending(id)
37
+ DBLista._validate_id id
38
+
39
+ DBLista._post("/bots/#{id}/set-pending", nil, @token)
40
+ true
41
+ end
42
+ end
43
+ end
@@ -3,16 +3,17 @@
3
3
  module DBLista::User
4
4
  # User client - voting
5
5
  module Voting
6
- # Votes for a selected bot/server
7
- #
8
- # @param id [Integer] entity ID
9
- # @param type [Symbol] type of entity (bot/server)
10
- # @return [Hash] raw data from DBLista
11
- def vote(id, type = :bot)
12
- DBLista._validate_id id
13
- raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless DBLista::User::Client::ALLOWED_TYPES.include?(type)
6
+ # Votes for a selected bot/server
7
+ #
8
+ # @param id [Integer] entity ID
9
+ # @param type [Symbol] type of entity (bot/server)
10
+ # @return [Boolean] true if operation succeded
11
+ def vote(id, type = :bot)
12
+ DBLista._validate_id id
13
+ raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless DBLista::User::Client::ALLOWED_TYPES.include?(type)
14
14
 
15
- DBLista._post("/#{type}s/#{id}/vote", nil, @token)
16
- end
15
+ DBLista._post("/#{type}s/#{id}/vote", nil, @token)
16
+ true
17
+ end
17
18
  end
18
19
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module DBLista
4
4
  # Wrapper version
5
- VERSION = '0.1.5'
5
+ VERSION = '0.3.2'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dblista
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - deepivin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-04 00:00:00.000000000 Z
11
+ date: 2020-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -70,7 +70,9 @@ files:
70
70
  - dblista.gemspec
71
71
  - example/info.rb
72
72
  - lib/dblista.rb
73
+ - lib/dblista/constants.rb
73
74
  - lib/dblista/errors.rb
75
+ - lib/dblista/helpers.rb
74
76
  - lib/dblista/info.rb
75
77
  - lib/dblista/list/bot.rb
76
78
  - lib/dblista/list/server.rb
@@ -80,6 +82,7 @@ files:
80
82
  - lib/dblista/user/client.rb
81
83
  - lib/dblista/user/notifications.rb
82
84
  - lib/dblista/user/rating.rb
85
+ - lib/dblista/user/verification.rb
83
86
  - lib/dblista/user/voting.rb
84
87
  - lib/dblista/version.rb
85
88
  homepage: https://github.com/marek12306/dblista-wrapper-ruby