dblista 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: af5c06a56c095575ded742823dfeb531103e6746113c81a0c9a2e14081dd6d78
4
- data.tar.gz: 2ed0b2d32d232b0e5d51bc5f78488762ace9fda84de2d551aead67033fb25d54
3
+ metadata.gz: 7a839df00612d366d1a0184c647cdce72895f1ee02d71c25deb2e76ae78c7026
4
+ data.tar.gz: 4922b94a22e10332f564ef628058664204c3904c794e1381cab452478c24af8f
5
5
  SHA512:
6
- metadata.gz: 1ec8859f47192634b82352e48fb3198e32e5b1ee275c952844a8a1e2162393b098cfbf2e3f4ed5417b6a0442b8e1de88e73f367ae27cf023d5e6f57a9665dfa0
7
- data.tar.gz: 59e82924a1a5ebf293e62af219773ab5ddce35d72eb7f06258b1c0e8b01cc09ed9f25771a642f13dcbf9d07d991005a92b8ced9e72cd4bc5c3fd9fe938bcf94b
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.3.1)
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.inspect
36
+ puts top
37
37
  ```
38
38
 
39
39
  ## Licencja
@@ -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
@@ -8,7 +8,7 @@ require 'cgi'
8
8
  #
9
9
  # @example Fetch top 25 bots
10
10
  # top = DBLista::List::Bot.top
11
- # puts top.inspect
11
+ # puts top
12
12
  module DBLista::List
13
13
  # Bot lists
14
14
  module Bot
@@ -5,58 +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 [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
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
- # 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)
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
- true
17
- end
15
+ DBLista._post("/#{type}s/#{id}/boost", nil, @token)
16
+ true
17
+ end
18
18
 
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)
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
- DBLista._delete("/#{type}s/#{id}/boost", nil, @token)
29
- true
30
- end
28
+ DBLista._delete("/#{type}s/#{id}/boost", nil, @token)
29
+ true
30
+ end
31
31
  end
32
32
  end
@@ -13,11 +13,11 @@ module DBLista::User
13
13
  #
14
14
  # @example Server voting
15
15
  # client = DBLista::User::Client.new "USER_TOKEN"
16
- # response = client.vote(123456789012345678, :server)
16
+ # client.vote(123456789012345678, :server)
17
17
  #
18
18
  # @example Bot rating
19
19
  # client = DBLista::User::Client.new "USER_TOKEN"
20
- # response = client.rate(123456789012345678, 5, 'Nice bot')
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
- # 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 [Boolean] true if operation succeded
16
- def clear_notifications
17
- DBLista._get('/users/me/notifications/clear', @token)
18
- true
19
- 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
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
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
- # 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
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
@@ -3,36 +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 [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)
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
- true
22
- end
17
+ DBLista._post("/#{type}s/#{id}/rate", {
18
+ rating: rating,
19
+ details: details
20
+ }, @token)
21
+ true
22
+ end
23
23
 
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)
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
- DBLista._delete("/#{type}s/#{id}/rate/#{target_id}", nil, @token)
35
- true
36
- end
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
- # 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
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
- DBLista._post("/bots/#{id}/approve?reason=#{CGI.escape reason}", nil, @token)
17
- true
18
- end
16
+ DBLista._post("/bots/#{id}/approve?reason=#{CGI.escape reason}", nil, @token)
17
+ true
18
+ end
19
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
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
- DBLista._post("/bots/#{id}/reject?reason=#{CGI.escape reason}", nil, @token)
29
- true
30
- end
28
+ DBLista._post("/bots/#{id}/reject?reason=#{CGI.escape reason}", nil, @token)
29
+ true
30
+ end
31
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
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
- DBLista._post("/bots/#{id}/set-pending", nil, @token)
40
- true
41
- end
39
+ DBLista._post("/bots/#{id}/set-pending", nil, @token)
40
+ true
41
+ end
42
42
  end
43
43
  end
@@ -3,17 +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 [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)
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
- true
17
- end
15
+ DBLista._post("/#{type}s/#{id}/vote", nil, @token)
16
+ true
17
+ end
18
18
  end
19
19
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module DBLista
4
4
  # Wrapper version
5
- VERSION = '0.3.1'
5
+ VERSION = '0.3.2'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dblista
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - deepivin