bitflyer 2.0.2 → 2.0.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 +4 -4
- data/.github/dependabot.yml +13 -21
- data/Gemfile.lock +11 -22
- data/README.md +4 -0
- data/bitflyer.gemspec +0 -1
- data/lib/bitflyer/http.rb +43 -26
- data/lib/bitflyer/realtime/client.rb +1 -0
- data/lib/bitflyer/version.rb +1 -1
- metadata +1 -15
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fa057685f2e11b3a0bf9f46f0282f240e57e22c4cfbb507e4d92770b8441a997
|
|
4
|
+
data.tar.gz: ae4ce59c0e407b7e80d1970b7f716037fcf5c79e09abee07074b019873fcc5f2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 68fb55c3fb2bf4e52595ad2574913b425927f0db1b21d59181163306354d4d2fed6cf0d60213732d36a0cf18e59910e21b00a61311a4d0f8497885777414c5e0
|
|
7
|
+
data.tar.gz: 78819f20b021ffd427837b9525c057fd3f33ef7b9237d274e92fe3089660d8e16255bf2fd70c82d0e2a67a82c22c6aede1e67fb02e1b8b6d15f0578a56549dc2
|
data/.github/dependabot.yml
CHANGED
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
version: 2
|
|
2
2
|
updates:
|
|
3
|
-
- package-ecosystem: bundler
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
- dependency-name: rubocop
|
|
17
|
-
versions:
|
|
18
|
-
- 1.12.0
|
|
19
|
-
- 1.12.1
|
|
20
|
-
- dependency-name: regexp_parser
|
|
21
|
-
versions:
|
|
22
|
-
- 2.1.0
|
|
23
|
-
- 2.1.1
|
|
3
|
+
- package-ecosystem: bundler
|
|
4
|
+
directory: "/"
|
|
5
|
+
schedule:
|
|
6
|
+
interval: daily
|
|
7
|
+
time: "12:00"
|
|
8
|
+
timezone: Asia/Tokyo
|
|
9
|
+
open-pull-requests-limit: 20
|
|
10
|
+
allow:
|
|
11
|
+
- dependency-type: direct
|
|
12
|
+
- dependency-type: indirect
|
|
13
|
+
ignore:
|
|
14
|
+
- dependency-name: parallel
|
|
15
|
+
update-types: ["version-update:semver-major"]
|
data/Gemfile.lock
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
bitflyer (2.0.
|
|
5
|
-
faraday (>= 2.0)
|
|
4
|
+
bitflyer (2.0.3)
|
|
6
5
|
websocket-client-simple (>= 0.9)
|
|
7
6
|
|
|
8
7
|
GEM
|
|
@@ -13,23 +12,14 @@ GEM
|
|
|
13
12
|
coderay (1.1.3)
|
|
14
13
|
diff-lcs (1.6.2)
|
|
15
14
|
event_emitter (0.2.6)
|
|
16
|
-
faraday (2.14.0)
|
|
17
|
-
faraday-net_http (>= 2.0, < 3.5)
|
|
18
|
-
json
|
|
19
|
-
logger
|
|
20
|
-
faraday-net_http (3.4.2)
|
|
21
|
-
net-http (~> 0.5)
|
|
22
15
|
io-console (0.8.2)
|
|
23
|
-
json (2.
|
|
24
|
-
language_server-protocol (3.17.0.
|
|
16
|
+
json (2.21.1)
|
|
17
|
+
language_server-protocol (3.17.0.6)
|
|
25
18
|
lint_roller (1.1.0)
|
|
26
|
-
logger (1.7.0)
|
|
27
19
|
method_source (1.1.0)
|
|
28
20
|
mutex_m (0.3.0)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
parallel (1.27.0)
|
|
32
|
-
parser (3.3.10.1)
|
|
21
|
+
parallel (1.28.0)
|
|
22
|
+
parser (3.3.12.0)
|
|
33
23
|
ast (~> 2.4.1)
|
|
34
24
|
racc
|
|
35
25
|
prism (1.9.0)
|
|
@@ -39,8 +29,8 @@ GEM
|
|
|
39
29
|
reline (>= 0.6.0)
|
|
40
30
|
racc (1.8.1)
|
|
41
31
|
rainbow (3.1.1)
|
|
42
|
-
rake (13.
|
|
43
|
-
regexp_parser (2.
|
|
32
|
+
rake (13.4.2)
|
|
33
|
+
regexp_parser (2.12.0)
|
|
44
34
|
reline (0.6.3)
|
|
45
35
|
io-console (~> 0.5)
|
|
46
36
|
rspec (3.13.2)
|
|
@@ -52,29 +42,28 @@ GEM
|
|
|
52
42
|
rspec-expectations (3.13.5)
|
|
53
43
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
54
44
|
rspec-support (~> 3.13.0)
|
|
55
|
-
rspec-mocks (3.13.
|
|
45
|
+
rspec-mocks (3.13.8)
|
|
56
46
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
57
47
|
rspec-support (~> 3.13.0)
|
|
58
48
|
rspec-support (3.13.7)
|
|
59
|
-
rubocop (1.
|
|
49
|
+
rubocop (1.88.2)
|
|
60
50
|
json (~> 2.3)
|
|
61
51
|
language_server-protocol (~> 3.17.0.2)
|
|
62
52
|
lint_roller (~> 1.1.0)
|
|
63
|
-
parallel (
|
|
53
|
+
parallel (>= 1.10)
|
|
64
54
|
parser (>= 3.3.0.2)
|
|
65
55
|
rainbow (>= 2.2.2, < 4.0)
|
|
66
56
|
regexp_parser (>= 2.9.3, < 3.0)
|
|
67
57
|
rubocop-ast (>= 1.49.0, < 2.0)
|
|
68
58
|
ruby-progressbar (~> 1.7)
|
|
69
59
|
unicode-display_width (>= 2.4.0, < 4.0)
|
|
70
|
-
rubocop-ast (1.
|
|
60
|
+
rubocop-ast (1.50.0)
|
|
71
61
|
parser (>= 3.3.7.2)
|
|
72
62
|
prism (~> 1.7)
|
|
73
63
|
ruby-progressbar (1.13.0)
|
|
74
64
|
unicode-display_width (3.2.0)
|
|
75
65
|
unicode-emoji (~> 4.1)
|
|
76
66
|
unicode-emoji (4.2.0)
|
|
77
|
-
uri (1.1.1)
|
|
78
67
|
websocket (1.2.11)
|
|
79
68
|
websocket-client-simple (0.9.0)
|
|
80
69
|
base64
|
data/README.md
CHANGED
|
@@ -114,3 +114,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|
|
114
114
|
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
115
115
|
|
|
116
116
|
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
|
|
117
|
+
|
|
118
|
+
## Author
|
|
119
|
+
|
|
120
|
+
[@unhappychoice](https://unhappychoice.com)
|
data/bitflyer.gemspec
CHANGED
|
@@ -18,7 +18,6 @@ Gem::Specification.new do |spec|
|
|
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
19
19
|
spec.require_paths = ['lib']
|
|
20
20
|
|
|
21
|
-
spec.add_dependency 'faraday', '>= 2.0'
|
|
22
21
|
spec.add_dependency 'websocket-client-simple', '>= 0.9'
|
|
23
22
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
|
24
23
|
spec.add_development_dependency 'pry'
|
data/lib/bitflyer/http.rb
CHANGED
|
@@ -3,45 +3,62 @@
|
|
|
3
3
|
require 'bitflyer'
|
|
4
4
|
require 'bitflyer/http/public'
|
|
5
5
|
require 'bitflyer/http/private'
|
|
6
|
-
require '
|
|
6
|
+
require 'net/http'
|
|
7
|
+
require 'uri'
|
|
8
|
+
require 'json'
|
|
7
9
|
require 'openssl'
|
|
8
10
|
|
|
9
11
|
module Bitflyer
|
|
10
12
|
module HTTP
|
|
11
|
-
|
|
12
|
-
extend Forwardable
|
|
13
|
+
BASE_URL = 'https://api.bitflyer.jp'
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
Response = Struct.new(:body)
|
|
15
16
|
|
|
17
|
+
class Connection
|
|
16
18
|
def initialize(key, secret)
|
|
17
|
-
@connection = Faraday::Connection.new(url: 'https://api.bitflyer.jp') do |f|
|
|
18
|
-
f.request :json
|
|
19
|
-
f.response :json
|
|
20
|
-
f.use Authentication, key, secret
|
|
21
|
-
f.adapter Faraday.default_adapter
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
class Authentication < Faraday::Middleware
|
|
27
|
-
def initialize(app, key, secret)
|
|
28
|
-
super(app)
|
|
29
19
|
@key = key
|
|
30
20
|
@secret = secret
|
|
21
|
+
@uri = URI.parse(BASE_URL)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def get(path, params = {})
|
|
25
|
+
query = URI.encode_www_form(params.compact)
|
|
26
|
+
full_path = query.empty? ? path : "#{path}?#{query}"
|
|
27
|
+
request = Net::HTTP::Get.new(full_path, default_headers)
|
|
28
|
+
sign_request(request, full_path)
|
|
29
|
+
Response.new(execute(request))
|
|
31
30
|
end
|
|
32
31
|
|
|
33
|
-
def
|
|
34
|
-
|
|
32
|
+
def post(path, body = {})
|
|
33
|
+
request = Net::HTTP::Post.new(path, default_headers.merge('Content-Type' => 'application/json'))
|
|
34
|
+
request.body = JSON.generate(body.compact)
|
|
35
|
+
sign_request(request, path, request.body)
|
|
36
|
+
Response.new(execute(request))
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
def default_headers
|
|
42
|
+
{ 'Accept' => 'application/json' }
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def sign_request(request, path, body = '')
|
|
46
|
+
return if @key.nil? || @secret.nil?
|
|
35
47
|
|
|
36
48
|
timestamp = Time.now.to_i.to_s
|
|
37
|
-
method =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
49
|
+
method = request.method.upcase
|
|
50
|
+
text = timestamp + method + path + (body || '')
|
|
51
|
+
signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), @secret, text)
|
|
52
|
+
request['ACCESS-KEY'] = @key
|
|
53
|
+
request['ACCESS-TIMESTAMP'] = timestamp
|
|
54
|
+
request['ACCESS-SIGN'] = signature
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def execute(request)
|
|
58
|
+
response = Net::HTTP.start(@uri.host, @uri.port, use_ssl: true) { |http| http.request(request) }
|
|
59
|
+
JSON.parse(response.body)
|
|
60
|
+
rescue JSON::ParserError
|
|
61
|
+
response.body
|
|
45
62
|
end
|
|
46
63
|
end
|
|
47
64
|
end
|
data/lib/bitflyer/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bitflyer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.
|
|
4
|
+
version: 2.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yuji Ueki
|
|
@@ -9,20 +9,6 @@ bindir: exe
|
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
|
-
- !ruby/object:Gem::Dependency
|
|
13
|
-
name: faraday
|
|
14
|
-
requirement: !ruby/object:Gem::Requirement
|
|
15
|
-
requirements:
|
|
16
|
-
- - ">="
|
|
17
|
-
- !ruby/object:Gem::Version
|
|
18
|
-
version: '2.0'
|
|
19
|
-
type: :runtime
|
|
20
|
-
prerelease: false
|
|
21
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
-
requirements:
|
|
23
|
-
- - ">="
|
|
24
|
-
- !ruby/object:Gem::Version
|
|
25
|
-
version: '2.0'
|
|
26
12
|
- !ruby/object:Gem::Dependency
|
|
27
13
|
name: websocket-client-simple
|
|
28
14
|
requirement: !ruby/object:Gem::Requirement
|