coinfloor 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/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +36 -0
- data/LICENSE.txt +20 -0
- data/README.md +96 -0
- data/Rakefile +51 -0
- data/VERSION +1 -0
- data/coinfloor.gemspec +47 -0
- data/lib/coinfloor.rb +101 -0
- data/lib/coinfloor/collection.rb +30 -0
- data/lib/coinfloor/helper.rb +19 -0
- data/lib/coinfloor/model.rb +29 -0
- data/lib/coinfloor/net.rb +39 -0
- data/lib/coinfloor/orders.rb +41 -0
- data/lib/coinfloor/ticker.rb +16 -0
- data/lib/coinfloor/transactions.rb +39 -0
- metadata +63 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 15e1a7b68b2b8dbc736df287c6edfeffb788db24
|
|
4
|
+
data.tar.gz: fc4f683d9ddbdc054bd85cb06f9946f7019ebf0b
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 7dddd1b28d73907a5aec70e4858bcdfbb2168bb872df64b2dbcd89a833dc8230cbb195e8ce420ea42137068009c4721320af7514e9c18a05e88774edb9ae582b
|
|
7
|
+
data.tar.gz: 1ecc6ba0991b69cdcc0e0a128cdb45dadc8ead060f5e6fc49efd99fc35224759ec7aaf92c07bacdf472868d05bea3c219f3e6dfd576129e7dc65a79af568ec15
|
data/.rspec
ADDED
data/.ruby-gemset
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
coinfloor
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ruby-2.3.0
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
GEM
|
|
2
|
+
remote: http://rubygems.org/
|
|
3
|
+
specs:
|
|
4
|
+
activemodel (4.0.0.beta1)
|
|
5
|
+
activesupport (= 4.0.0.beta1)
|
|
6
|
+
builder (~> 3.1.0)
|
|
7
|
+
activesupport (4.0.0.beta1)
|
|
8
|
+
i18n (~> 0.6.2)
|
|
9
|
+
minitest (~> 4.2)
|
|
10
|
+
multi_json (~> 1.3)
|
|
11
|
+
thread_safe (~> 0.1)
|
|
12
|
+
tzinfo (~> 0.3.33)
|
|
13
|
+
atomic (1.1.7)
|
|
14
|
+
builder (3.1.4)
|
|
15
|
+
i18n (0.6.4)
|
|
16
|
+
minitest (4.7.1)
|
|
17
|
+
multi_json (1.7.2)
|
|
18
|
+
netrc (0.7.9)
|
|
19
|
+
rest_client (1.8.3)
|
|
20
|
+
netrc (~> 0.7.7)
|
|
21
|
+
ruby-hmac (0.4.0)
|
|
22
|
+
thread_safe (0.1.0)
|
|
23
|
+
atomic
|
|
24
|
+
tzinfo (0.3.37)
|
|
25
|
+
|
|
26
|
+
PLATFORMS
|
|
27
|
+
ruby
|
|
28
|
+
|
|
29
|
+
DEPENDENCIES
|
|
30
|
+
activemodel (>= 3.1)
|
|
31
|
+
activesupport (>= 3.1)
|
|
32
|
+
rest_client
|
|
33
|
+
ruby-hmac
|
|
34
|
+
|
|
35
|
+
BUNDLED WITH
|
|
36
|
+
1.11.2
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2013 Kojn
|
|
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,96 @@
|
|
|
1
|
+
# Bitstamp Ruby API
|
|
2
|
+
|
|
3
|
+
Feel free to fork, modify & redistribute under the MIT license.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
gem 'bitstamp'
|
|
10
|
+
|
|
11
|
+
## Create API Key
|
|
12
|
+
|
|
13
|
+
More info at: [https://www.bitstamp.net/article/api-key-implementation/](https://www.bitstamp.net/article/api-key-implementation/)
|
|
14
|
+
|
|
15
|
+
## Setup
|
|
16
|
+
|
|
17
|
+
```ruby
|
|
18
|
+
Bitstamp.setup do |config|
|
|
19
|
+
config.key = YOUR_API_KEY
|
|
20
|
+
config.secret = YOUR_API_SECRET
|
|
21
|
+
config.client_id = YOUR_BITSTAMP_USERNAME
|
|
22
|
+
end
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
If you fail to set your `key` or `secret` or `client_id` a `MissingConfigExeception`
|
|
26
|
+
will be raised.
|
|
27
|
+
|
|
28
|
+
## Bitstamp ticker
|
|
29
|
+
|
|
30
|
+
The bitstamp ticker. Returns `last`, `high`, `low`, `volume`, `bid` and `ask`
|
|
31
|
+
|
|
32
|
+
```ruby
|
|
33
|
+
Bitstamp.ticker
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
It's also possible to query through the `Bitstamp::Ticker` object with
|
|
37
|
+
each individual method.
|
|
38
|
+
|
|
39
|
+
```ruby
|
|
40
|
+
Bitstamp::Ticker.low # => "109.00"
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Fetch your open order
|
|
44
|
+
|
|
45
|
+
Returns an array with your open orders.
|
|
46
|
+
|
|
47
|
+
```ruby
|
|
48
|
+
Bitstamp.orders.all
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Create a sell order
|
|
52
|
+
|
|
53
|
+
Returns an `Order` object.
|
|
54
|
+
|
|
55
|
+
```ruby
|
|
56
|
+
Bitstamp.orders.sell(amount: 1.0, price: 111)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Create a buy order
|
|
60
|
+
|
|
61
|
+
Returns an `Order` object.
|
|
62
|
+
|
|
63
|
+
```ruby
|
|
64
|
+
Bitstamp.orders.buy(amount: 1.0, price: 111)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Fetch your transactions
|
|
68
|
+
|
|
69
|
+
Returns an `Array` of `UserTransaction`.
|
|
70
|
+
|
|
71
|
+
```ruby
|
|
72
|
+
Bitstamp.user_transactions.all
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
*To be continued!**
|
|
76
|
+
|
|
77
|
+
# Tests
|
|
78
|
+
|
|
79
|
+
If you'd like to run the tests you need to set the following environment variables:
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
export BITSTAMP_KEY=xxx
|
|
83
|
+
export BITSTAMP_SECRET=yyy
|
|
84
|
+
export BITSTAMP_CLIENT_ID=zzz
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Contributing
|
|
88
|
+
|
|
89
|
+
1. Fork it
|
|
90
|
+
2. Create your feature branch (`git checkout -b
|
|
91
|
+
my-new-feature`)
|
|
92
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
93
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
94
|
+
5. Create new Pull Request
|
|
95
|
+
|
|
96
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
Jeweler::Tasks.new do |gem|
|
|
18
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
|
19
|
+
gem.name = "coinfloor"
|
|
20
|
+
gem.homepage = "http://github.com/kojnapp/coinfloor"
|
|
21
|
+
gem.license = "MIT"
|
|
22
|
+
gem.summary = %Q{Coinfloor Ruby API}
|
|
23
|
+
gem.description = %Q{Ruby API for use with coinfloor.}
|
|
24
|
+
gem.email = "stygeo@gmail.com"
|
|
25
|
+
gem.authors = ["Jeffrey Wilcke"]
|
|
26
|
+
# dependencies defined in Gemfile
|
|
27
|
+
end
|
|
28
|
+
Jeweler::RubygemsDotOrgTasks.new
|
|
29
|
+
|
|
30
|
+
require 'rspec/core'
|
|
31
|
+
require 'rspec/core/rake_task'
|
|
32
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
|
33
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
|
37
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
|
38
|
+
spec.rcov = true
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
task :default => :spec
|
|
42
|
+
|
|
43
|
+
require 'rdoc/task'
|
|
44
|
+
Rake::RDocTask.new do |rdoc|
|
|
45
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
|
46
|
+
|
|
47
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
48
|
+
rdoc.title = "coinfloor #{version}"
|
|
49
|
+
rdoc.rdoc_files.include('README*')
|
|
50
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
51
|
+
end
|
data/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.4.0
|
data/coinfloor.gemspec
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
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: coinfloor 0.4.0 ruby lib
|
|
6
|
+
|
|
7
|
+
Gem::Specification.new do |s|
|
|
8
|
+
s.name = "coinfloor"
|
|
9
|
+
s.version = "0.1.0"
|
|
10
|
+
|
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
12
|
+
s.authors = ["Vadim Marchenko"]
|
|
13
|
+
s.date = "2014-03-09"
|
|
14
|
+
s.description = "Ruby API for use with coinfloor."
|
|
15
|
+
s.email = "vadim@gmail.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
|
+
"coinfloor.gemspec",
|
|
31
|
+
"lib/coinfloor.rb",
|
|
32
|
+
"lib/coinfloor/collection.rb",
|
|
33
|
+
"lib/coinfloor/helper.rb",
|
|
34
|
+
"lib/coinfloor/model.rb",
|
|
35
|
+
"lib/coinfloor/net.rb",
|
|
36
|
+
"lib/coinfloor/orders.rb",
|
|
37
|
+
"lib/coinfloor/ticker.rb",
|
|
38
|
+
"lib/coinfloor/transactions.rb"
|
|
39
|
+
]
|
|
40
|
+
s.homepage = "https://github.com/cryptopay-dev/coinfloor-ruby"
|
|
41
|
+
s.licenses = ["MIT"]
|
|
42
|
+
s.require_paths = ["lib"]
|
|
43
|
+
s.rubygems_version = "2.1.11"
|
|
44
|
+
s.summary = "Coinfloor Ruby API"
|
|
45
|
+
|
|
46
|
+
end
|
|
47
|
+
|
data/lib/coinfloor.rb
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
require 'active_support/core_ext'
|
|
2
|
+
require 'active_support/inflector'
|
|
3
|
+
require 'active_model'
|
|
4
|
+
require 'rest_client'
|
|
5
|
+
require 'hmac-sha2'
|
|
6
|
+
|
|
7
|
+
require 'coinfloor/net'
|
|
8
|
+
require 'coinfloor/helper'
|
|
9
|
+
require 'coinfloor/collection'
|
|
10
|
+
require 'coinfloor/model'
|
|
11
|
+
|
|
12
|
+
require 'coinfloor/orders'
|
|
13
|
+
require 'coinfloor/transactions'
|
|
14
|
+
require 'coinfloor/ticker'
|
|
15
|
+
|
|
16
|
+
String.send(:include, ActiveSupport::Inflector)
|
|
17
|
+
|
|
18
|
+
module Coinfloor
|
|
19
|
+
# API Key
|
|
20
|
+
mattr_accessor :key
|
|
21
|
+
|
|
22
|
+
# Coinfloor secret
|
|
23
|
+
mattr_accessor :secret
|
|
24
|
+
|
|
25
|
+
# Coinfloor client ID
|
|
26
|
+
mattr_accessor :client_id
|
|
27
|
+
|
|
28
|
+
# Currency
|
|
29
|
+
mattr_accessor :currency
|
|
30
|
+
@@currency = :gbp
|
|
31
|
+
|
|
32
|
+
def self.orders
|
|
33
|
+
self.sanity_check!
|
|
34
|
+
|
|
35
|
+
@@orders ||= Coinfloor::Orders.new
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def self.user_transactions
|
|
39
|
+
self.sanity_check!
|
|
40
|
+
|
|
41
|
+
@@transactions ||= Coinfloor::UserTransactions.new
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def self.transactions
|
|
45
|
+
return Coinfloor::Transactions.from_api
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def self.balance
|
|
49
|
+
self.sanity_check!
|
|
50
|
+
|
|
51
|
+
JSON.parse Coinfloor::Net.post('/balance').to_str
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def self.withdraw_bitcoins(options = {})
|
|
55
|
+
self.sanity_check!
|
|
56
|
+
if options[:amount].nil? || options[:address].nil?
|
|
57
|
+
raise MissingConfigExeception.new("Required parameters not supplied, :amount, :address")
|
|
58
|
+
end
|
|
59
|
+
response_body = Coinfloor::Net.post('/bitcoin_withdrawal',options).body_str
|
|
60
|
+
if response_body != 'true'
|
|
61
|
+
return JSON.parse response_body
|
|
62
|
+
else
|
|
63
|
+
return response_body
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def self.bitcoin_deposit_address
|
|
68
|
+
# returns the deposit address
|
|
69
|
+
self.sanity_check!
|
|
70
|
+
return Coinfloor::Net.post('/bitcoin_deposit_address').body_str
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def self.unconfirmed_user_deposits
|
|
74
|
+
self.sanity_check!
|
|
75
|
+
return JSON.parse Coinfloor::Net::post("/unconfirmed_btc").body_str
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def self.ticker
|
|
79
|
+
return Coinfloor::Ticker.from_api
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def self.order_book
|
|
83
|
+
return JSON.parse Coinfloor::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("Coinfloor Gem not properly configured")
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
class MissingConfigExeception<Exception;end;
|
|
101
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module Coinfloor
|
|
2
|
+
class Collection
|
|
3
|
+
attr_accessor :access_token, :module, :name, :model, :path
|
|
4
|
+
|
|
5
|
+
def initialize(api_prefix="/api")
|
|
6
|
+
self.access_token = Coinfloor.key
|
|
7
|
+
|
|
8
|
+
self.module = self.class.to_s.singularize.underscore
|
|
9
|
+
self.name = self.module.split('/').last
|
|
10
|
+
self.model = self.module.camelize.constantize
|
|
11
|
+
self.path = "#{api_prefix}/#{self.name.pluralize}"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def all(options = {})
|
|
15
|
+
Coinfloor::Helper.parse_objects! Coinfloor::Net::get(self.path).to_str, self.model
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def create(options = {})
|
|
19
|
+
Coinfloor::Helper.parse_object! Coinfloor::Net::post(self.path, options).to_str, self.model
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def find(id, options = {})
|
|
23
|
+
Coinfloor::Helper.parse_object! Coinfloor::Net::get("#{self.path}/#{id}").to_str, self.model
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def update(id, options = {})
|
|
27
|
+
Coinfloor::Helper.parse_object! Coinfloor::Net::patch("#{self.path}/#{id}", options).to_str, self.model
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Coinfloor
|
|
2
|
+
module Helper
|
|
3
|
+
def self.parse_objects!(string, klass)
|
|
4
|
+
# If Coinfloor returned nothing (which it does if the results yield empty) 'cast' it to an array
|
|
5
|
+
string = "[]" if string == ""
|
|
6
|
+
|
|
7
|
+
objects = JSON.parse(string)
|
|
8
|
+
objects.collect do |t_json|
|
|
9
|
+
parse_object!(t_json, klass)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.parse_object!(object, klass)
|
|
14
|
+
object = JSON.parse(object) if object.is_a? String
|
|
15
|
+
|
|
16
|
+
klass.new(object)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Coinfloor
|
|
2
|
+
class Model
|
|
3
|
+
attr_accessor :error, :message
|
|
4
|
+
|
|
5
|
+
include ActiveModel::Validations
|
|
6
|
+
include ActiveModel::Conversion
|
|
7
|
+
extend ActiveModel::Naming
|
|
8
|
+
|
|
9
|
+
def initialize(attributes = {})
|
|
10
|
+
self.attributes = attributes
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# Set the attributes based on the given hash
|
|
14
|
+
def attributes=(attributes = {})
|
|
15
|
+
attributes.each do |name, value|
|
|
16
|
+
begin
|
|
17
|
+
send("#{name}=", value)
|
|
18
|
+
rescue NoMethodError => e
|
|
19
|
+
puts "Unable to assign #{name}. No such method."
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Returns a hash with the current instance variables
|
|
25
|
+
def attributes
|
|
26
|
+
Hash[instance_variables.map { |name| [name, instance_variable_get(name)] }]
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module Coinfloor
|
|
2
|
+
module Net
|
|
3
|
+
def self.to_uri(path)
|
|
4
|
+
return "https://webapi.coinfloor.co.uk:8090/bist/XBT/GBP#{path}/"
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def self.get(path, options={})
|
|
8
|
+
RestClient::Request.execute method: :get,
|
|
9
|
+
url: self.to_uri(path),
|
|
10
|
+
user: "#{Coinfloor.client_id}/#{Coinfloor.key}",
|
|
11
|
+
password: Coinfloor.secret
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.post(path, options={})
|
|
15
|
+
RestClient::Request.execute method: :post,
|
|
16
|
+
payload: options,
|
|
17
|
+
url: self.to_uri(path),
|
|
18
|
+
user: "#{Coinfloor.client_id}/#{Coinfloor.key}",
|
|
19
|
+
password: Coinfloor.secret
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.patch(path, options={})
|
|
23
|
+
RestClient::Request.execute method: :put,
|
|
24
|
+
payload: options,
|
|
25
|
+
url: self.to_uri(path),
|
|
26
|
+
user: "#{Coinfloor.client_id}/#{Coinfloor.key}",
|
|
27
|
+
password: Coinfloor.secret
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self.delete(path, options={})
|
|
31
|
+
RestClient::Request.execute method: :delete,
|
|
32
|
+
payload: options,
|
|
33
|
+
url: self.to_uri(path),
|
|
34
|
+
user: "#{Coinfloor.client_id}/#{Coinfloor.key}",
|
|
35
|
+
password: Coinfloor.secret
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module Coinfloor
|
|
2
|
+
class Orders < Coinfloor::Collection
|
|
3
|
+
def all(options = {})
|
|
4
|
+
Coinfloor::Helper.parse_objects! Coinfloor::Net::post('/open_orders').to_str, self.model
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def create(options = {})
|
|
8
|
+
path = (options[:type] == Coinfloor::Order::SELL ? "/sell" : "/buy")
|
|
9
|
+
Coinfloor::Helper.parse_object! Coinfloor::Net::post(path, options).to_str, self.model
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def sell(options = {})
|
|
13
|
+
options.merge!({type: Coinfloor::Order::SELL})
|
|
14
|
+
self.create options
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def buy(options = {})
|
|
18
|
+
options.merge!({type: Coinfloor::Order::BUY})
|
|
19
|
+
self.create options
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def find(order_id)
|
|
23
|
+
all = self.all
|
|
24
|
+
index = all.index {|order| order.id.to_i == order_id}
|
|
25
|
+
|
|
26
|
+
return all[index] if index
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
class Order < Coinfloor::Model
|
|
31
|
+
BUY = 0
|
|
32
|
+
SELL = 1
|
|
33
|
+
|
|
34
|
+
attr_accessor :type, :amount, :price, :id, :datetime
|
|
35
|
+
attr_accessor :error, :message
|
|
36
|
+
|
|
37
|
+
def cancel!
|
|
38
|
+
Coinfloor::Net::post('/cancel_order', {id: self.id}).to_str
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Coinfloor
|
|
2
|
+
class Ticker < Coinfloor::Model
|
|
3
|
+
attr_accessor :last, :high, :low, :volume, :bid, :ask, :timestamp, :vwap
|
|
4
|
+
|
|
5
|
+
def self.from_api
|
|
6
|
+
Coinfloor::Helper.parse_object!(Coinfloor::Net.get('/ticker').to_str, self)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def self.method_missing method, *args
|
|
10
|
+
ticker = self.from_api
|
|
11
|
+
return ticker.send(method) if ticker.respond_to? method
|
|
12
|
+
|
|
13
|
+
super
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module Coinfloor
|
|
2
|
+
class UserTransactions < Coinfloor::Collection
|
|
3
|
+
def all(options = {})
|
|
4
|
+
# Default time delta to an hour
|
|
5
|
+
options[:timedelta] = "3600" unless options[:timedelta]
|
|
6
|
+
|
|
7
|
+
Coinfloor::Helper.parse_objects! Coinfloor::Net::post("/user_transactions", options).to_str, self.model
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def find(order_id)
|
|
11
|
+
all = self.all
|
|
12
|
+
index = all.index {|order| order.id.to_i == order_id}
|
|
13
|
+
|
|
14
|
+
return all[index] if index
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def create(options = {})
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def update(options={})
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class UserTransaction < Coinfloor::Model
|
|
25
|
+
attr_accessor :datetime, :id, :type, :usd, :btc, :fee, :order_id, :btc_usd, :nonce
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# adding in methods to pull the last public trades list
|
|
29
|
+
class Transactions < Coinfloor::Model
|
|
30
|
+
attr_accessor :date, :price, :tid, :amount
|
|
31
|
+
|
|
32
|
+
def self.from_api
|
|
33
|
+
Coinfloor::Helper.parse_objects! Coinfloor::Net::get("/transactions").to_str, self
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: coinfloor
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Vadim Marchenko
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-03-09 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Ruby API for use with coinfloor.
|
|
14
|
+
email: vadim@gmail.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files:
|
|
18
|
+
- LICENSE.txt
|
|
19
|
+
- README.md
|
|
20
|
+
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
|
+
- coinfloor.gemspec
|
|
31
|
+
- lib/coinfloor.rb
|
|
32
|
+
- lib/coinfloor/collection.rb
|
|
33
|
+
- lib/coinfloor/helper.rb
|
|
34
|
+
- lib/coinfloor/model.rb
|
|
35
|
+
- lib/coinfloor/net.rb
|
|
36
|
+
- lib/coinfloor/orders.rb
|
|
37
|
+
- lib/coinfloor/ticker.rb
|
|
38
|
+
- lib/coinfloor/transactions.rb
|
|
39
|
+
homepage: https://github.com/cryptopay-dev/coinfloor-ruby
|
|
40
|
+
licenses:
|
|
41
|
+
- MIT
|
|
42
|
+
metadata: {}
|
|
43
|
+
post_install_message:
|
|
44
|
+
rdoc_options: []
|
|
45
|
+
require_paths:
|
|
46
|
+
- lib
|
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
48
|
+
requirements:
|
|
49
|
+
- - ">="
|
|
50
|
+
- !ruby/object:Gem::Version
|
|
51
|
+
version: '0'
|
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
|
+
requirements:
|
|
54
|
+
- - ">="
|
|
55
|
+
- !ruby/object:Gem::Version
|
|
56
|
+
version: '0'
|
|
57
|
+
requirements: []
|
|
58
|
+
rubyforge_project:
|
|
59
|
+
rubygems_version: 2.5.1
|
|
60
|
+
signing_key:
|
|
61
|
+
specification_version: 4
|
|
62
|
+
summary: Coinfloor Ruby API
|
|
63
|
+
test_files: []
|