coin_falcon 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +35 -0
- data/LICENSE.txt +21 -0
- data/README.md +3 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/coin_falcon.gemspec +26 -0
- data/lib/coin_falcon/client.rb +72 -0
- data/lib/coin_falcon/version.rb +3 -0
- data/lib/coin_falcon.rb +15 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 570c78fd30472cbfec2fd585eb64deacd8e305e66082d2cf1ac0692415521830
|
4
|
+
data.tar.gz: 1e7cf3facbd7b72c0c5a6212755aab5fd5534b25369c0ef097c62e3e5e64e66d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a52f9f79a3620bb450010fa991e9ec85005228c53bcbd3043a3f9e4143290eaa14c2dbaf1e02a58d830b7c64f7c7f6dc3da455982ce6ec83dbb0a0f54cad3ce2
|
7
|
+
data.tar.gz: e603e184d54bab783f57b854b94b879c88d66f3d399b94dc61b3b39d24564da7d025f3df92b49886a2bc312f33fcb3fc9dd574dae98c37c642bb911e2f9005d0
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
coin_falcon (0.0.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.3)
|
10
|
+
rake (10.5.0)
|
11
|
+
rspec (3.7.0)
|
12
|
+
rspec-core (~> 3.7.0)
|
13
|
+
rspec-expectations (~> 3.7.0)
|
14
|
+
rspec-mocks (~> 3.7.0)
|
15
|
+
rspec-core (3.7.1)
|
16
|
+
rspec-support (~> 3.7.0)
|
17
|
+
rspec-expectations (3.7.0)
|
18
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
+
rspec-support (~> 3.7.0)
|
20
|
+
rspec-mocks (3.7.0)
|
21
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
+
rspec-support (~> 3.7.0)
|
23
|
+
rspec-support (3.7.1)
|
24
|
+
|
25
|
+
PLATFORMS
|
26
|
+
ruby
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
bundler (~> 1.16)
|
30
|
+
coin_falcon!
|
31
|
+
rake (~> 10.0)
|
32
|
+
rspec (~> 3.0)
|
33
|
+
|
34
|
+
BUNDLED WITH
|
35
|
+
1.16.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Tony Rom
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "coin_falcon"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/coin_falcon.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "coin_falcon/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "coin_falcon"
|
8
|
+
spec.version = CoinFalcon::VERSION
|
9
|
+
spec.authors = ["Tony Rom"]
|
10
|
+
spec.email = ["thetonyrom@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "Ruby library for the CoinFalcon API."
|
13
|
+
spec.homepage = "https://github.com/thetonyrom/coin_falcon"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
26
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module CoinFalcon
|
2
|
+
# Client executes requests against the CoinFalcon API.
|
3
|
+
#
|
4
|
+
class Client
|
5
|
+
KEY_HEADER = 'CF-API-KEY'.freeze
|
6
|
+
TIME_HEADER = 'CF-API-TIMESTAMP'.freeze
|
7
|
+
SIGN_HEADER = 'CF-API-SIGNATURE'.freeze
|
8
|
+
|
9
|
+
attr_reader :api_key, :api_secret
|
10
|
+
|
11
|
+
def initialize(api_key, api_secret)
|
12
|
+
@api_key = api_key
|
13
|
+
@api_secret = api_secret
|
14
|
+
end
|
15
|
+
|
16
|
+
def orderbook(market)
|
17
|
+
url = build_url("markets/#{market}/orders")
|
18
|
+
|
19
|
+
response = get(url)
|
20
|
+
|
21
|
+
JSON.parse(response.body)
|
22
|
+
end
|
23
|
+
|
24
|
+
def accounts
|
25
|
+
url = build_url('user/accounts')
|
26
|
+
|
27
|
+
response = get(url)
|
28
|
+
|
29
|
+
JSON.parse(response.body)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def build_url(path)
|
35
|
+
URI(CoinFalcon.api_base + path)
|
36
|
+
end
|
37
|
+
|
38
|
+
def headers(method, path, body = nil)
|
39
|
+
timestamp = Time.now.to_i
|
40
|
+
|
41
|
+
{
|
42
|
+
KEY_HEADER => api_key,
|
43
|
+
TIME_HEADER => timestamp,
|
44
|
+
SIGN_HEADER => sign(timestamp, method, path, body),
|
45
|
+
'Content-Type' => 'application/json'
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
def sign(timestamp, method, path, body)
|
50
|
+
payload = build_payload(timestamp, method, path, body)
|
51
|
+
|
52
|
+
OpenSSL::HMAC.hexdigest('sha256', api_secret, payload)
|
53
|
+
end
|
54
|
+
|
55
|
+
def build_payload(timestamp, method, path, body)
|
56
|
+
[timestamp, method, path, body].compact.join('|')
|
57
|
+
end
|
58
|
+
|
59
|
+
def get(url)
|
60
|
+
request = Net::HTTP::Get.new(url)
|
61
|
+
|
62
|
+
headers('GET', url.path).each do |header, value|
|
63
|
+
request[header] = value
|
64
|
+
end
|
65
|
+
|
66
|
+
http = Net::HTTP.new(url.hostname, url.port)
|
67
|
+
http.use_ssl = true
|
68
|
+
|
69
|
+
http.request(request)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
data/lib/coin_falcon.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
require 'openssl'
|
4
|
+
|
5
|
+
require 'coin_falcon/client'
|
6
|
+
|
7
|
+
require 'coin_falcon/version'
|
8
|
+
|
9
|
+
module CoinFalcon
|
10
|
+
@api_base = 'https://staging.coinfalcon.com/api/v1/'
|
11
|
+
|
12
|
+
class << self
|
13
|
+
attr_accessor :api_base
|
14
|
+
end
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: coin_falcon
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tony Rom
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-02-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- thetonyrom@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- ".travis.yml"
|
65
|
+
- Gemfile
|
66
|
+
- Gemfile.lock
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- bin/console
|
71
|
+
- bin/setup
|
72
|
+
- coin_falcon.gemspec
|
73
|
+
- lib/coin_falcon.rb
|
74
|
+
- lib/coin_falcon/client.rb
|
75
|
+
- lib/coin_falcon/version.rb
|
76
|
+
homepage: https://github.com/thetonyrom/coin_falcon
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
metadata: {}
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 2.7.5
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: Ruby library for the CoinFalcon API.
|
100
|
+
test_files: []
|