shapeshift_ruby 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/shapeshift_ruby/client.rb +99 -0
- data/lib/shapeshift_ruby/version.rb +3 -0
- data/lib/shapeshift_ruby.rb +5 -0
- data/shapeshift-ruby.gemspec +28 -0
- metadata +113 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cba4bebc483f36c33b5a4654dfbe10f69f949e99
|
4
|
+
data.tar.gz: 8e72cd6983cb65e1678914e8d221a89a4b5ad43d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 64199ade97389b76414a6d3b456eded4feb9ef9412a825065afd110da6f784da98af77c418290aa98543584f86e15017f19cd7b57a2f5f68dc17bbb6069610c5
|
7
|
+
data.tar.gz: 25420d7969150ec31de26b94dd5e190a20308cac593f6c087003db969a3508f85252d32953c5ae8c25fe681adbadcf92dec2733c5083319162845b790aeb5472
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Bogdan Sviripa
|
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,39 @@
|
|
1
|
+
# ShapeShift API Wrapper
|
2
|
+
|
3
|
+
A ruby wrapper for the [shapshift.io API](https://shapeshift.io)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'shapeshift_ruby'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install shapeshift_ruby
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require 'shapeshift_ruby'
|
25
|
+
client = ShapeShiftRuby::Client.new
|
26
|
+
client.rate(pair: 'btc_ltc')
|
27
|
+
=> {"pair"=>"btc_ltc", "rate"=>"59.50746268"}
|
28
|
+
```
|
29
|
+
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/iamkidjoe/shapeshift-ruby.
|
34
|
+
|
35
|
+
|
36
|
+
## License
|
37
|
+
|
38
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
39
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'shapeshift_ruby'
|
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
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module ShapeShiftRuby
|
5
|
+
class Client
|
6
|
+
API_URL = 'https://shapeshift.io'.freeze
|
7
|
+
|
8
|
+
# GET Requests
|
9
|
+
|
10
|
+
def rate(pair:)
|
11
|
+
api_request(url: url("rate/#{pair}"), method: 'get')
|
12
|
+
end
|
13
|
+
|
14
|
+
def limit(pair:)
|
15
|
+
api_request(url: url("rate/#{pair}"), method: 'get')
|
16
|
+
end
|
17
|
+
|
18
|
+
def market_info(pair:)
|
19
|
+
api_request(url: url("marketinfo/#{pair}"), method: 'get')
|
20
|
+
end
|
21
|
+
|
22
|
+
def recent_transactions(max:)
|
23
|
+
api_request(url: url("marketinfo/#{max}"), method: 'get')
|
24
|
+
end
|
25
|
+
|
26
|
+
def transaction_status(deposit_address:)
|
27
|
+
api_request(url: url("txStat/#{deposit_address}"), method: 'get')
|
28
|
+
end
|
29
|
+
|
30
|
+
def time_remaining(deposit_address:)
|
31
|
+
api_request(url: url("timeremaining/#{deposit_address}"), method: 'get')
|
32
|
+
end
|
33
|
+
|
34
|
+
def coins
|
35
|
+
api_request(url: url('getcoins'), method: 'get')
|
36
|
+
end
|
37
|
+
|
38
|
+
def validate_address(address:, coin_symbol:)
|
39
|
+
api_request(url: url("validateAddress/#{address}/#{coin_symbol}"), method: 'get')
|
40
|
+
end
|
41
|
+
|
42
|
+
def transaction_by_api_key(api_key:)
|
43
|
+
api_request(url: url("txbyapikey/#{api_key}"), method: 'get')
|
44
|
+
end
|
45
|
+
|
46
|
+
def transaction_by_address(address, api_key:)
|
47
|
+
api_request(url: url("txbyaddress/#{address}/#{api_key}"), method: 'get')
|
48
|
+
end
|
49
|
+
|
50
|
+
# Post requests
|
51
|
+
|
52
|
+
def shift(withdrawal:, pair:, return_address: '', dest_tag: '', rs_address: '', api_key: '')
|
53
|
+
api_request(url: url('shift'), method: 'post', params: {
|
54
|
+
pair: pair,
|
55
|
+
withdrawal: withdrawal,
|
56
|
+
returnAddress: return_address,
|
57
|
+
destTag: dest_tag,
|
58
|
+
rsAddress: rs_address,
|
59
|
+
apiKey: api_key
|
60
|
+
})
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
def mail(email:, transaction_id:)
|
65
|
+
api_request(url: url('mail'), method: 'post', params: { email: email, txid: transaction_id })
|
66
|
+
end
|
67
|
+
|
68
|
+
def fixed_amount_transaction(withdrawal:, pair:, amount:, return_address: '', dest_tag: '', rs_address: '', api_key: '')
|
69
|
+
api_request(url: url('sendamount'), method: 'post', params: {
|
70
|
+
amount: amount,
|
71
|
+
pair: pair,
|
72
|
+
withdrawal: withdrawal,
|
73
|
+
returnAddress: return_address,
|
74
|
+
destTag: dest_tag,
|
75
|
+
rsAddress: rs_address,
|
76
|
+
apiKey: api_key
|
77
|
+
})
|
78
|
+
end
|
79
|
+
|
80
|
+
def cancel_pending(address:)
|
81
|
+
api_request(url: url('cancelpending'), method: 'post', params: { address: address })
|
82
|
+
end
|
83
|
+
|
84
|
+
private
|
85
|
+
|
86
|
+
def url(path)
|
87
|
+
"#{API_URL}/#{path}"
|
88
|
+
end
|
89
|
+
|
90
|
+
def api_request(url:, method:, params: {})
|
91
|
+
data = RestClient::Request.execute(
|
92
|
+
method: method,
|
93
|
+
url: url,
|
94
|
+
payload: params,
|
95
|
+
)
|
96
|
+
JSON.parse(data)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'shapeshift_ruby/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'shapeshift_ruby'
|
8
|
+
spec.version = ShapeShiftRuby::VERSION
|
9
|
+
spec.authors = ['Bogdan Sviripa']
|
10
|
+
spec.email = ['iamkidjoe@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = 'A ruby wrapper for the ShapeShift API'
|
13
|
+
spec.description = 'A ruby wrapper for the ShapeShift API'
|
14
|
+
spec.homepage = 'https://github.com/iamkidjoe/shapeshift_ruby'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = 'exe'
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ['lib']
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.14'
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
27
|
+
spec.add_runtime_dependency 'rest-client', '~> 2.0.2'
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: shapeshift_ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bogdan Sviripa
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-09-01 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.14'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.14'
|
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
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rest-client
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.0.2
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.0.2
|
69
|
+
description: A ruby wrapper for the ShapeShift API
|
70
|
+
email:
|
71
|
+
- iamkidjoe@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/console
|
84
|
+
- bin/setup
|
85
|
+
- lib/shapeshift_ruby.rb
|
86
|
+
- lib/shapeshift_ruby/client.rb
|
87
|
+
- lib/shapeshift_ruby/version.rb
|
88
|
+
- shapeshift-ruby.gemspec
|
89
|
+
homepage: https://github.com/iamkidjoe/shapeshift_ruby
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 2.5.2
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: A ruby wrapper for the ShapeShift API
|
113
|
+
test_files: []
|