shapeshiftio 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d8521419ac9cc63ddc3966299a099a8b224e97ac
4
+ data.tar.gz: 0e9cb73787dac20e96e55a7943dcaea502e23712
5
+ SHA512:
6
+ metadata.gz: d166c033b47a05ed8e0baaba6ffc8eff970ce61bd0901ce7d4c9c0012c3aa9b2520b8db59625bc2e1fbca58ca5c1daab690a5dc5d2a94d3c7d67bbcad09a4944
7
+ data.tar.gz: 73eecafd1eaeed6c20d6cadf0c92c80c7b896f9bfa7cf1ad876c56464544084cdb6837f675a2edd54a3177f8eb935fbe11d3e2f71aa0bd0603bbadf4e31c2780
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in shapeshift.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,19 @@
1
+ The MIT License (MIT)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # Shapeshift
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/shapeshift`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Refactor and make code base more DRY
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'shapeshift'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install shapeshift
22
+
23
+ ## Usage
24
+
25
+ TODO: Use cases and example code coming soon.
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/atjohnson/shapeshift.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "shapeshiftio"
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,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,3 @@
1
+ module Shapeshiftio
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,110 @@
1
+ require "shapeshift/version"
2
+ require 'net/http'
3
+ require 'json'
4
+ module Shapeshiftio
5
+
6
+ private
7
+ def self.api_call(params,url_method)
8
+ url = URI.parse("https://shapeshift.io/#{url_method}")
9
+ req = Net::HTTP::Post.new(url.request_uri)
10
+
11
+ req.set_form_data(params)
12
+ http = Net::HTTP.new(url.host, url.port)
13
+ http.use_ssl = (url.scheme == "https")
14
+ response = http.request(req)
15
+ result = response.body.to_json
16
+ end
17
+
18
+
19
+ public
20
+ def self.get(path_name, value = nil, p2 = nil)
21
+ uri = URI("https://shapeshift.io/#{path_name}/#{value}/#{p2}")
22
+ response = Net::HTTP.get(uri)
23
+ check_response(response)
24
+ end
25
+
26
+ def self.get_coins
27
+ coins = get("getcoins")
28
+ all_coins = []
29
+ coins.each do |coin|
30
+ all_coins << coin[1]['name']
31
+ end
32
+ all_coins
33
+ end
34
+
35
+ def self.limit(coin_pair)
36
+ get("limit", coin_pair)
37
+ end
38
+
39
+ def self.market_info(coin_pair)
40
+ get("marketinfo", coin_pair)
41
+ end
42
+
43
+ def self.rate(coin_pair)
44
+ get("rate", coin_pair)
45
+ end
46
+
47
+ def self.recent_tx(max)
48
+ get("recenttx", max)
49
+ end
50
+
51
+ def self.tx_stat(deposit_address)
52
+ get("txStat", deposit_address)
53
+ end
54
+
55
+ def self.time_remaining(deposit_address)
56
+ get("timeremaining", deposit_address)
57
+ end
58
+
59
+ def self.validate(address,coin_symbol)
60
+ get("validateAddress",address,coin_symbol)
61
+ end
62
+
63
+ def self.shift(withdrawal, coin_pair, options = {})
64
+ params = {"withdrawal" => "#{withdrawal}",
65
+ "pair" => "#{coin_pair}",
66
+ "apiKey" => "c354645558d70364fbc6a6dc85679e602036cbabeb42c91b3e268e817dd3494c7a1304cd08e2499dfebd8b8d34c219a514ec66d5d013c190e4b82ea2d6f42437"
67
+ }.merge!(options)
68
+
69
+ api_call(params,"shift")
70
+ end
71
+
72
+ def self.receipt(email, txid)
73
+ params = { "email" => "#{email}", "txid" => "#{txid}"}
74
+
75
+ api_call(params,"mail")
76
+ end
77
+
78
+ def self.fixed(amount, wallet_address, coin_pair, options = {})
79
+
80
+ params = {
81
+ "amount" => "#{amount}",
82
+ "withdrawal" => "#{wallet_address}",
83
+ "pair" => "#{coin_pair}",
84
+ "apiKey" => "c354645558d70364fbc6a6dc85679e602036cbabeb42c91b3e268e817dd3494c7a1304cd08e2499dfebd8b8d34c219a514ec66d5d013c190e4b82ea2d6f42437"
85
+ }.merge!(options)
86
+ api_call(params,"sendamount")
87
+ end
88
+
89
+ def self.quote(amount, coin_pair)
90
+
91
+ params = { "amount" => "#{amount}", "pair" => "#{coin_pair}"}
92
+ api_call(params,"sendamount")
93
+ end
94
+
95
+ def self.cancel(deposit_address)
96
+ params= { "address" => "#{deposit_address}"}
97
+ api_call(params,"cancelpending")
98
+ end
99
+
100
+ private
101
+
102
+ def self.check_response(response)
103
+ begin
104
+ value = JSON.parse(response)
105
+ rescue JSON::ParserError
106
+ return puts "The API is not responding"
107
+ end
108
+ end
109
+
110
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'shapeshiftio/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "shapeshiftio"
8
+ spec.version = Shapeshiftio::VERSION
9
+ spec.authors = ["Ricardo Malafaia"]
10
+ spec.email = ["ricardo.malafaia1994@gmail.com"]
11
+
12
+ spec.summary = %q{A complete Ruby wrapper for the shapeshift.io API.}
13
+ spec.description = %q{}
14
+ spec.homepage = "https://github.com/rbm4/shapeshiftio"
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
+
27
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: shapeshiftio
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ricardo Malafaia
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-03-30 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
+ description: ''
42
+ email:
43
+ - ricardo.malafaia1994@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - bin/console
54
+ - bin/setup
55
+ - lib/shapeshiftio.rb
56
+ - lib/shapeshiftio/version.rb
57
+ - shapeshiftio.gemspec
58
+ homepage: https://github.com/rbm4/shapeshiftio
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.6.11
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: A complete Ruby wrapper for the shapeshift.io API.
82
+ test_files: []