dblista 0.3.1 → 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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/dblista.rb +1 -2
- data/lib/dblista/list/bot.rb +1 -1
- data/lib/dblista/user/actions.rb +53 -53
- data/lib/dblista/user/boosting.rb +22 -22
- data/lib/dblista/user/client.rb +2 -2
- data/lib/dblista/user/notifications.rb +42 -42
- data/lib/dblista/user/rating.rb +28 -28
- data/lib/dblista/user/verification.rb +29 -29
- data/lib/dblista/user/voting.rb +11 -11
- data/lib/dblista/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a839df00612d366d1a0184c647cdce72895f1ee02d71c25deb2e76ae78c7026
|
4
|
+
data.tar.gz: 4922b94a22e10332f564ef628058664204c3904c794e1381cab452478c24af8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9131862894f3adfaba7fb2a0add9f7fb31f423a8a94ebbd19efb8d1f84f8c14e8ee9acec3c1742a3eef0cc2e02cb8f228f5ab3eb98b5e6ebe8de0427b4f2d14
|
7
|
+
data.tar.gz: 3105e3459bea2a2c8f33f1f4470ead0d103d6757396bdde267e4b323cd5839e573d90d63d47ab6b3756083cf0e5f9a18740b2a844629ddc06ceca51ea6ab6150
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/lib/dblista.rb
CHANGED
@@ -38,6 +38,7 @@ module DBLista
|
|
38
38
|
response = _https(uri).request(req)
|
39
39
|
result = JSON.parse response.body
|
40
40
|
raise DBLista::Error, result['error'].capitalize unless result['status'] == 'success'
|
41
|
+
|
41
42
|
result['data']
|
42
43
|
end
|
43
44
|
|
@@ -81,8 +82,6 @@ module DBLista
|
|
81
82
|
|
82
83
|
# @!visibility private
|
83
84
|
def self._limit_integer(input)
|
84
|
-
puts input
|
85
|
-
puts input.is_a?(Integer)
|
86
85
|
raise DBLista::Error, DBLista::Errors::LIMIT_INTEGER unless input.is_a?(Integer)
|
87
86
|
end
|
88
87
|
end
|
data/lib/dblista/list/bot.rb
CHANGED
data/lib/dblista/user/actions.rb
CHANGED
@@ -5,58 +5,58 @@ require 'json'
|
|
5
5
|
module DBLista::User
|
6
6
|
# User client - actions
|
7
7
|
module Actions
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
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)
|
16
|
+
|
17
|
+
DBLista._post("/#{type}s", body, @token)
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
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)
|
29
|
+
|
30
|
+
DBLista._put("/#{type}s", body, @token)
|
31
|
+
true
|
32
|
+
end
|
33
|
+
|
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
|
61
61
|
end
|
62
62
|
end
|
@@ -3,30 +3,30 @@
|
|
3
3
|
module DBLista::User
|
4
4
|
# User client - boosting
|
5
5
|
module Boosting
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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
|
-
|
16
|
-
|
17
|
-
|
15
|
+
DBLista._post("/#{type}s/#{id}/boost", nil, @token)
|
16
|
+
true
|
17
|
+
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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)
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
DBLista._delete("/#{type}s/#{id}/boost", nil, @token)
|
29
|
+
true
|
30
|
+
end
|
31
31
|
end
|
32
32
|
end
|
data/lib/dblista/user/client.rb
CHANGED
@@ -13,11 +13,11 @@ module DBLista::User
|
|
13
13
|
#
|
14
14
|
# @example Server voting
|
15
15
|
# client = DBLista::User::Client.new "USER_TOKEN"
|
16
|
-
#
|
16
|
+
# client.vote(123456789012345678, :server)
|
17
17
|
#
|
18
18
|
# @example Bot rating
|
19
19
|
# client = DBLista::User::Client.new "USER_TOKEN"
|
20
|
-
#
|
20
|
+
# client.rate(123456789012345678, 5, 'Nice bot')
|
21
21
|
class Client
|
22
22
|
include DBLista::User::Voting
|
23
23
|
include DBLista::User::Actions
|
@@ -3,50 +3,50 @@
|
|
3
3
|
module DBLista::User
|
4
4
|
# User client - notifications
|
5
5
|
module Notifications
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
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
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
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
|
51
51
|
end
|
52
52
|
end
|
data/lib/dblista/user/rating.rb
CHANGED
@@ -3,36 +3,36 @@
|
|
3
3
|
module DBLista::User
|
4
4
|
# User client - rating
|
5
5
|
module Rating
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
DBLista._post("/#{type}s/#{id}/rate", {
|
18
|
+
rating: rating,
|
19
|
+
details: details
|
20
|
+
}, @token)
|
21
|
+
true
|
22
|
+
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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)
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
DBLista._delete("/#{type}s/#{id}/rate/#{target_id}", nil, @token)
|
35
|
+
true
|
36
|
+
end
|
37
37
|
end
|
38
38
|
end
|
@@ -5,39 +5,39 @@ require 'cgi'
|
|
5
5
|
module DBLista::User
|
6
6
|
# User client - verification (only for staff)
|
7
7
|
module Verification
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
DBLista._post("/bots/#{id}/approve?reason=#{CGI.escape reason}", nil, @token)
|
17
|
+
true
|
18
|
+
end
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
DBLista._post("/bots/#{id}/reject?reason=#{CGI.escape reason}", nil, @token)
|
29
|
+
true
|
30
|
+
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
DBLista._post("/bots/#{id}/set-pending", nil, @token)
|
40
|
+
true
|
41
|
+
end
|
42
42
|
end
|
43
43
|
end
|
data/lib/dblista/user/voting.rb
CHANGED
@@ -3,17 +3,17 @@
|
|
3
3
|
module DBLista::User
|
4
4
|
# User client - voting
|
5
5
|
module Voting
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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
|
-
|
16
|
-
|
17
|
-
|
15
|
+
DBLista._post("/#{type}s/#{id}/vote", nil, @token)
|
16
|
+
true
|
17
|
+
end
|
18
18
|
end
|
19
19
|
end
|
data/lib/dblista/version.rb
CHANGED