yobit 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d009344d1d31886363efcf153d44e0fe6b0ce48a
4
+ data.tar.gz: 4a5088e2909287c452b60f57f13d5c7b7ea17c5c
5
+ SHA512:
6
+ metadata.gz: 0d0c2ff2e9143095173aecf08a57af0ea04ce3be6c0e11965ea98379b2fbba0ecc80602c0ea31b877515546dbf73315e50c42a4b248a936ec8977249f2ce9dce
7
+ data.tar.gz: cf31462b2666ceb2d187f2c3775a0a296fe6fbb62d93f63f691ee8f5f29a579f60ac9d040375a9422efebe4e7d64a130630151620fd3d410f3113fc59f789359
@@ -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 yobit.gemspec
4
+ gemspec
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2017 Ryan Fox
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.
@@ -0,0 +1,36 @@
1
+ # Yobit
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/yobit`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'yobit'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install yobit
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
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/[USERNAME]/yobit. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "yobit"
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
@@ -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,117 @@
1
+ require "yobit/version"
2
+ require 'openssl'
3
+ require 'rest-client'
4
+ require 'addressable/uri'
5
+
6
+ module Yobit
7
+ PUBLIC_API_URL = 'https://yobit.net/api/3/'.freeze
8
+ TRADE_API_URL = 'https://yobit.net/tapi/'.freeze
9
+
10
+ class ApiConfig
11
+ attr_accessor :key
12
+
13
+ def initialize
14
+ @key = ''
15
+ end
16
+ end
17
+
18
+ class << self
19
+ attr_accessor :config
20
+ end
21
+
22
+ def self.setup
23
+ @config ||= ApiConfig.new
24
+ yield config
25
+ end
26
+
27
+ def self.info
28
+ get('info')
29
+ end
30
+
31
+ def self.ticker(pairs_list)
32
+ currencies = prepare_pairs(pairs_list)
33
+ get('ticker' + currencies)
34
+ end
35
+
36
+ def self.depth(pairs_list:, limit: 150)
37
+ limit = 2000 if (limit > 2000)
38
+ currencies = prepare_pairs(pairs_list)
39
+ get('depth' + currencies, limit: limit)
40
+ end
41
+
42
+ def self.trades(pairs_list:, limit: 150)
43
+ limit = 2000 if (limit > 2000)
44
+ currencies = prepare_pairs(pairs_list)
45
+ get('trades' + currencies, limit: limit)
46
+ end
47
+
48
+ def self.get_info
49
+ get('getInfo', client: trade_client)
50
+ end
51
+
52
+ def self.trade(pair:, type:, rate:, amount:)
53
+ post('Trade', client: trade_client, pair: pair, type: type, rate: rate, amount: amount)
54
+ end
55
+
56
+ def self.active_orders(pair)
57
+ get('ActiveOrders', client: trade_client, pair: pair)
58
+ end
59
+
60
+ def self.order_info(order_id)
61
+ get('OrderInfo', client: trade_client, order_id: order_id)
62
+ end
63
+
64
+ def self.cancel_order(order_id)
65
+ post('CancelOrder', client: trade_client, order_id: order_id)
66
+ end
67
+
68
+ def self.trade_history(from: 0, count: 1000, from_id: 0, end_id: 1000, order: "DESC", since: 0, end_time: Time.new(3000).to_i, pair:)
69
+ post('TradeHistory', client: trade_client,
70
+ from: from,
71
+ count: count,
72
+ from_id: from_id,
73
+ end_id: end_id,
74
+ order: order,
75
+ since: since,
76
+ end_time: end_time,
77
+ pair: pair)
78
+ end
79
+
80
+ def self.get_deposit_address(coin_name:, need_new: 0)
81
+ get('GetDepositAddress', client: trade_client, coinName: coin_name, need_new: need_new)
82
+ end
83
+
84
+ def self.withdraw_coins_to_address(coin_name:, amount:, address:)
85
+ post('WithdrawCoinsToAddress', client: trade_client, coinName: coin_name, amount: amount, address: address)
86
+ end
87
+
88
+ protected
89
+
90
+ def self.prepare_pairs(pairs_list)
91
+ pairs_list.join("-").prepend("/")
92
+ end
93
+
94
+ def self.public_client
95
+ @@public_client ||= RestClient::Resource.new(Yobit::PUBLIC_API_URL)
96
+ end
97
+
98
+ def self.trade_client
99
+ @@trade_client ||= RestClient::Resource.new(Yobit::TRADE_API_URL)
100
+ end
101
+
102
+ def self.get(method_name, client: public_client, **params)
103
+ client[method_name].get(params)
104
+ end
105
+
106
+ def self.post(method_name, client: public_client, **params)
107
+ params[:nonce] = (Time.now.to_f * 10000000).to_i
108
+ params[:sign] = create_sign(params)
109
+ client[method_name].post(params, {key: config.key})
110
+ end
111
+
112
+ def self.create_sign(data)
113
+ encoded_data = Addressable::URI.form_encode(data)
114
+ OpenSSL::HMAC.hexdigest('sha512', config.key, encoded_data)
115
+ end
116
+
117
+ end
@@ -0,0 +1,3 @@
1
+ module Yobit
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'yobit/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "yobit"
8
+ spec.version = Yobit::VERSION
9
+ spec.authors = ["Ryan Fox"]
10
+ spec.email = ["rfox75@gmail.com"]
11
+ spec.summary = %q{yobit.net api wrapper}
12
+ spec.description = %q{yobit.net api wrapper}
13
+ spec.homepage = "http://www.github.com/austra/yobit"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.13"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+
24
+ spec.add_dependency 'rest-client'
25
+ spec.add_dependency 'addressable'
26
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yobit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ryan Fox
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-06-22 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.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
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: rest-client
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: addressable
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: yobit.net api wrapper
70
+ email:
71
+ - rfox75@gmail.com
72
+ executables:
73
+ - console
74
+ - setup
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".gitignore"
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - bin/console
84
+ - bin/setup
85
+ - lib/yobit.rb
86
+ - lib/yobit/version.rb
87
+ - yobit.gemspec
88
+ homepage: http://www.github.com/austra/yobit
89
+ licenses:
90
+ - MIT
91
+ metadata: {}
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ requirements: []
107
+ rubyforge_project:
108
+ rubygems_version: 2.5.1
109
+ signing_key:
110
+ specification_version: 4
111
+ summary: yobit.net api wrapper
112
+ test_files: []