bitodeme 0.2.9 → 0.3.0
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/.env.example +1 -0
- data/.env.test +1 -0
- data/Gemfile.lock +4 -4
- data/README.md +12 -11
- data/bitodeme.gemspec +1 -1
- data/lib/bitodeme.rb +9 -9
- data/lib/bitodeme/auth.rb +4 -2
- data/lib/bitodeme/configuration.rb +3 -1
- data/lib/bitodeme/conn.rb +6 -1
- data/lib/bitodeme/resources/base.rb +4 -4
- data/lib/bitodeme/resources/currency.rb +1 -3
- data/lib/bitodeme/unauthorized_conn.rb +6 -1
- data/lib/bitodeme/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6962c2eeb7db329d119650c8b545f696426d2197
|
4
|
+
data.tar.gz: 6f9de2c83dd3600674f37d8fa45f52b92b341eeb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df538d17c4880d7f45df06d459c8399aeb9587464f8d95019aa07c0d37423095b93c36a445a8a71fed41cd17a351772dab84e5b05446c306f810327f27a48168
|
7
|
+
data.tar.gz: 240ec81d5a4aecf1df9a23fd4b0cd590bbb50f0628107563ff7f580110b0be9e522aa80352aba3a87f60150de9d1a580d79ddfb22143bb0f40d74020b97606a2
|
data/.env.example
CHANGED
data/.env.test
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bitodeme (0.2.
|
4
|
+
bitodeme (0.2.9)
|
5
5
|
dotenv (~> 2.2, >= 2.2)
|
6
|
-
faraday (~> 0.
|
6
|
+
faraday (~> 0.15.2)
|
7
7
|
faraday_middleware (~> 0.12)
|
8
8
|
|
9
9
|
GEM
|
@@ -23,9 +23,9 @@ GEM
|
|
23
23
|
thread_safe (~> 0.3, >= 0.3.1)
|
24
24
|
diff-lcs (1.3)
|
25
25
|
docile (1.1.5)
|
26
|
-
dotenv (2.
|
26
|
+
dotenv (2.5.0)
|
27
27
|
equalizer (0.0.11)
|
28
|
-
faraday (0.
|
28
|
+
faraday (0.15.2)
|
29
29
|
multipart-post (>= 1.2, < 3)
|
30
30
|
faraday_middleware (0.12.2)
|
31
31
|
faraday (>= 0.7.4, < 1.0)
|
data/README.md
CHANGED
@@ -24,6 +24,7 @@ Then set environment vars:
|
|
24
24
|
export BITODEME_HOSTNAME=alpha.bitodeme.com; # Bitodeme Domain
|
25
25
|
export BITODEME_CLIENT_ID=clientidentifier; # API key
|
26
26
|
export BITODEME_CLIENT_SECRET=clientsecret; # API secret
|
27
|
+
export BITODEME_CLIENT_LOGGING=true; # To enable logging (optional)
|
27
28
|
```
|
28
29
|
|
29
30
|
## Usage
|
@@ -32,17 +33,17 @@ export BITODEME_CLIENT_SECRET=clientsecret; # API secret
|
|
32
33
|
|
33
34
|
Fetch all currencies
|
34
35
|
```ruby
|
35
|
-
currencies = Bitodeme.
|
36
|
+
currencies = Bitodeme.list_currencies
|
36
37
|
```
|
37
38
|
|
38
39
|
Fetch all updated currencies after given time in milli seconds
|
39
40
|
```ruby
|
40
|
-
updated_currencies = Bitodeme.
|
41
|
+
updated_currencies = Bitodeme.list_currencies(since: 1604131436476)
|
41
42
|
```
|
42
43
|
|
43
44
|
Pagination
|
44
45
|
```ruby
|
45
|
-
last_10_currencies = Bitodeme.
|
46
|
+
last_10_currencies = Bitodeme.list_currencies(page: 1, per_page: 10)
|
46
47
|
```
|
47
48
|
|
48
49
|
### Deposit (Unconfirmed deposits only)
|
@@ -50,38 +51,38 @@ last_10_currencies = Bitodeme.currencies(page: 1, per_page: 10)
|
|
50
51
|
Fetch all unconfirmed deposits
|
51
52
|
|
52
53
|
```ruby
|
53
|
-
deposits = Bitodeme.
|
54
|
+
deposits = Bitodeme.list_deposits
|
54
55
|
```
|
55
56
|
|
56
57
|
### Funds
|
57
58
|
|
58
59
|
Fetch all funds
|
59
60
|
```ruby
|
60
|
-
funds = Bitodeme.
|
61
|
+
funds = Bitodeme.list_funds
|
61
62
|
```
|
62
63
|
|
63
64
|
Fetch all updated funds after given time
|
64
65
|
```ruby
|
65
|
-
updated_funds = Bitodeme.
|
66
|
+
updated_funds = Bitodeme.list_funds(since: 1513418293)
|
66
67
|
```
|
67
68
|
|
68
69
|
### FundAddress
|
69
70
|
|
70
71
|
Fetch all fund addresses
|
71
72
|
```ruby
|
72
|
-
fund_addresses = Bitodeme.
|
73
|
+
fund_addresses = Bitodeme.list_fund_addresses
|
73
74
|
```
|
74
75
|
|
75
76
|
Fetch all updated fund_addresses after given time
|
76
77
|
```ruby
|
77
|
-
updated_fund_addresses = Bitodeme.
|
78
|
+
updated_fund_addresses = Bitodeme.list_fund_addresses(since: 1513418293)
|
78
79
|
```
|
79
80
|
|
80
81
|
### Invoice
|
81
82
|
|
82
83
|
Fetch an invoice information
|
83
84
|
```ruby
|
84
|
-
invoice = Bitodeme.
|
85
|
+
invoice = Bitodeme.find_invoice('id')
|
85
86
|
```
|
86
87
|
|
87
88
|
Build & create an invoice
|
@@ -109,12 +110,12 @@ invoice = Bitodeme.create_invoice(invoice)
|
|
109
110
|
|
110
111
|
Fetch all transaction logs (deposits, withdrawals and fees)
|
111
112
|
```ruby
|
112
|
-
transaction_logs = Bitodeme.
|
113
|
+
transaction_logs = Bitodeme.list_transaction_logs
|
113
114
|
```
|
114
115
|
|
115
116
|
Find a transaction_log
|
116
117
|
```ruby
|
117
|
-
transaction_log = Bitodeme.
|
118
|
+
transaction_log = Bitodeme.find_transaction_log('id')
|
118
119
|
```
|
119
120
|
|
120
121
|
### Withdrawal (Send money)
|
data/bitodeme.gemspec
CHANGED
@@ -29,6 +29,6 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_development_dependency 'vcr', '~> 4.0'
|
30
30
|
|
31
31
|
spec.add_dependency 'dotenv', '~> 2.2', '>= 2.2'
|
32
|
-
spec.add_dependency 'faraday', '~> 0.
|
32
|
+
spec.add_dependency 'faraday', '~> 0.15.2'
|
33
33
|
spec.add_dependency 'faraday_middleware', '~> 0.12'
|
34
34
|
end
|
data/lib/bitodeme.rb
CHANGED
@@ -28,17 +28,17 @@ Withdrawal = Bitodeme::Resource::Withdrawal
|
|
28
28
|
module Bitodeme
|
29
29
|
extend SingleForwardable
|
30
30
|
|
31
|
-
def_delegator :Currency, :all, :
|
32
|
-
def_delegator :Deposit, :all, :
|
33
|
-
def_delegator :Fund, :find, :
|
34
|
-
def_delegator :Fund, :all, :
|
35
|
-
def_delegator :FundAddress, :find, :
|
36
|
-
def_delegator :FundAddress, :all, :
|
31
|
+
def_delegator :Currency, :all, :list_currencies
|
32
|
+
def_delegator :Deposit, :all, :list_deposits
|
33
|
+
def_delegator :Fund, :find, :find_fund
|
34
|
+
def_delegator :Fund, :all, :list_funds
|
35
|
+
def_delegator :FundAddress, :find, :find_fund_address
|
36
|
+
def_delegator :FundAddress, :all, :list_fund_addresses
|
37
37
|
def_delegator :Invoice, :build, :build_invoice
|
38
38
|
def_delegator :Invoice, :create, :create_invoice
|
39
|
-
def_delegator :Invoice, :find, :
|
40
|
-
def_delegator :TransactionLog, :find, :
|
41
|
-
def_delegator :TransactionLog, :all, :
|
39
|
+
def_delegator :Invoice, :find, :find_invoice
|
40
|
+
def_delegator :TransactionLog, :find, :find_transaction_log
|
41
|
+
def_delegator :TransactionLog, :all, :list_transaction_logs
|
42
42
|
def_delegator :Withdrawal, :build, :build_withdrawal
|
43
43
|
def_delegator :Withdrawal, :create, :create_withdrawal
|
44
44
|
|
data/lib/bitodeme/auth.rb
CHANGED
@@ -24,10 +24,11 @@ module Bitodeme
|
|
24
24
|
|
25
25
|
private
|
26
26
|
|
27
|
+
GRANT_TYPE = 'client_credentials'.freeze
|
27
28
|
USER_AGENT = "Ruby / Bitodeme::Auth v#{Bitodeme::VERSION}".freeze
|
28
29
|
|
29
30
|
def_delegators :Bitodeme, :config
|
30
|
-
def_delegators :config, :hostname, :client_id, :client_secret
|
31
|
+
def_delegators :config, :hostname, :client_id, :client_secret, :logging
|
31
32
|
|
32
33
|
attr_reader :connection, :access_token, :expires_at
|
33
34
|
|
@@ -54,6 +55,7 @@ module Bitodeme
|
|
54
55
|
def build_connection
|
55
56
|
Faraday.new(faraday_opts) do |conn|
|
56
57
|
conn.request :json
|
58
|
+
conn.response :logger if logging
|
57
59
|
conn.response :json, content_type: /\bjson$/
|
58
60
|
conn.adapter Faraday.default_adapter
|
59
61
|
end
|
@@ -74,7 +76,7 @@ module Bitodeme
|
|
74
76
|
{
|
75
77
|
client_id: client_id,
|
76
78
|
client_secret: client_secret,
|
77
|
-
grant_type:
|
79
|
+
grant_type: GRANT_TYPE
|
78
80
|
}
|
79
81
|
end
|
80
82
|
end
|
@@ -7,7 +7,8 @@ module Bitodeme
|
|
7
7
|
|
8
8
|
attr_reader :hostname,
|
9
9
|
:client_id,
|
10
|
-
:client_secret
|
10
|
+
:client_secret,
|
11
|
+
:logging
|
11
12
|
|
12
13
|
def self.build
|
13
14
|
$bitodeme_configuration ||= instance
|
@@ -19,6 +20,7 @@ module Bitodeme
|
|
19
20
|
@hostname = ENV['BITODEME_HOSTNAME']
|
20
21
|
@client_id = ENV['BITODEME_CLIENT_ID']
|
21
22
|
@client_secret = ENV['BITODEME_CLIENT_SECRET']
|
23
|
+
@logging = ENV['BITODEME_CLIENT_LOGGING']
|
22
24
|
end
|
23
25
|
end
|
24
26
|
end
|
data/lib/bitodeme/conn.rb
CHANGED
@@ -3,6 +3,7 @@ require 'singleton'
|
|
3
3
|
module Bitodeme
|
4
4
|
# HTTP Connection for Bitodeme
|
5
5
|
class Conn
|
6
|
+
extend Forwardable
|
6
7
|
include Singleton
|
7
8
|
|
8
9
|
USER_AGENT = "Ruby / Bitodeme::Conn v#{Bitodeme::VERSION}".freeze
|
@@ -15,6 +16,9 @@ module Bitodeme
|
|
15
16
|
|
16
17
|
attr_reader :auth
|
17
18
|
|
19
|
+
def_delegators :Bitodeme, :config
|
20
|
+
def_delegators :config, :hostname, :logging
|
21
|
+
|
18
22
|
def initialize
|
19
23
|
@auth = Bitodeme::Auth.build
|
20
24
|
end
|
@@ -23,6 +27,7 @@ module Bitodeme
|
|
23
27
|
Faraday.new(faraday_opts) do |conn|
|
24
28
|
conn.request :oauth2, auth.token, token_type: :bearer
|
25
29
|
conn.request :json
|
30
|
+
conn.response :logger if logging
|
26
31
|
conn.response :json, content_type: /\bjson$/
|
27
32
|
conn.adapter Faraday.default_adapter
|
28
33
|
end
|
@@ -30,7 +35,7 @@ module Bitodeme
|
|
30
35
|
|
31
36
|
def faraday_opts
|
32
37
|
@faraday_opts ||= {
|
33
|
-
url: "https://#{
|
38
|
+
url: "https://#{hostname}",
|
34
39
|
headers: { 'User-Agent' => USER_AGENT }
|
35
40
|
}
|
36
41
|
end
|
@@ -11,10 +11,6 @@ module Bitodeme
|
|
11
11
|
class << self
|
12
12
|
private
|
13
13
|
|
14
|
-
def conn
|
15
|
-
Bitodeme::Conn.build
|
16
|
-
end
|
17
|
-
|
18
14
|
def _find(collection, resource, id)
|
19
15
|
item = get("/api/v1/#{collection}/#{id}").body.fetch(resource, {})
|
20
16
|
new(item)
|
@@ -40,6 +36,10 @@ module Bitodeme
|
|
40
36
|
query_params[:ends_at] = opts[:ends_at] if opts.key?(:ends_at)
|
41
37
|
query_params
|
42
38
|
end
|
39
|
+
|
40
|
+
def conn
|
41
|
+
Bitodeme::Conn.build
|
42
|
+
end
|
43
43
|
end
|
44
44
|
|
45
45
|
def to_h
|
@@ -51,15 +51,13 @@ module Bitodeme
|
|
51
51
|
|
52
52
|
private
|
53
53
|
|
54
|
-
def
|
54
|
+
def conn
|
55
55
|
Bitodeme::UnauthorizedConn.build
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
59
|
private
|
60
60
|
|
61
|
-
def_delegators :unauthorized_conn, :get
|
62
|
-
|
63
61
|
def initialize(params)
|
64
62
|
super(attrs: attrs, params: params)
|
65
63
|
end
|
@@ -3,6 +3,7 @@ require 'singleton'
|
|
3
3
|
module Bitodeme
|
4
4
|
# HTTP Connection for Bitodeme unauthorized endpoints
|
5
5
|
class UnauthorizedConn
|
6
|
+
extend Forwardable
|
6
7
|
include Singleton
|
7
8
|
|
8
9
|
USER_AGENT = "Ruby / Bitodeme::Conn v#{Bitodeme::VERSION}".freeze
|
@@ -13,9 +14,13 @@ module Bitodeme
|
|
13
14
|
|
14
15
|
private
|
15
16
|
|
17
|
+
def_delegators :Bitodeme, :config
|
18
|
+
def_delegators :config, :hostname, :logging
|
19
|
+
|
16
20
|
def connection
|
17
21
|
Faraday.new(faraday_opts) do |conn|
|
18
22
|
conn.request :json
|
23
|
+
conn.response :logger if logging
|
19
24
|
conn.response :json, content_type: /\bjson$/
|
20
25
|
conn.adapter Faraday.default_adapter
|
21
26
|
end
|
@@ -23,7 +28,7 @@ module Bitodeme
|
|
23
28
|
|
24
29
|
def faraday_opts
|
25
30
|
@faraday_opts ||= {
|
26
|
-
url: "https://#{
|
31
|
+
url: "https://#{hostname}",
|
27
32
|
headers: { 'User-Agent' => USER_AGENT }
|
28
33
|
}
|
29
34
|
end
|
data/lib/bitodeme/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitodeme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bitodeme Integrations Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -148,14 +148,14 @@ dependencies:
|
|
148
148
|
requirements:
|
149
149
|
- - "~>"
|
150
150
|
- !ruby/object:Gem::Version
|
151
|
-
version:
|
151
|
+
version: 0.15.2
|
152
152
|
type: :runtime
|
153
153
|
prerelease: false
|
154
154
|
version_requirements: !ruby/object:Gem::Requirement
|
155
155
|
requirements:
|
156
156
|
- - "~>"
|
157
157
|
- !ruby/object:Gem::Version
|
158
|
-
version:
|
158
|
+
version: 0.15.2
|
159
159
|
- !ruby/object:Gem::Dependency
|
160
160
|
name: faraday_middleware
|
161
161
|
requirement: !ruby/object:Gem::Requirement
|