bitso 0.1.1
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/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +23 -0
- data/Gemfile.lock +111 -0
- data/LICENSE.txt +20 -0
- data/README.md +98 -0
- data/Rakefile +52 -0
- data/VERSION +1 -0
- data/bitso.gemspec +90 -0
- data/lib/bitso.rb +101 -0
- data/lib/bitso/collection.rb +30 -0
- data/lib/bitso/helper.rb +19 -0
- data/lib/bitso/model.rb +30 -0
- data/lib/bitso/net.rb +34 -0
- data/lib/bitso/orders.rb +41 -0
- data/lib/bitso/ticker.rb +16 -0
- data/lib/bitso/transactions.rb +37 -0
- data/spec/bitso_spec.rb +89 -0
- data/spec/collection_spec.rb +12 -0
- data/spec/fixtures/vcr_cassettes/bitso/balance.yml +63 -0
- data/spec/fixtures/vcr_cassettes/bitso/order_book.yml +1910 -0
- data/spec/fixtures/vcr_cassettes/bitso/orders/all.yml +62 -0
- data/spec/fixtures/vcr_cassettes/bitso/orders/buy.yml +62 -0
- data/spec/fixtures/vcr_cassettes/bitso/orders/sell/failure.yml +60 -0
- data/spec/fixtures/vcr_cassettes/bitso/ticker.yml +63 -0
- data/spec/fixtures/vcr_cassettes/bitso/transactions.yml +244 -0
- data/spec/fixtures/vcr_cassettes/bitso/unconfirmed_user_deposits.yml +72 -0
- data/spec/fixtures/vcr_cassettes/bitso/user_transactions/all.yml +223 -0
- data/spec/fixtures/vcr_cassettes/bitso/withdraw_bitcoins/failure.yml +145 -0
- data/spec/orders_spec.rb +40 -0
- data/spec/spec_helper.rb +26 -0
- data/spec/support/bitso_setup.rb +19 -0
- data/spec/support/vcr.rb +21 -0
- data/spec/transactions_spec.rb +32 -0
- metadata +178 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 95b219a5d4cf8e1f12eb6629947c1832d0daf574
|
4
|
+
data.tar.gz: 11382bc7b273e11f48ab2f5193071ddd9631b1c8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b07e87b7cca14e4329f10609340ae5e879ef4540b0a93b5bb57eab3dc243b2c3bbc1a36fae7be9d243ee487a428fef219cf94cea73d9e10f780c1da768f4828e
|
7
|
+
data.tar.gz: 76ad6bb79f5f468bd4ab3ea9cbe3185646d79c3dc1cffc67c6e2e44a2e516d5218ff56d8469b8c383d9d19cab229d5090730b1121368e04093872000610fc20c
|
data/.rspec
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
bitso
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.2.2
|
data/Gemfile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
ruby '2.2.2'
|
2
|
+
|
3
|
+
source "http://rubygems.org"
|
4
|
+
# Add dependencies required to use your gem here.
|
5
|
+
# Example:
|
6
|
+
# gem "activesupport", ">= 2.3.5"
|
7
|
+
gem "activemodel" #, ">= 3.1"
|
8
|
+
gem "activesupport" #, ">= 3.1"
|
9
|
+
gem "rest-client" #, "1.7.3"
|
10
|
+
|
11
|
+
# Add dependencies to develop your gem here.
|
12
|
+
# Include everything needed to run rake, tests, features, etc.
|
13
|
+
group :development do
|
14
|
+
gem "rspec" #, ">= 0"
|
15
|
+
gem "rdoc" #, "~> 3.12"
|
16
|
+
gem "bundler" #, "~> 1.8.2"
|
17
|
+
gem "jeweler" #, "~> 1.8.4"
|
18
|
+
end
|
19
|
+
|
20
|
+
group :test do
|
21
|
+
gem "vcr" #, "2.6.0"
|
22
|
+
gem "webmock" #, "1.13.0"
|
23
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activemodel (4.2.3)
|
5
|
+
activesupport (= 4.2.3)
|
6
|
+
builder (~> 3.1)
|
7
|
+
activesupport (4.2.3)
|
8
|
+
i18n (~> 0.7)
|
9
|
+
json (~> 1.7, >= 1.7.7)
|
10
|
+
minitest (~> 5.1)
|
11
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
12
|
+
tzinfo (~> 1.1)
|
13
|
+
addressable (2.3.8)
|
14
|
+
builder (3.2.2)
|
15
|
+
crack (0.4.2)
|
16
|
+
safe_yaml (~> 1.0.0)
|
17
|
+
descendants_tracker (0.0.4)
|
18
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
19
|
+
diff-lcs (1.2.5)
|
20
|
+
domain_name (0.5.24)
|
21
|
+
unf (>= 0.0.5, < 1.0.0)
|
22
|
+
faraday (0.9.1)
|
23
|
+
multipart-post (>= 1.2, < 3)
|
24
|
+
git (1.2.9.1)
|
25
|
+
github_api (0.12.4)
|
26
|
+
addressable (~> 2.3)
|
27
|
+
descendants_tracker (~> 0.0.4)
|
28
|
+
faraday (~> 0.8, < 0.10)
|
29
|
+
hashie (>= 3.4)
|
30
|
+
multi_json (>= 1.7.5, < 2.0)
|
31
|
+
nokogiri (~> 1.6.6)
|
32
|
+
oauth2
|
33
|
+
hashie (3.4.2)
|
34
|
+
highline (1.7.3)
|
35
|
+
http-cookie (1.0.2)
|
36
|
+
domain_name (~> 0.5)
|
37
|
+
i18n (0.7.0)
|
38
|
+
jeweler (2.0.1)
|
39
|
+
builder
|
40
|
+
bundler (>= 1.0)
|
41
|
+
git (>= 1.2.5)
|
42
|
+
github_api
|
43
|
+
highline (>= 1.6.15)
|
44
|
+
nokogiri (>= 1.5.10)
|
45
|
+
rake
|
46
|
+
rdoc
|
47
|
+
json (1.8.3)
|
48
|
+
jwt (1.5.1)
|
49
|
+
mime-types (2.6.1)
|
50
|
+
mini_portile (0.6.2)
|
51
|
+
minitest (5.8.0)
|
52
|
+
multi_json (1.11.2)
|
53
|
+
multi_xml (0.5.5)
|
54
|
+
multipart-post (2.0.0)
|
55
|
+
netrc (0.10.3)
|
56
|
+
nokogiri (1.6.6.2)
|
57
|
+
mini_portile (~> 0.6.0)
|
58
|
+
oauth2 (1.0.0)
|
59
|
+
faraday (>= 0.8, < 0.10)
|
60
|
+
jwt (~> 1.0)
|
61
|
+
multi_json (~> 1.3)
|
62
|
+
multi_xml (~> 0.5)
|
63
|
+
rack (~> 1.2)
|
64
|
+
rack (1.6.4)
|
65
|
+
rake (10.4.2)
|
66
|
+
rdoc (4.2.0)
|
67
|
+
rest-client (1.8.0)
|
68
|
+
http-cookie (>= 1.0.2, < 2.0)
|
69
|
+
mime-types (>= 1.16, < 3.0)
|
70
|
+
netrc (~> 0.7)
|
71
|
+
rspec (3.3.0)
|
72
|
+
rspec-core (~> 3.3.0)
|
73
|
+
rspec-expectations (~> 3.3.0)
|
74
|
+
rspec-mocks (~> 3.3.0)
|
75
|
+
rspec-core (3.3.2)
|
76
|
+
rspec-support (~> 3.3.0)
|
77
|
+
rspec-expectations (3.3.1)
|
78
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
79
|
+
rspec-support (~> 3.3.0)
|
80
|
+
rspec-mocks (3.3.2)
|
81
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
82
|
+
rspec-support (~> 3.3.0)
|
83
|
+
rspec-support (3.3.0)
|
84
|
+
safe_yaml (1.0.4)
|
85
|
+
thread_safe (0.3.5)
|
86
|
+
tzinfo (1.2.2)
|
87
|
+
thread_safe (~> 0.1)
|
88
|
+
unf (0.1.4)
|
89
|
+
unf_ext
|
90
|
+
unf_ext (0.0.7.1)
|
91
|
+
vcr (2.9.3)
|
92
|
+
webmock (1.21.0)
|
93
|
+
addressable (>= 2.3.6)
|
94
|
+
crack (>= 0.3.2)
|
95
|
+
|
96
|
+
PLATFORMS
|
97
|
+
ruby
|
98
|
+
|
99
|
+
DEPENDENCIES
|
100
|
+
activemodel
|
101
|
+
activesupport
|
102
|
+
bundler
|
103
|
+
jeweler
|
104
|
+
rdoc
|
105
|
+
rest-client
|
106
|
+
rspec
|
107
|
+
vcr
|
108
|
+
webmock
|
109
|
+
|
110
|
+
BUNDLED WITH
|
111
|
+
1.10.6
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2015 Arturo Diaz
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
# Bitso Ruby API
|
2
|
+
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
Add this line to your application's Gemfile:
|
7
|
+
|
8
|
+
gem 'bitso'
|
9
|
+
|
10
|
+
## Create API Key
|
11
|
+
|
12
|
+
More info at: [https://bitso.com/api_info](https://bitso.com/api_info)
|
13
|
+
|
14
|
+
## Setup
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
Bitso.setup do |config|
|
18
|
+
config.key = YOUR_API_KEY
|
19
|
+
config.secret = YOUR_API_SECRET
|
20
|
+
config.client_id = YOUR_BITSO_USERNAME
|
21
|
+
end
|
22
|
+
```
|
23
|
+
|
24
|
+
If you fail to set your `key` or `secret` or `client_id` a `MissingConfigExeception`
|
25
|
+
will be raised.
|
26
|
+
|
27
|
+
## Bitso ticker
|
28
|
+
|
29
|
+
The Bitso ticker. Returns `last`, `high`, `low`, `volume`, `bid` and `ask`
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
Bitso.ticker
|
33
|
+
```
|
34
|
+
|
35
|
+
It's also possible to query through the `Bitso::Ticker` object with
|
36
|
+
each individual method.
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
Bitso::Ticker.low # => "109.00"
|
40
|
+
```
|
41
|
+
|
42
|
+
## Fetch your open order
|
43
|
+
|
44
|
+
Returns an array with your open orders.
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
Bitso.orders.all
|
48
|
+
```
|
49
|
+
|
50
|
+
## Create a sell order
|
51
|
+
|
52
|
+
Returns an `Order` object.
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
Bitso.orders.sell(amount: 1.0, price: 111)
|
56
|
+
```
|
57
|
+
|
58
|
+
## Create a buy order
|
59
|
+
|
60
|
+
Returns an `Order` object.
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
Bitso.orders.buy(amount: 1.0, price: 111)
|
64
|
+
```
|
65
|
+
|
66
|
+
## Fetch your transactions
|
67
|
+
|
68
|
+
Returns an `Array` of `UserTransaction`.
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
Bitso.user_transactions.all
|
72
|
+
```
|
73
|
+
|
74
|
+
*To be continued!**
|
75
|
+
|
76
|
+
# Tests
|
77
|
+
|
78
|
+
If you'd like to run the tests you need to set the following environment variables:
|
79
|
+
|
80
|
+
```
|
81
|
+
export BITSO_KEY=xxx
|
82
|
+
export BITSO_SECRET=yyy
|
83
|
+
export BITSO_CLIENT_ID=zzz
|
84
|
+
```
|
85
|
+
|
86
|
+
## Contributing
|
87
|
+
|
88
|
+
1. Fork it
|
89
|
+
2. Create your feature branch (`git checkout -b
|
90
|
+
my-new-feature`)
|
91
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
92
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
93
|
+
5. Create new Pull Request
|
94
|
+
|
95
|
+
|
96
|
+
## Credits
|
97
|
+
|
98
|
+
This is a fork of the [Bitstamp gem](https://github.com/kojnapp/bitstamp) built by [kojnapp](https://github.com/kojnapp).
|
data/Rakefile
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
require "bundler/gem_tasks"
|
6
|
+
|
7
|
+
begin
|
8
|
+
Bundler.setup(:default, :development)
|
9
|
+
rescue Bundler::BundlerError => e
|
10
|
+
$stderr.puts e.message
|
11
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
12
|
+
exit e.status_code
|
13
|
+
end
|
14
|
+
require 'rake'
|
15
|
+
|
16
|
+
require 'jeweler'
|
17
|
+
|
18
|
+
Jeweler::Tasks.new do |gem|
|
19
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
20
|
+
gem.name = "bitso"
|
21
|
+
gem.homepage = "http://github.com/arturodz/bitso"
|
22
|
+
gem.license = "GPL"
|
23
|
+
gem.summary = %Q{Bitso Ruby API Wrapper}
|
24
|
+
gem.description = %Q{Ruby API for use with bitso.}
|
25
|
+
gem.email = "me@arturodz.com"
|
26
|
+
gem.authors = ["Arturo Diaz"]
|
27
|
+
# dependencies defined in Gemfile
|
28
|
+
end
|
29
|
+
Jeweler::RubygemsDotOrgTasks.new
|
30
|
+
|
31
|
+
require 'rspec/core'
|
32
|
+
require 'rspec/core/rake_task'
|
33
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
34
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
35
|
+
end
|
36
|
+
|
37
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
38
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
39
|
+
spec.rcov = true
|
40
|
+
end
|
41
|
+
|
42
|
+
task :default => :spec
|
43
|
+
|
44
|
+
require 'rdoc/task'
|
45
|
+
Rake::RDocTask.new do |rdoc|
|
46
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
47
|
+
|
48
|
+
rdoc.rdoc_dir = 'rdoc'
|
49
|
+
rdoc.title = "bitso #{version}"
|
50
|
+
rdoc.rdoc_files.include('README*')
|
51
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
52
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.1
|
data/bitso.gemspec
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: bitso 0.4.0 ruby lib
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "bitso"
|
9
|
+
s.version = "0.1.1"
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.authors = ["Arturo Diaz"]
|
13
|
+
s.date = "2015-08-18"
|
14
|
+
s.description = "Ruby API for use with Bitso."
|
15
|
+
s.email = "me@arturodz.com"
|
16
|
+
s.extra_rdoc_files = [
|
17
|
+
"LICENSE.txt",
|
18
|
+
"README.md"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".rspec",
|
22
|
+
".ruby-gemset",
|
23
|
+
".ruby-version",
|
24
|
+
"Gemfile",
|
25
|
+
"Gemfile.lock",
|
26
|
+
"LICENSE.txt",
|
27
|
+
"README.md",
|
28
|
+
"Rakefile",
|
29
|
+
"VERSION",
|
30
|
+
"bitso.gemspec",
|
31
|
+
"lib/bitso.rb",
|
32
|
+
"lib/bitso/collection.rb",
|
33
|
+
"lib/bitso/helper.rb",
|
34
|
+
"lib/bitso/model.rb",
|
35
|
+
"lib/bitso/net.rb",
|
36
|
+
"lib/bitso/orders.rb",
|
37
|
+
"lib/bitso/ticker.rb",
|
38
|
+
"lib/bitso/transactions.rb",
|
39
|
+
"spec/bitso_spec.rb",
|
40
|
+
"spec/collection_spec.rb",
|
41
|
+
"spec/fixtures/vcr_cassettes/bitso/balance.yml",
|
42
|
+
"spec/fixtures/vcr_cassettes/bitso/order_book.yml",
|
43
|
+
"spec/fixtures/vcr_cassettes/bitso/orders/all.yml",
|
44
|
+
"spec/fixtures/vcr_cassettes/bitso/orders/buy.yml",
|
45
|
+
"spec/fixtures/vcr_cassettes/bitso/orders/sell/failure.yml",
|
46
|
+
"spec/fixtures/vcr_cassettes/bitso/ticker.yml",
|
47
|
+
"spec/fixtures/vcr_cassettes/bitso/transactions.yml",
|
48
|
+
"spec/fixtures/vcr_cassettes/bitso/user_transactions/all.yml",
|
49
|
+
"spec/orders_spec.rb",
|
50
|
+
"spec/spec_helper.rb",
|
51
|
+
"spec/support/bitso_setup.rb",
|
52
|
+
"spec/support/vcr.rb",
|
53
|
+
"spec/transactions_spec.rb"
|
54
|
+
]
|
55
|
+
s.homepage = "http://github.com/arturodz/bitso"
|
56
|
+
s.licenses = ["GPL"]
|
57
|
+
s.require_paths = ["lib"]
|
58
|
+
s.rubygems_version = "2.1.11"
|
59
|
+
s.summary = "Bitso Ruby API"
|
60
|
+
|
61
|
+
if s.respond_to? :specification_version then
|
62
|
+
s.specification_version = 4
|
63
|
+
|
64
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
65
|
+
s.add_runtime_dependency(%q<activemodel>, [">= 3.1"])
|
66
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 3.1"])
|
67
|
+
s.add_runtime_dependency(%q<rest-client>, [">= 1.7.3"])
|
68
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
69
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
70
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.3.5"])
|
71
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
72
|
+
else
|
73
|
+
s.add_dependency(%q<activemodel>, [">= 3.1"])
|
74
|
+
s.add_dependency(%q<activesupport>, [">= 3.1"])
|
75
|
+
s.add_dependency(%q<rest-client>, [">= 1.7.3"])
|
76
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
77
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
78
|
+
s.add_dependency(%q<bundler>, ["~> 1.3.5"])
|
79
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
80
|
+
end
|
81
|
+
else
|
82
|
+
s.add_dependency(%q<activemodel>, [">= 3.1"])
|
83
|
+
s.add_dependency(%q<activesupport>, [">= 3.1"])
|
84
|
+
s.add_dependency(%q<rest-client>, [">= 1.7.3"])
|
85
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
86
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
87
|
+
s.add_dependency(%q<bundler>, ["~> 1.3.5"])
|
88
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
89
|
+
end
|
90
|
+
end
|
data/lib/bitso.rb
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
require 'active_support/core_ext'
|
3
|
+
require 'active_support/inflector'
|
4
|
+
require 'active_model'
|
5
|
+
require 'rest-client'
|
6
|
+
require 'rubysl-openssl'
|
7
|
+
require 'rubysl-base64'
|
8
|
+
|
9
|
+
require 'bitso/net'
|
10
|
+
require 'bitso/helper'
|
11
|
+
require 'bitso/collection'
|
12
|
+
require 'bitso/model'
|
13
|
+
require 'bitso/orders'
|
14
|
+
require 'bitso/transactions'
|
15
|
+
require 'bitso/ticker'
|
16
|
+
|
17
|
+
String.send(:include, ActiveSupport::Inflector)
|
18
|
+
|
19
|
+
module Bitso
|
20
|
+
# API Key
|
21
|
+
mattr_accessor :key
|
22
|
+
|
23
|
+
# Bitso secret
|
24
|
+
mattr_accessor :secret
|
25
|
+
|
26
|
+
# Bitso client ID
|
27
|
+
mattr_accessor :client_id
|
28
|
+
|
29
|
+
# Currency
|
30
|
+
mattr_accessor :currency
|
31
|
+
@@currency = :mxn
|
32
|
+
|
33
|
+
def self.orders
|
34
|
+
self.sanity_check!
|
35
|
+
|
36
|
+
@@orders ||= Bitso::Orders.new
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.user_transactions
|
40
|
+
self.sanity_check!
|
41
|
+
|
42
|
+
@@transactions ||= Bitso::UserTransactions.new
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.transactions
|
46
|
+
return Bitso::Transactions.from_api
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.balance
|
50
|
+
self.sanity_check!
|
51
|
+
|
52
|
+
JSON.parse Bitso::Net.post('/balance').to_str
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.withdraw_bitcoins(options = {})
|
56
|
+
self.sanity_check!
|
57
|
+
if options[:amount].nil? || options[:address].nil?
|
58
|
+
raise MissingConfigExeception.new("Required parameters not supplied, :amount, :address")
|
59
|
+
end
|
60
|
+
response_body = Bitso::Net.post('/bitcoin_withdrawal',options).body_str
|
61
|
+
if response_body != 'true'
|
62
|
+
return JSON.parse response_body
|
63
|
+
else
|
64
|
+
return response_body
|
65
|
+
end
|
66
|
+
end
|
67
|
+
def self.bitcoin_deposit_address
|
68
|
+
# returns the deposit address
|
69
|
+
self.sanity_check!
|
70
|
+
return Bitso::Net.post('/bitcoin_deposit_address').body_str
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.unconfirmed_user_deposits
|
74
|
+
self.sanity_check!
|
75
|
+
return JSON.parse Bitso::Net::post("/unconfirmed_btc").body_str
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.ticker
|
79
|
+
return Bitso::Ticker.from_api
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.order_book
|
83
|
+
return JSON.parse Bitso::Net.get('/order_book').to_str
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.setup
|
87
|
+
yield self
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.configured?
|
91
|
+
self.key && self.secret && self.client_id
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.sanity_check!
|
95
|
+
unless configured?
|
96
|
+
raise MissingConfigExeception.new("Bitso Gem not properly configured")
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
class MissingConfigExeception<Exception;end;
|
101
|
+
end
|