dblista 0.1.1 → 0.1.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: 03552046ae51c948da59280f1f33b786b5fb504365a5cc055756039e927b1db1
4
- data.tar.gz: b3c8a8ecf6f040e27ed63692969b8b966a561badd09ca69bf32b16bd81583d52
3
+ metadata.gz: 4ba88619d64539697aa11e51f60ecbf292729ae2d6d8c2ae3291caea28b40dc2
4
+ data.tar.gz: dcdcd9f0bb7482b30d0d388ea6cda59fad862267341e6b28e8e10bd558a0e3c2
5
5
  SHA512:
6
- metadata.gz: f748d302a492e25be43ffa01a74b4d8066bf82f7a0006188e93371c5db46dec7c5ceb38119bd92cebeb9889fd33ea02fa93c9e70890a8091f20de8711963ff33
7
- data.tar.gz: 8fd35536aa122579ab14c8014e3022f9289e3f489b294087a6ff9789d9d1c5700e11ed63edd60b6c8de94e542b8fde9efc91a64f179a441448bcd81f3d4c07a9
6
+ metadata.gz: 65e48135e27d24539322178ed7f7f27c437e7a54a2f22cf004780f9babad45b2baa96972f75f4c88e433e05f20be390453a1a6fdeb7b752da42d9e2b4929cb16
7
+ data.tar.gz: a3d951c2872d596ce2867b905df9d2e513d1c776ca89011c6b1b624a006dd590b66d370e413bc7213828fa317a0291d872f0a6767dec23a2621f61087c0fb12e
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dblista (0.1.1)
4
+ dblista (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # DBLista
1
+ # DBLista Ruby wrapper [![Gem Version](https://badge.fury.io/rb/dblista.svg)](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) oraz na CRUD botów oraz serwerów.
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
- ## License
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.
@@ -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
@@ -43,6 +37,13 @@ module DBLista
43
37
  JSON.parse response.body
44
38
  end
45
39
 
40
+ # @!visibility private
41
+ def self._get(path, token = nil)
42
+ uri = URI("#{DBLista::API_PATH}#{path}")
43
+ req = Net::HTTP::Get.new(uri)
44
+ _handle_request(req, uri, token, nil)
45
+ end
46
+
46
47
  # @!visibility private
47
48
  def self._post(path, data = nil, token = nil)
48
49
  uri = URI("#{DBLista::API_PATH}#{path}")
@@ -14,4 +14,6 @@ module DBLista::Errors
14
14
  QUERY_NOT_PROVIDED = 'Search query is not provided'
15
15
  # Raised when body is not a hash
16
16
  BODY_HASH = 'Body must be a hash'
17
+ # Raised when token is invalid or expired
18
+ INVALID_TOKEN = 'Invalid or expired token'
17
19
  end
@@ -31,6 +31,15 @@ module DBLista::User
31
31
  raise DBLista::Error, DBLista::Errors::TOKEN_NOT_PROVIDED unless token
32
32
 
33
33
  @token = token
34
+
35
+ raise DBLista::Error, DBLista::Errors::INVALID_TOKEN unless me['status'] == 'success'
36
+ end
37
+
38
+ # Fetches information about user
39
+ #
40
+ # @return [Hash] raw data from DBLista
41
+ def me
42
+ DBLista._get('/users/me', @token)
34
43
  end
35
44
  end
36
45
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module DBLista
4
4
  # Wrapper version
5
- VERSION = '0.1.1'
5
+ VERSION = '0.1.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.1.1
4
+ version: 0.1.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-03 00:00:00.000000000 Z
11
+ date: 2020-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler