bitodeme 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +9 -0
- data/lib/bitodeme/auth.rb +8 -3
- data/lib/bitodeme/conn.rb +2 -2
- data/lib/bitodeme/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47c1bccb6089399d31440eab810a1b4c6ac210e0
|
4
|
+
data.tar.gz: '09d81264d360aa21da27fc71d5be93651365edbf'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ad50422db90dac7723b63a2f9ae6d334a37388b3b86aee943c2e62a0443055bd13dded7e644727f5826dc1fe6b65bc1374fbeb7af426bef59b99d61977afdc8
|
7
|
+
data.tar.gz: 6bb4e53305ab0d79c98fd89d16ffc9f51b10fb1bd8b4767bcd691f7a1835c5454c178bfc07b9c59405a4509c3251f2e3ea20e123da4b616f0fb3c43b5bf67312
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -131,6 +131,15 @@ withdrawal = Bitodeme.create_withdrawal(withdrawal)
|
|
131
131
|
|
132
132
|
All plural methods support `pagination`(`per_page` and `page`) and `since` query parameters
|
133
133
|
|
134
|
+
### Authentication
|
135
|
+
|
136
|
+
Bitodeme endpoint requests automatically authenticated by `bitodeme` library. But in case you need, you can fetch access token by running the command below. The token automatically renews itself, so you don't need to worry about token expiration. Note: Auth class instance is shared across the threads, so everytime you should get the same token until it expires.
|
137
|
+
|
138
|
+
```ruby
|
139
|
+
auth = Bitodeme::Auth.build
|
140
|
+
auth.token
|
141
|
+
```
|
142
|
+
|
134
143
|
## Standalone Usage
|
135
144
|
|
136
145
|
In project root folder:
|
data/lib/bitodeme/auth.rb
CHANGED
@@ -4,9 +4,10 @@ module Bitodeme
|
|
4
4
|
# OAuth2 client credentials authenticator for Bitodeme
|
5
5
|
class Auth
|
6
6
|
extend Forwardable
|
7
|
+
include Singleton
|
7
8
|
|
8
|
-
def
|
9
|
-
|
9
|
+
def self.build
|
10
|
+
$bitodeme_auth ||= instance
|
10
11
|
end
|
11
12
|
|
12
13
|
# Valid access token for Bitodeme endpoints
|
@@ -17,7 +18,7 @@ module Bitodeme
|
|
17
18
|
|
18
19
|
private
|
19
20
|
|
20
|
-
USER_AGENT = "Ruby / Bitodeme v#{Bitodeme::VERSION}".freeze
|
21
|
+
USER_AGENT = "Ruby / Bitodeme::Auth v#{Bitodeme::VERSION}".freeze
|
21
22
|
GRANT_TYPE = 'client_credentials'.freeze
|
22
23
|
AUTH_ENDPOINT = '/api/v1/tokens'.freeze
|
23
24
|
|
@@ -26,6 +27,10 @@ module Bitodeme
|
|
26
27
|
|
27
28
|
attr_reader :access_token, :expires_at
|
28
29
|
|
30
|
+
def initialize
|
31
|
+
@expires_at = 0
|
32
|
+
end
|
33
|
+
|
29
34
|
def expired?
|
30
35
|
Time.now.to_i > expires_at
|
31
36
|
end
|
data/lib/bitodeme/conn.rb
CHANGED
@@ -6,7 +6,7 @@ module Bitodeme
|
|
6
6
|
class Conn
|
7
7
|
include Singleton
|
8
8
|
|
9
|
-
USER_AGENT = "Ruby / Bitodeme v#{Bitodeme::VERSION}".freeze
|
9
|
+
USER_AGENT = "Ruby / Bitodeme::Conn v#{Bitodeme::VERSION}".freeze
|
10
10
|
|
11
11
|
def self.build
|
12
12
|
$bitodeme_conn ||= instance.send(:conn)
|
@@ -17,7 +17,7 @@ module Bitodeme
|
|
17
17
|
attr_reader :auth, :hostname
|
18
18
|
|
19
19
|
def initialize
|
20
|
-
@auth = Bitodeme::Auth.
|
20
|
+
@auth = Bitodeme::Auth.build
|
21
21
|
@hostname = Bitodeme.config.hostname
|
22
22
|
end
|
23
23
|
|
data/lib/bitodeme/version.rb
CHANGED