bitsor 0.1.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 +7 -0
- data/.circleci/config.yml +61 -0
- data/.gitignore +16 -0
- data/.rspec +2 -0
- data/.rubocop.yml +45 -0
- data/.ruby-version +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +20 -0
- data/LICENSE.txt +21 -0
- data/README.md +74 -0
- data/Rakefile +9 -0
- data/bin/console +16 -0
- data/bin/setup +8 -0
- data/bitsor.gemspec +33 -0
- data/lib/bitsor/client/account_status.rb +14 -0
- data/lib/bitsor/client/available_books.rb +14 -0
- data/lib/bitsor/client/balance.rb +14 -0
- data/lib/bitsor/client/bitcoin_withdrawal.rb +12 -0
- data/lib/bitsor/client/debit_card_withdrawal.rb +12 -0
- data/lib/bitsor/client/ether_withdrawal.rb +12 -0
- data/lib/bitsor/client/fees.rb +14 -0
- data/lib/bitsor/client/funding.rb +14 -0
- data/lib/bitsor/client/funding_destination.rb +14 -0
- data/lib/bitsor/client/kyc_documents.rb +12 -0
- data/lib/bitsor/client/ledger.rb +38 -0
- data/lib/bitsor/client/mx_bank_codes.rb +12 -0
- data/lib/bitsor/client/open_orders.rb +14 -0
- data/lib/bitsor/client/order_book.rb +12 -0
- data/lib/bitsor/client/order_trades.rb +12 -0
- data/lib/bitsor/client/orders.rb +22 -0
- data/lib/bitsor/client/phone_number.rb +12 -0
- data/lib/bitsor/client/phone_number_withdrawal.rb +12 -0
- data/lib/bitsor/client/phone_verification.rb +12 -0
- data/lib/bitsor/client/spei_withdrawal.rb +12 -0
- data/lib/bitsor/client/ticker.rb +14 -0
- data/lib/bitsor/client/trades.rb +14 -0
- data/lib/bitsor/client/user_trades.rb +14 -0
- data/lib/bitsor/client/withdrawals.rb +12 -0
- data/lib/bitsor/client.rb +86 -0
- data/lib/bitsor/concerns/authorizable.rb +10 -0
- data/lib/bitsor/concerns/configurable.rb +41 -0
- data/lib/bitsor/concerns/connection.rb +86 -0
- data/lib/bitsor/concerns/rate_limit.rb +18 -0
- data/lib/bitsor/default.rb +32 -0
- data/lib/bitsor/error.rb +96 -0
- data/lib/bitsor/normalizer.rb +138 -0
- data/lib/bitsor/version.rb +20 -0
- data/lib/bitsor.rb +33 -0
- metadata +148 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f2b6612c7e1b52244270a79a75316446b2c6fab4
|
4
|
+
data.tar.gz: ce4b62fa5ff35c25af1e18496b61a225526c12fb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0b2ab8209a509c4325bcd2893a07242854b07b38afcbd55d41a057cd553c07b421acffa4d455b341d9d68b89b747c2b2382787b047b8f8a38393e23ae6d94770
|
7
|
+
data.tar.gz: 62e996c139162d26199be6a10aac875a2f6bf9ffa50568118dee30947511d6cd934d8ad0f41983a97aeb115dede45239598911da33cbf935b13dbb84f75ed342
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# Ruby CircleCI 2.0 configuration file
|
2
|
+
#
|
3
|
+
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
|
4
|
+
#
|
5
|
+
version: 2
|
6
|
+
jobs:
|
7
|
+
build:
|
8
|
+
parallelism: 1
|
9
|
+
docker:
|
10
|
+
# specify the version you desire here
|
11
|
+
- image: circleci/ruby:2.3.3-node-browsers
|
12
|
+
- image: circleci/php:7.1.9-browsers
|
13
|
+
|
14
|
+
# Specify service dependencies here if necessary
|
15
|
+
# CircleCI maintains a library of pre-built images
|
16
|
+
# documented at https://circleci.com/docs/2.0/circleci-images/
|
17
|
+
# - image: circleci/postgres:9.4
|
18
|
+
|
19
|
+
working_directory: ~/repo
|
20
|
+
|
21
|
+
steps:
|
22
|
+
- checkout
|
23
|
+
|
24
|
+
- run:
|
25
|
+
name: Setup Code Climate test-reporter
|
26
|
+
command: |
|
27
|
+
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
28
|
+
chmod +x ./cc-test-reporter
|
29
|
+
|
30
|
+
# Restore bundle cache
|
31
|
+
- type: cache-restore
|
32
|
+
name: Restore bundle cache
|
33
|
+
key: rails-demo-bundle-{{ checksum "Gemfile.lock" }}
|
34
|
+
|
35
|
+
- run: gem install bundler -v 1.16
|
36
|
+
- run:
|
37
|
+
name: Bundle Install
|
38
|
+
command: bundle install --jobs=4 --retry=3 --path vendor/bundle
|
39
|
+
|
40
|
+
# Store bundle cache
|
41
|
+
- type: cache-save
|
42
|
+
name: Store bundle cache
|
43
|
+
key: bitsor-bundle-{{ checksum "Gemfile.lock" }}
|
44
|
+
paths:
|
45
|
+
- vendor/bundle
|
46
|
+
|
47
|
+
# Run rspec in parallel
|
48
|
+
- run: |
|
49
|
+
./cc-test-reporter before-build
|
50
|
+
bundle exec rspec --profile 10 \
|
51
|
+
--format RspecJunitFormatter \
|
52
|
+
--out test_results/rspec.xml \
|
53
|
+
--format progress \
|
54
|
+
$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
|
55
|
+
./cc-test-reporter format-coverage -t simplecov $CIRCLE_ARTIFACTS/coverage/.resultset.json
|
56
|
+
./cc-test-reporter upload-coverage
|
57
|
+
|
58
|
+
# Save test results for timing analysis
|
59
|
+
- store_test_results:
|
60
|
+
path: test_results
|
61
|
+
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.3
|
3
|
+
Style/Documentation:
|
4
|
+
Enabled: false
|
5
|
+
Style/TrailingCommaInLiteral:
|
6
|
+
EnforcedStyleForMultiline: comma
|
7
|
+
Style/AlignParameters:
|
8
|
+
EnforcedStyle: with_fixed_indentation
|
9
|
+
Style/PercentLiteralDelimiters:
|
10
|
+
PreferredDelimiters:
|
11
|
+
default: []
|
12
|
+
'%i': []
|
13
|
+
'%w': []
|
14
|
+
Style/FrozenStringLiteralComment:
|
15
|
+
EnforcedStyle: always
|
16
|
+
Style/TrailingBlankLines:
|
17
|
+
EnforcedStyle: final_blank_line
|
18
|
+
Style/LambdaCall:
|
19
|
+
Enabled: false
|
20
|
+
Style/IndentHash:
|
21
|
+
Enabled: false
|
22
|
+
Style/AlignHash:
|
23
|
+
Enabled: false
|
24
|
+
Metrics/ClassLength:
|
25
|
+
Enabled: false
|
26
|
+
Metrics/MethodLength:
|
27
|
+
Enabled: false
|
28
|
+
Metrics/AbcSize:
|
29
|
+
Enabled: false
|
30
|
+
Metrics/LineLength:
|
31
|
+
Max: 120
|
32
|
+
# To make it possible to copy or click on URIs in the code, we allow lines
|
33
|
+
# containing a URI to be longer than Max.
|
34
|
+
AllowHeredoc: true
|
35
|
+
AllowURI: true
|
36
|
+
URISchemes:
|
37
|
+
- http
|
38
|
+
- https
|
39
|
+
# The IgnoreCopDirectives option causes the LineLength rule to ignore cop
|
40
|
+
# directives like '# rubocop: enable ...' when calculating a line's length.
|
41
|
+
IgnoreCopDirectives: false
|
42
|
+
Metrics/BlockLength:
|
43
|
+
Enabled: false
|
44
|
+
Style/NumericLiterals:
|
45
|
+
Enabled: false
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.3
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in bitsor.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem 'rubocop'
|
9
|
+
|
10
|
+
group :test do
|
11
|
+
gem 'dotenv'
|
12
|
+
gem 'multi_json'
|
13
|
+
gem 'pry'
|
14
|
+
gem 'rspec'
|
15
|
+
gem 'rspec_junit_formatter'
|
16
|
+
gem 'simplecov', require: false
|
17
|
+
gem 'vcr', '3.0.3'
|
18
|
+
gem 'webmock', '3.1.1'
|
19
|
+
end
|
20
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Adrian Castillo
|
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
@@ -0,0 +1,74 @@
|
|
1
|
+
[](https://codeclimate.com/github/rodacato/bitsor/maintainability)
|
2
|
+
[](https://codeclimate.com/github/rodacato/bitsor/test_coverage)
|
3
|
+
[](https://circleci.com/gh/rodacato/bitsor/tree/master)
|
4
|
+
|
5
|
+
# Bitsor
|
6
|
+
|
7
|
+
Ruby wrapper for bitso.com API, you will need an account to get the credentials to use this wrapper.
|
8
|
+
|
9
|
+
If you already have an account, you can get your api credentials from [here](https://bitso.com/api_setup).
|
10
|
+
|
11
|
+
If you dont have already an account, consider to signup from my referal link [here](https://bitso.com/?ref=nphw).
|
12
|
+
|
13
|
+
## Quick start
|
14
|
+
|
15
|
+
Install via Rubygems
|
16
|
+
|
17
|
+
gem install bitsor
|
18
|
+
|
19
|
+
... or add to your Gemfile
|
20
|
+
|
21
|
+
gem "bitsor", "~> 0.1"
|
22
|
+
|
23
|
+
### Making requests
|
24
|
+
|
25
|
+
[API methods](https://bitso.com/api_info#private-rest-api) are available as module methods (consuming module-level
|
26
|
+
configuration) or as client instance methods.
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
# Provide authentication credentials
|
30
|
+
Bitsor.configure do |c|
|
31
|
+
c.client_id = 123456
|
32
|
+
c.api_key = 'funky'
|
33
|
+
c.api_secret = '4l1Th3c01Ns!'
|
34
|
+
end
|
35
|
+
|
36
|
+
# Fetch the user balance
|
37
|
+
Bitsor.balance
|
38
|
+
```
|
39
|
+
or
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
# Provide authentication credentials
|
43
|
+
client = Bitsor::Client.new(client_id: 123456, api_key: 'defunkt', api_secret: '4l1Th3c01Ns!')
|
44
|
+
|
45
|
+
# Fetch the user balance
|
46
|
+
client.balance
|
47
|
+
```
|
48
|
+
|
49
|
+
## Contributing
|
50
|
+
|
51
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/rodacato/bitsor.
|
52
|
+
|
53
|
+
## License
|
54
|
+
|
55
|
+
Copyright (c) 2017 Adrian Castillo
|
56
|
+
|
57
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
58
|
+
a copy of this software and associated documentation files (the
|
59
|
+
"Software"), to deal in the Software without restriction, including
|
60
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
61
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
62
|
+
permit persons to whom the Software is furnished to do so, subject to
|
63
|
+
the following conditions:
|
64
|
+
|
65
|
+
The above copyright notice and this permission notice shall be
|
66
|
+
included in all copies or substantial portions of the Software.
|
67
|
+
|
68
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
69
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
70
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
71
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
72
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
73
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
74
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'bitsor'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
16
|
+
|
data/bin/setup
ADDED
data/bitsor.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
lib = File.expand_path('../lib', __FILE__)
|
5
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
+
require 'bitsor/version'
|
7
|
+
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
spec.name = 'bitsor'
|
10
|
+
spec.version = Bitsor::VERSION
|
11
|
+
spec.authors = ['Adrian Castillo']
|
12
|
+
spec.email = ['rodacato@gmail.com']
|
13
|
+
|
14
|
+
spec.summary = 'Unofficial Ruby API wrapper for use with Bitso.'
|
15
|
+
spec.description = 'Manage your bitso account from their API endpoints'
|
16
|
+
spec.homepage = 'https://www.bitsotower.com'
|
17
|
+
spec.license = 'MIT'
|
18
|
+
spec.metadata = { "source_code_uri" => "https://github.com/rodacato/bitsor" }
|
19
|
+
|
20
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
21
|
+
f.match(%r{^(test|spec|features)/})
|
22
|
+
end
|
23
|
+
spec.bindir = 'exe'
|
24
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
|
+
spec.require_paths = ['lib']
|
26
|
+
|
27
|
+
spec.add_dependency 'typhoeus', '~> 1.3'
|
28
|
+
|
29
|
+
spec.add_development_dependency 'bundler', '~> 1.15'
|
30
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
31
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
32
|
+
end
|
33
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bitsor
|
4
|
+
class Client
|
5
|
+
module FundingDestination
|
6
|
+
def funding_destination(fund_currency:)
|
7
|
+
normalize_response.with(:funding_destination) do
|
8
|
+
get('/v3/funding_destination/', fund_currency: fund_currency)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bitsor
|
4
|
+
class Client
|
5
|
+
module Ledger
|
6
|
+
def ledger(marker: nil, sort: :desc, limit: 25)
|
7
|
+
normalize_response.with(:ledger) do
|
8
|
+
get('/v3/ledger/', marker: marker, sort: sort, limit: limit)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def ledger_trades(marker: nil, sort: :desc, limit: 25)
|
13
|
+
normalize_response.with(:ledger) do
|
14
|
+
get('/v3/ledger/trades/', marker: marker, sort: sort, limit: limit)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def ledger_fees(marker: nil, sort: :desc, limit: 25)
|
19
|
+
normalize_response.with(:ledger) do
|
20
|
+
get('/v3/ledger/fees/', marker: marker, sort: sort, limit: limit)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def ledger_fundings(marker: nil, sort: :desc, limit: 25)
|
25
|
+
normalize_response.with(:ledger) do
|
26
|
+
get('/v3/ledger/fundings/', marker: marker, sort: sort, limit: limit)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def ledger_withdrawals(marker: nil, sort: :desc, limit: 25)
|
31
|
+
normalize_response.with(:ledger) do
|
32
|
+
get('/v3/ledger/withdrawals/', marker: marker, sort: sort, limit: limit)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bitsor
|
4
|
+
class Client
|
5
|
+
module OpenOrders
|
6
|
+
def open_orders(book: :all, marker: nil, sort: :desc, limit: 25)
|
7
|
+
normalize_response.with(:order) do
|
8
|
+
get('/v3/open_orders/', book: book, marker: marker, sort: sort, limit: limit)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bitsor
|
4
|
+
class Client
|
5
|
+
module Orders
|
6
|
+
def lookup_order(oid:)
|
7
|
+
normalize_response.with(:order) do
|
8
|
+
get("/v3/orders/#{oid}/")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def place_order(book:, side:, type:, major: nil, minor: nil, price: nil)
|
13
|
+
post('/v3/orders/', book: book, side: side, type: type, major: major, minor: minor, price: price)
|
14
|
+
end
|
15
|
+
|
16
|
+
def cancel_order(oid:)
|
17
|
+
delete("/v3/orders/#{oid}/")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|