dblista 0.1.0 → 0.1.5
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 +3 -3
- data/dblista.gemspec +1 -0
- data/lib/dblista.rb +10 -7
- data/lib/dblista/errors.rb +2 -0
- data/lib/dblista/user/actions.rb +1 -1
- data/lib/dblista/user/boosting.rb +1 -2
- data/lib/dblista/user/client.rb +18 -0
- data/lib/dblista/user/notifications.rb +20 -0
- data/lib/dblista/user/rating.rb +1 -1
- data/lib/dblista/user/voting.rb +1 -1
- data/lib/dblista/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8a9f1ef63473322f8f5cfb544e460fe77740bfba0bf6e767be8d583f2906cb6
|
4
|
+
data.tar.gz: 855aeed578c2e189b9c57098e1978b24c1a38a2225ddb232fa84959f6ac2c264
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc04945b098ae8850aac02baec8cc6d20fc8f6388ec60e86a8ac6533d00b85d6439613ea7da5ba5a0dc097f95bba79c4f09b3a718fda7954215723d1ab887bb3
|
7
|
+
data.tar.gz: 3c94d344e3c0e5f61a0114daa40845dfd8d83d60baaa2f2ec942b7618e37c0d6bd5143dfaf1b3b110f5721daa6e38b62df84617695f899477eed4119ff0b9723
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
# DBLista
|
1
|
+
# DBLista Ruby wrapper [](https://badge.fury.io/rb/dblista)
|
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)
|
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.
|
6
6
|
|
7
7
|
## Instalacja
|
8
8
|
|
@@ -36,6 +36,6 @@ top = DBLista::List::Bot.top
|
|
36
36
|
puts top['data'].inspect
|
37
37
|
```
|
38
38
|
|
39
|
-
##
|
39
|
+
## Licencja
|
40
40
|
|
41
41
|
Ten gem jest dostępny na licencji [MIT License](https://opensource.org/licenses/MIT). Rób z nim co chcesz.
|
data/dblista.gemspec
CHANGED
@@ -12,6 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.summary = %q{Wrapper for dblista.pl API}
|
13
13
|
spec.homepage = "https://github.com/marek12306/dblista-wrapper-ruby"
|
14
14
|
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = '>= 2.4'
|
15
16
|
|
16
17
|
# Specify which files should be added to the gem when it is released.
|
17
18
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
data/lib/dblista.rb
CHANGED
@@ -22,12 +22,6 @@ module DBLista
|
|
22
22
|
# Regexp for checking if string is a number
|
23
23
|
IS_NUMBER = /^\d+$/.freeze
|
24
24
|
|
25
|
-
# @!visibility private
|
26
|
-
def self._get(path)
|
27
|
-
req = URI.open("#{DBLista::API_PATH}#{path}")
|
28
|
-
JSON.parse req.read
|
29
|
-
end
|
30
|
-
|
31
25
|
def self._https(uri)
|
32
26
|
Net::HTTP.new(uri.host, uri.port).tap do |http|
|
33
27
|
http.use_ssl = true
|
@@ -40,7 +34,16 @@ module DBLista
|
|
40
34
|
req['Content-Type'] = 'application/json'
|
41
35
|
req['Authorization'] = token if token
|
42
36
|
response = _https(uri).request(req)
|
43
|
-
JSON.parse response.body
|
37
|
+
result = JSON.parse response.body
|
38
|
+
raise DBLista::Error, result['error'].capitalize unless result['status'] == 'success'
|
39
|
+
result
|
40
|
+
end
|
41
|
+
|
42
|
+
# @!visibility private
|
43
|
+
def self._get(path, token = nil)
|
44
|
+
uri = URI("#{DBLista::API_PATH}#{path}")
|
45
|
+
req = Net::HTTP::Get.new(uri)
|
46
|
+
_handle_request(req, uri, token, nil)
|
44
47
|
end
|
45
48
|
|
46
49
|
# @!visibility private
|
data/lib/dblista/errors.rb
CHANGED
data/lib/dblista/user/actions.rb
CHANGED
data/lib/dblista/user/client.rb
CHANGED
@@ -4,6 +4,7 @@ require_relative './actions'
|
|
4
4
|
require_relative './boosting'
|
5
5
|
require_relative './rating'
|
6
6
|
require_relative './voting'
|
7
|
+
require_relative './notifications'
|
7
8
|
|
8
9
|
# User module - client + client modules
|
9
10
|
module DBLista::User
|
@@ -21,6 +22,7 @@ module DBLista::User
|
|
21
22
|
include DBLista::User::Actions
|
22
23
|
include DBLista::User::Boosting
|
23
24
|
include DBLista::User::Rating
|
25
|
+
include DBLista::User::Notifications
|
24
26
|
|
25
27
|
# Allowed entity types to use
|
26
28
|
ALLOWED_TYPES = %i[bot server].freeze
|
@@ -31,6 +33,22 @@ module DBLista::User
|
|
31
33
|
raise DBLista::Error, DBLista::Errors::TOKEN_NOT_PROVIDED unless token
|
32
34
|
|
33
35
|
@token = token
|
36
|
+
|
37
|
+
raise DBLista::Error, DBLista::Errors::INVALID_TOKEN unless me['status'] == 'success'
|
38
|
+
end
|
39
|
+
|
40
|
+
# Fetches information about current user
|
41
|
+
#
|
42
|
+
# @return [Hash] raw data from DBLista
|
43
|
+
def me
|
44
|
+
DBLista._get('/users/me', @token)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Fetches current user guilds
|
48
|
+
#
|
49
|
+
# @return [Hash] raw data from DBLista
|
50
|
+
def guilds
|
51
|
+
DBLista._get('/users/me/guilds', @token)
|
34
52
|
end
|
35
53
|
end
|
36
54
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DBLista::User
|
4
|
+
# User client - notifications
|
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
|
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
|
19
|
+
end
|
20
|
+
end
|
data/lib/dblista/user/rating.rb
CHANGED
data/lib/dblista/user/voting.rb
CHANGED
data/lib/dblista/version.rb
CHANGED
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.
|
4
|
+
version: 0.1.5
|
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-
|
11
|
+
date: 2020-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -78,6 +78,7 @@ files:
|
|
78
78
|
- lib/dblista/user/actions.rb
|
79
79
|
- lib/dblista/user/boosting.rb
|
80
80
|
- lib/dblista/user/client.rb
|
81
|
+
- lib/dblista/user/notifications.rb
|
81
82
|
- lib/dblista/user/rating.rb
|
82
83
|
- lib/dblista/user/voting.rb
|
83
84
|
- lib/dblista/version.rb
|
@@ -93,7 +94,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
93
94
|
requirements:
|
94
95
|
- - ">="
|
95
96
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
97
|
+
version: '2.4'
|
97
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
99
|
requirements:
|
99
100
|
- - ">="
|