dblista 0.4.1 → 0.6.3

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: 25f9fc3a7d2556a54dafc9073ac06ef3592296360486068d00c17aae37db688f
4
- data.tar.gz: 2274d8e90f6583e914c0c1e50485d58d9862754449cbe3e23ac9245a3be96844
3
+ metadata.gz: eef98740edf560cead48533ff0182e034f5c10b3fd48b6e669cabb6b55df0263
4
+ data.tar.gz: 3fe559a04ab016a6eca76770d020f6faa29fb6c5347fcbfb5a9992ca52f21c99
5
5
  SHA512:
6
- metadata.gz: 42cf0410d0357273ea2406e3f1053b24a4cda7ee64fafacf2da20d8c5e7f8c885a0136691c39dd27898a906485385f695f9c09243beb083a1a71fd4d7741fbf6
7
- data.tar.gz: 3ce4828266de795597277dfbcb5b0506e86d4974ebf11ad0d46a09173accab39845e9681ba46251e2c67a0c174de0c459aff6709287a944591c243400572d260
6
+ metadata.gz: 4172050fc532367befe9cdd299c02ae74cd24054e894b39256c06739a82b04ac0c2922525ee0d6a5d85f2500b206c1d9de6eeb2bfc8ca0f87d2b123504326b2a
7
+ data.tar.gz: 9a7516f152967a23e7c6caf2cf48bda9e58f9ba99e01b004a31b1b48434641df4f23f3aadf1ab7dd4ff85b3c1020b10793af1c2fd897c5918992e77f88968737
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dblista (0.4.1)
4
+ dblista (0.6.2)
5
5
  zache
6
6
 
7
7
  GEM
@@ -25,6 +25,7 @@ GEM
25
25
  zache (0.12.0)
26
26
 
27
27
  PLATFORMS
28
+ ruby
28
29
  x86-mingw32
29
30
 
30
31
  DEPENDENCIES
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, serwerów oraz ich 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._get("/bots/list/top/0?limit=1000000")
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._get("/servers/list/top/0?limit=1000000")
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.1'
5
+ VERSION = '0.6.3'
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.1
4
+ version: 0.6.3
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-06 00:00:00.000000000 Z
11
+ date: 2020-11-16 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
@@ -123,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
124
  - !ruby/object:Gem::Version
124
125
  version: '0'
125
126
  requirements: []
126
- rubygems_version: 3.0.3
127
+ rubygems_version: 3.1.2
127
128
  signing_key:
128
129
  specification_version: 4
129
130
  summary: Wrapper for dblista.pl API