dblista 0.4.0 → 0.6.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: 20bc126654c09a9c27d1a5601a5fd6ca6f78d97b434c4c72d0f053b790a55bcf
4
- data.tar.gz: b37f3e82284ca081f443422a5b2b1a34c2beafa3ae5233f5533e2b2ce557e87d
3
+ metadata.gz: b31b6ae4257bc177d0ed4282e37170e4a10448e756b59d750f67f9e250e36518
4
+ data.tar.gz: 1821a94d6543ac36ec993f90252949cfe72c9511d1c9fe8a73e4fd16f56bc4db
5
5
  SHA512:
6
- metadata.gz: 2e8c060120beae4594c8b5e9faa0b81bbc29dbe08c4fb0f27a61afe7816092594dc5ef205565538599aa17a97352b53b853c256b5faa5dca68c6dcbce11c613d
7
- data.tar.gz: 6992b4c8b78a17f307d2ed2c2225c5e333cee7630c9cbf485af5c661fc89b89348c595848a8ea205e0435136555a3dcbbf85cbca0505fce87d603126b2987073
6
+ metadata.gz: 526fa00ddb1bdec907aa16a55c6a8dccb41600f5feca339381c5205842a2063a2dd741ea86709f58c70d92220515f8c26b3c0282c15dc0d6989409ee74a384c6
7
+ data.tar.gz: f37c6d987f425bec392883237e7c4f36a25091683523505f424a40fbdb9b4d127194f67aeaa33c2961225ad98345045d04c4fc89f9bd77423d68271158547af3
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dblista (0.4.0)
4
+ dblista (0.6.2)
5
5
  zache
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -2,7 +2,14 @@
2
2
 
3
3
  [Dokumentacja](https://www.rubydoc.info/github/marek12306/dblista-wrapper-ruby)
4
4
 
5
- Gem pozwalający na komunikację z API DBListy. Pozwala m.in. na automatyczne wysyłanie statystyk (dla botów napisanych w Discordrb), CRUD botów i serwerów oraz pare innych rzeczy.
5
+ Gem pozwalający na komunikację z API DBListy.
6
+
7
+ Pozwala na:
8
+
9
+ - Automatyczne/ręczne wysyłanie statystyk
10
+ - Kontrolowanie kontem użytkownika
11
+ - Pobieranie różnych list botów oraz serwerów oraz wyszukiwanie
12
+ - Pobieranie informacji o botach, serwerach oraz użytkownikach
6
13
 
7
14
  ## Instalacja
8
15
 
@@ -61,7 +61,7 @@ module DBLista::List
61
61
  # @return [Array] array of raw bot data from DBLista
62
62
  def self.all
63
63
  DBLista._cache(:botsall) do
64
- DBLista::List::Bot.top(0, 100_000_000)
64
+ DBLista._get('/bots/list/top/0?limit=1000000')
65
65
  end
66
66
  end
67
67
 
@@ -36,7 +36,7 @@ module DBLista::List
36
36
  # @return [Array] array of raw server data from DBLista
37
37
  def self.all
38
38
  DBLista._cache(:serversall) do
39
- DBLista::List::Server.top(0, 100_000_000)
39
+ DBLista._get('/servers/list/top/0?limit=1000000')
40
40
  end
41
41
  end
42
42
 
@@ -58,5 +58,23 @@ module DBLista::User
58
58
  }, @token)
59
59
  true
60
60
  end
61
+
62
+ # Generates token for bot
63
+ #
64
+ # @param id [Integer] bot ID
65
+ # @return [Hash] raw data from DBLista
66
+ def generate_token(id)
67
+ DBLista._validate_id id
68
+ DBLista._get("/bots/stats/#{id}?token=#{@token}")
69
+ end
70
+
71
+ # Resets token for bot
72
+ #
73
+ # @param id [Integer] bot ID
74
+ # @return [Hash] raw data from DBLista
75
+ def reset_token(id)
76
+ DBLista._validate_id id
77
+ DBLista._post("/bots/stats/#{id}/reset", nil, @token)
78
+ end
61
79
  end
62
80
  end
@@ -8,6 +8,7 @@ require_relative './rating'
8
8
  require_relative './voting'
9
9
  require_relative './notifications'
10
10
  require_relative './verification'
11
+ require_relative './info'
11
12
 
12
13
  # User module - client + client modules
13
14
  module DBLista::User
@@ -27,6 +28,7 @@ module DBLista::User
27
28
  include DBLista::User::Rating
28
29
  include DBLista::User::Notifications
29
30
  include DBLista::User::Verification
31
+ include DBLista::User::Information
30
32
 
31
33
  # Allowed entity types to use
32
34
  ALLOWED_TYPES = %i[bot server].freeze
@@ -54,7 +56,7 @@ module DBLista::User
54
56
  # Fetches current user guilds
55
57
  #
56
58
  # @return [Hash] raw data from DBLista
57
- def guilds
59
+ def joined_guilds
58
60
  @cache.get(:guilds, lifetime: DBLista::CACHE_LIFETIME) do
59
61
  DBLista._get('/users/me/guilds', @token)
60
62
  end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DBLista::User
4
+ # User client - information
5
+ module Information
6
+ # Fetches your servers
7
+ #
8
+ # @return [Hash] raw data from DBLista
9
+ def servers
10
+ DBLista._get('/servers/user/me', @token)
11
+ end
12
+
13
+ # Fetches your bots
14
+ #
15
+ # @return [Hash] raw data from DBLista
16
+ def bots
17
+ DBLista._get('/bots/user/me', @token)
18
+ end
19
+ end
20
+ end
@@ -34,5 +34,40 @@ module DBLista::User
34
34
  DBLista._delete("/#{type}s/#{id}/rate/#{target_id}", nil, @token)
35
35
  true
36
36
  end
37
+
38
+ # Reports rate of a selected bot/server
39
+ #
40
+ # @param id [Integer] ID
41
+ # @param target_id [Integer] target user to remove rate from (for owners only)
42
+ # @param report_reason [String] reason of report (details)
43
+ # @param type [Symbol] type of entity (bot/server)
44
+ # @return [Boolean] true if operation succeded
45
+ def report_rate(id, rate_id, report_reason = 'Brak powodu', type = :bot)
46
+ DBLista._validate_id id
47
+ raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless DBLista::User::Client::ALLOWED_TYPES.include?(type)
48
+
49
+ DBLista._post("/#{type}s/#{id}/ratings/#{rate_id}/report", {
50
+ reportReason: report_reason.to_s
51
+ }, @token)
52
+ true
53
+ end
54
+
55
+ # Fetches all rate reports
56
+ #
57
+ # @return [Hash] raw data from DBLista
58
+ def reports
59
+ DBLista._get('/reports')
60
+ end
61
+
62
+ # Deletes rate report
63
+ #
64
+ # @param id [Integer] report ID
65
+ # @return [Hash] raw data from DBLista
66
+ def delete_report(id, type = :bot)
67
+ raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless DBLista::User::Client::ALLOWED_TYPES.include?(type)
68
+
69
+ DBLista._delete("/reports/#{id}", nil, @token)
70
+ true
71
+ end
37
72
  end
38
73
  end
@@ -13,7 +13,7 @@ module DBLista::User
13
13
  def approve(id, reason = 'Brak powodu')
14
14
  DBLista._validate_id id
15
15
 
16
- DBLista._post("/bots/#{id}/approve?reason=#{CGI.escape reason}", nil, @token)
16
+ DBLista._post("/bots/verify/#{id}/approve?reason=#{CGI.escape reason}", nil, @token)
17
17
  true
18
18
  end
19
19
 
@@ -25,7 +25,7 @@ module DBLista::User
25
25
  def reject(id, reason = 'Brak powodu')
26
26
  DBLista._validate_id id
27
27
 
28
- DBLista._post("/bots/#{id}/reject?reason=#{CGI.escape reason}", nil, @token)
28
+ DBLista._post("/bots/verify/#{id}/reject?reason=#{CGI.escape reason}", nil, @token)
29
29
  true
30
30
  end
31
31
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  module DBLista
4
4
  # Wrapper version
5
- VERSION = '0.4.0'
5
+ VERSION = '0.6.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.4.0
4
+ version: 0.6.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-05 00:00:00.000000000 Z
11
+ date: 2020-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zache
@@ -99,6 +99,7 @@ files:
99
99
  - lib/dblista/user/actions.rb
100
100
  - lib/dblista/user/boosting.rb
101
101
  - lib/dblista/user/client.rb
102
+ - lib/dblista/user/info.rb
102
103
  - lib/dblista/user/notifications.rb
103
104
  - lib/dblista/user/rating.rb
104
105
  - lib/dblista/user/verification.rb