coinone 0.1.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: '069fdbc2420b9ecbcb4dda0073ad2c9e686ed075'
4
- data.tar.gz: b459e4cddf4701f47aa02eb2bdb9f09476f31f8f
3
+ metadata.gz: 70f16d9aeb7c4a90669abc03eb6eac39ea0ba2c5
4
+ data.tar.gz: c30b05413fa6b6e1618675f8af3f5a958f2c26b7
5
5
  SHA512:
6
- metadata.gz: e93fac3835c04afdb083a68cff996612435975d21ac34cc715c89957e154c62bca76429b67836cffbff9a7a67d2c6925262d3b7f7c1002d46ce0957dff5bceb6
7
- data.tar.gz: 16ff0177794409a1ccd4235fbb2b2afa676f56027da3504b705b1ad6cb73bf3011fdf965253dd9c3e32ad9a8c13021f2aee5d0d7b1fa71b42193a986f4ddfb44
6
+ metadata.gz: ec6d6240d305d10a7bc9e41f408a76cecc8841e6876ca83f4cca4fc8f0dfd8e5cc2b3d499a70b5835aadcb1993b79eac76f7bf99263be589732df9d0226d935f
7
+ data.tar.gz: 1c0b91f1747a882689d03b5b3c822cdbdb5709ae0978c27a610d3c418dfe1a351b8b50789d16f91d97b1882dbc761d6d12ce515d28e02993f5fdad493605b671
data/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  # Coinone
2
2
  [![GemVersion](https://badge.fury.io/rb/coinone.svg)](https://badge.fury.io/rb/coinone)
3
3
 
4
- `Coinone` Gem is porting from Coinone API
5
-
4
+ `Coinone` Gem is Ruby Language porting from Coinone API, and only support V2.
6
5
 
7
6
  ## Installation
8
7
 
@@ -22,8 +21,80 @@ Or install it yourself as:
22
21
 
23
22
  ## Usage
24
23
 
24
+ First, You set `ACCESS_TOKEN` and `SECRET_KEY` using [figaro](https://github.com/laserlemon/figaro) or [dotenv](https://github.com/bkeepers/dotenv)
25
+
26
+ #### Account V2
27
+ - ACCOUNT V2 / Account Infomation
28
+ ```ruby
29
+ user = Coinone::Account.new(access_token: ENV['COINONE_ACCESS_TOKEN'], secret_key: ENV['COINONE_SECRET_KEY'])
30
+
31
+ user.get_user_info
32
+
33
+ ```
34
+
35
+ #### OAUTH
36
+
37
+ #### ORDER V2
38
+
39
+ #### PUBLIC
40
+
41
+ Not Need `ACCESS_TOKEN` and `SECRET_KEY`
42
+
43
+ - PUBLIC / Currency
44
+ ```ruby
45
+ currency = Coinone::Public.get_currency
46
+
47
+
48
+ ```
49
+
50
+ - PUBLIC / Orderbook
51
+ ```ruby
52
+ orderbook = Coinone::Public.get_orderbook # Default "BTC"
53
+
54
+ btc_orderbook = Coinone::Public.get_orderbook(currency: "btc") # BTC Orderbook
55
+
56
+ eth_orderbook = Coinone::Public.get_orderbook(currency: "eth") # ETH Orderbook
57
+
58
+ etc_orderbook = Coinone::Public.get_orderbook(currency: "etc") # ETC Orderbook
59
+
60
+ ```
61
+
25
62
 
26
- ## Todo
63
+ - PUBLIC / Recent Complete Orders
64
+ ```ruby
65
+ complete_orders = Coinone::Public.get_complete_orders # Default "BTC" and "Hour"
66
+
67
+ btc_hour_complete_orders = Coinone::Public.get_complete_orders(currency: "btc", period: "hour") # BTC and Hour Complete Orders
68
+
69
+ btc_day_complete_orders = Coinone::Public.get_complete_orders(currency: "btc", period: "day") # BTC and Day Complete Orders
70
+
71
+ eth_hour_complete_orders = Coinone::Public.get_complete_orders(currency: "eth", period: "hour") # ETH and Hour Complete Orders
72
+
73
+ eth_day_complete_orders = Coinone::Public.get_complete_orders(currency: "eth", period: "day") # ETH and Day Complete Orders
74
+
75
+ etc_hour_complete_orders = Coinone::Public.get_complete_orders(currency: "etc", period: "hour") # ETC and Hour Complete Orders
76
+
77
+ etc_day_complete_orders = Coinone::Public.get_complete_orders(currency: "etc", period: "day") # ETC and Hour Complete Orders
78
+
79
+ ```
80
+
81
+ - PUBLIC / Ticker
82
+ ```ruby
83
+ ticker = Coinone::Public.get_ticker # Default "BTC"
84
+
85
+ btc_ticker = Coinone::Public.get_ticker(currency: "btc") # BTC Ticker
86
+
87
+ etc_ticker = Coinone::Public.get_ticker(currency: "etc") # ETH Ticker
88
+
89
+ etc_ticker = Coinone::Public.get_ticker(currency: "etc") # ETC Ticker
90
+
91
+ all_ticker = Coinone::Public.get_ticker(currency: "all") # ALL Ticker
92
+
93
+ ```
94
+
95
+ #### TRANSACTION V2
96
+
97
+ ## ToDo
27
98
  - [x] ACCOUNT V2 / Account Infomation
28
99
  - [ ] ACCOUNT V2 / Balance
29
100
  - [ ] ACCOUNT V2 / Daily Balance
@@ -44,11 +115,10 @@ Or install it yourself as:
44
115
  - [ ] ORDER V2 / My Complete Orders
45
116
  - [ ] ORDER V2 / My Limit Orders
46
117
 
47
-
48
- - [ ] PUBLIC / Currency
49
- - [ ] PUBLIC / OrderBook
50
- - [ ] PUBLIC / Recent Complete Orders
51
- - [ ] PUBLIC / Ticker
118
+ - [x] PUBLIC / Currency
119
+ - [x] PUBLIC / OrderBook
120
+ - [x] PUBLIC / Recent Complete Orders
121
+ - [x] PUBLIC / Ticker
52
122
 
53
123
  - [ ] TRANSACTION V2 / 2-Factor Authentication
54
124
  - [ ] TRANSACTION V2 / Coin Transactions History
@@ -80,3 +150,6 @@ This link listing [Change Log](https://github.com/ggomagundan/coinone/blob/maste
80
150
 
81
151
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
82
152
 
153
+
154
+
155
+
data/coinone.gemspec CHANGED
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
36
36
  spec.add_development_dependency "bundler", "~> 1.14"
37
37
  spec.add_development_dependency "rake", "~> 10.0"
38
38
 
39
- spec.add_runtime_dependency "json", "~> 2.0.0"
40
- spec.add_dependency 'rest-client'
41
- spec.add_dependency 'addressable'
39
+ spec.add_runtime_dependency "json", "~> 2.0.0", ">= 2.0.0"
40
+ spec.add_dependency 'rest-client', '~> 2.0', '>= 2.0.1'
41
+ spec.add_dependency 'addressable', '~> 2.5'
42
42
  end
data/lib/coinone.rb CHANGED
@@ -3,5 +3,6 @@ require "coinone/version"
3
3
  module Coinone
4
4
  require 'coinone/connection'
5
5
  require 'coinone/account'
6
+ require 'coinone/public'
6
7
  require 'coinone/error'
7
8
  end
@@ -24,17 +24,12 @@ module Coinone
24
24
 
25
25
 
26
26
  def get_user_info
27
- res = @connection.post( "/account/user_info/")
27
+ response = @connection.post( "/v2/account/user_info/")
28
28
 
29
- @connection.check_for_errors(res.body)
30
-
31
- puts res.body
32
-
33
- set_user_info(res.body)
29
+ set_user_info(response)
34
30
  end
35
31
 
36
32
  def set_user_info(params={})
37
- json = JSON.parse(params, :symbolize_names => true)
38
33
 
39
34
  user_info = json[:userInfo]
40
35
  @security_level = user_info[:securityLevel].to_i
@@ -12,8 +12,8 @@ module Coinone
12
12
  end
13
13
 
14
14
  def update_info(params={})
15
- @taker = params[:taker] if params.has_key? :taker
16
- @maker = params[:maker] if params.has_key? :maker
15
+ @taker = params[:taker].to_f if params.has_key? :taker
16
+ @maker = params[:maker].to_f if params.has_key? :maker
17
17
  end
18
18
 
19
19
  end
@@ -12,8 +12,8 @@ module Coinone
12
12
  end
13
13
 
14
14
  def update_info(params={})
15
- @taker = params[:taker] if params.has_key? :taker
16
- @maker = params[:maker] if params.has_key? :maker
15
+ @taker = params[:taker].to_f if params.has_key? :taker
16
+ @maker = params[:maker].to_f if params.has_key? :maker
17
17
  end
18
18
 
19
19
  end
@@ -12,8 +12,8 @@ module Coinone
12
12
  end
13
13
 
14
14
  def update_info(params={})
15
- @taker = params[:taker] if params.has_key? :taker
16
- @maker = params[:maker] if params.has_key? :maker
15
+ @taker = params[:taker].to_f if params.has_key? :taker
16
+ @maker = params[:maker].to_f if params.has_key? :maker
17
17
  end
18
18
 
19
19
  end
@@ -10,13 +10,13 @@ module Coinone
10
10
 
11
11
  attr_reader :access_token, :secret_key
12
12
 
13
- BASE_URI = "https://api.coinone.co.kr/v2"
13
+ BASE_URI = "https://api.coinone.co.kr"
14
14
  REQUEST_URI = "https://coinone.co.kr/account/login/"
15
15
  AUTH_URI = "https://api.coinone.co.kr/oauth/access_token/"
16
16
  REFRESH_AUTH_URI = "https://api.coinone.co.kr/oauth/refresh_token/"
17
17
  DELETE_AUTH_URI = "https://api.coinone.co.kr/oauth/delete_token/"
18
- ACCESS_TOKEN = "ea3e8668-58cc-4eba-84b2-cdfbe616e5cc"
19
- SECRET_KEY= "dac26d4b-558f-4ada-b2ad-549bc1242554"
18
+ ACCESS_TOKEN = "ACESS_TOKEN"
19
+ SECRET_KEY= "SECRET_KEY"
20
20
 
21
21
  def self.factory(params) # :nodoc
22
22
  Connection.new(
@@ -37,7 +37,12 @@ module Coinone
37
37
  end
38
38
 
39
39
  def get( connection_uri, params = {} )
40
- resource[ connection_uri ].get params: params.merge(access_token: @access_token)
40
+
41
+ response = resource[ connection_uri ].get params: params.merge(access_token: @access_token)
42
+ check_for_errors(response.body)
43
+ JSON.parse(response.body, symbolize_names: true)
44
+
45
+
41
46
  end
42
47
 
43
48
  def post( connection_uri, params = {} )
@@ -52,8 +57,10 @@ module Coinone
52
57
  puts "signature: #{create_coinone_signature(payload)}"
53
58
  =end
54
59
 
55
- resource[ connection_uri ].post params, {'Content-Type': 'application/json', 'X-COINONE-PAYLOAD': payload, 'X-COINONE-SIGNATURE': signature }
60
+ response = resource[ connection_uri ].post params, {'Content-Type': 'application/json', 'X-COINONE-PAYLOAD': payload, 'X-COINONE-SIGNATURE': signature }
56
61
 
62
+ check_for_errors(response.body)
63
+ JSON.parse(response.body, symbolize_names: true)
57
64
  end
58
65
 
59
66
  def create_coinone_signature( payload )
@@ -0,0 +1,57 @@
1
+ require 'coinone/public/currency'
2
+ require 'coinone/public/orderbook'
3
+ require 'coinone/public/complete_orders'
4
+ require 'coinone/public/tickers'
5
+
6
+ module Coinone
7
+
8
+ module Public
9
+
10
+ attr_reader :currency, :orderbook, :complete_orders, :ticker
11
+
12
+ def get_currency(options={}, connection=nil)
13
+ @connection = connection || Connection.factory(options)
14
+ response = @connection.get("/currency")
15
+
16
+ puts response
17
+
18
+ @currency = Currency.new(response)
19
+
20
+ end
21
+
22
+ def get_orderbook(options={}, connection=nil)
23
+ @connection = connection || Connection.factory(options)
24
+ response = @connection.get("/orderbook", options)
25
+
26
+ puts response
27
+
28
+ @orderbook = Orderbook.new(response)
29
+
30
+ end
31
+
32
+ def get_complete_orders(options={}, connection=nil)
33
+ @connection = connection || Connection.factory(options)
34
+ response = @connection.get("/trades", options)
35
+
36
+ puts response
37
+
38
+ @complete_orders = CompleteOrders.new(response)
39
+ end
40
+
41
+
42
+ def get_ticker(options={}, connection=nil)
43
+ @connection = connection || Connection.factory(options)
44
+ response = @connection.get("/ticker", options)
45
+
46
+ puts response
47
+
48
+ @ticker = Tickers.new(response)
49
+
50
+
51
+ end
52
+
53
+ module_function :get_currency, :get_orderbook, :get_complete_orders, :get_ticker
54
+
55
+ end
56
+
57
+ end
@@ -0,0 +1,24 @@
1
+ require 'coinone/public/complete_orders/complete_order'
2
+ module Coinone
3
+
4
+ module Public
5
+ class CompleteOrders
6
+ attr_reader :orders, :timestamp, :currency
7
+
8
+ def initialize(params={})
9
+ @orders = []
10
+ @timestamp = params[:timestamp] || nil
11
+ @currency= params[:currency] || nil
12
+ push_orders(params[:completeOrders]) if params.has_key? :completeOrders
13
+ end
14
+
15
+ def push_orders(params)
16
+ params.each do |order|
17
+ @orders.push(CompleteOrder.new(order))
18
+ end
19
+ end
20
+
21
+ end
22
+ end
23
+
24
+ end
@@ -0,0 +1,18 @@
1
+ module Coinone
2
+
3
+ module Public
4
+ class CompleteOrders
5
+ class CompleteOrder
6
+ attr_reader :price, :qty, :timestamp
7
+
8
+ def initialize(params={})
9
+ @price = params[:price].to_i || nil
10
+ @qty = params[:qty].to_f || nil
11
+ @timestamp = params[:timestamp].to_i || nil
12
+ end
13
+ end
14
+
15
+ end
16
+ end
17
+
18
+ end
@@ -0,0 +1,16 @@
1
+ module Coinone
2
+
3
+ module Public
4
+ class Currency
5
+ attr_reader :currency, :source, :currency_type
6
+
7
+ def initialize(params={})
8
+ @currency = params[:currency].to_f || nil
9
+ @source = params[:source] || nil
10
+ @currency_type = params[:currencyType] || nil
11
+ end
12
+
13
+ end
14
+ end
15
+
16
+ end
@@ -0,0 +1,18 @@
1
+ require 'coinone/public/orderbook/orders'
2
+ module Coinone
3
+
4
+ module Public
5
+ class Orderbook
6
+ attr_reader :ask, :bid, :timestamp, :currency
7
+
8
+ def initialize(params={})
9
+ @ask = Orders.new(params[:ask]) || []
10
+ @bid = Orders.new(params[:bid]) || []
11
+ @timestamp = params[:timestamp].to_i || nil
12
+ @currency= params[:currency] || nil
13
+ end
14
+
15
+ end
16
+ end
17
+
18
+ end
@@ -0,0 +1,17 @@
1
+ module Coinone
2
+
3
+ module Public
4
+ class Orderbook
5
+ class Order
6
+ attr_reader :price, :qty
7
+
8
+ def initialize(params={})
9
+ @price = params[:price].to_i || nil
10
+ @qty = params[:qty].to_f || nil
11
+ end
12
+ end
13
+
14
+ end
15
+ end
16
+
17
+ end
@@ -0,0 +1,25 @@
1
+ require 'coinone/public/orderbook/order'
2
+ module Coinone
3
+
4
+ module Public
5
+ class Orderbook
6
+ class Orders
7
+ attr_reader :order_list
8
+
9
+ def initialize(params={})
10
+ @order_list = []
11
+ push_orders(params)
12
+ end
13
+
14
+ def push_orders(params)
15
+ params.each do |order|
16
+ @order_list.push(Order.new(order))
17
+ end
18
+ end
19
+
20
+ end
21
+
22
+ end
23
+ end
24
+
25
+ end
@@ -0,0 +1,26 @@
1
+ require 'coinone/public/tickers/ticker'
2
+ module Coinone
3
+
4
+ module Public
5
+ class Tickers
6
+ attr_reader :tickers
7
+
8
+ def initialize(params={})
9
+ @tickers = []
10
+ push_tickers(params)
11
+ end
12
+
13
+ def push_tickers(params)
14
+ currency_list = [:btc, :eth, :etc]
15
+ currency_list.each do |currency|
16
+ if params.has_key? currency
17
+ @tickers.push(Ticker.new(params[currency]))
18
+ end
19
+ end
20
+ @tickers.push(Ticker.new(params)) if params.has_key? :currency
21
+ end
22
+
23
+ end
24
+ end
25
+
26
+ end
@@ -0,0 +1,23 @@
1
+ module Coinone
2
+
3
+ module Public
4
+ class Tickers
5
+ class Ticker
6
+ attr_reader :volume, :last, :high, :currency, :low, :first
7
+
8
+ def initialize(params={})
9
+
10
+ @volume = params[:volume].to_f || nil
11
+ @last= params[:last].to_i || nil
12
+ @high= params[:high].to_i || nil
13
+ @currency= params[:currency] || nil
14
+ @low= params[:low].to_i || nil
15
+ @first= params[:first].to_i || nil
16
+
17
+ end
18
+ end
19
+
20
+ end
21
+ end
22
+
23
+ end
@@ -1,3 +1,3 @@
1
1
  module Coinone
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coinone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kai Park
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-07 00:00:00.000000000 Z
11
+ date: 2017-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -45,6 +45,9 @@ dependencies:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 2.0.0
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 2.0.0
48
51
  type: :runtime
49
52
  prerelease: false
50
53
  version_requirements: !ruby/object:Gem::Requirement
@@ -52,34 +55,43 @@ dependencies:
52
55
  - - "~>"
53
56
  - !ruby/object:Gem::Version
54
57
  version: 2.0.0
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 2.0.0
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: rest-client
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '2.0'
59
68
  - - ">="
60
69
  - !ruby/object:Gem::Version
61
- version: '0'
70
+ version: 2.0.1
62
71
  type: :runtime
63
72
  prerelease: false
64
73
  version_requirements: !ruby/object:Gem::Requirement
65
74
  requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '2.0'
66
78
  - - ">="
67
79
  - !ruby/object:Gem::Version
68
- version: '0'
80
+ version: 2.0.1
69
81
  - !ruby/object:Gem::Dependency
70
82
  name: addressable
71
83
  requirement: !ruby/object:Gem::Requirement
72
84
  requirements:
73
- - - ">="
85
+ - - "~>"
74
86
  - !ruby/object:Gem::Version
75
- version: '0'
87
+ version: '2.5'
76
88
  type: :runtime
77
89
  prerelease: false
78
90
  version_requirements: !ruby/object:Gem::Requirement
79
91
  requirements:
80
- - - ">="
92
+ - - "~>"
81
93
  - !ruby/object:Gem::Version
82
- version: '0'
94
+ version: '2.5'
83
95
  description: Wrapping for coinone.co.kr API
84
96
  email:
85
97
  - ggogun@gmail.com
@@ -111,6 +123,15 @@ files:
111
123
  - lib/coinone/account/virtual_account_info.rb
112
124
  - lib/coinone/connection.rb
113
125
  - lib/coinone/error.rb
126
+ - lib/coinone/public.rb
127
+ - lib/coinone/public/complete_orders.rb
128
+ - lib/coinone/public/complete_orders/complete_order.rb
129
+ - lib/coinone/public/currency.rb
130
+ - lib/coinone/public/orderbook.rb
131
+ - lib/coinone/public/orderbook/order.rb
132
+ - lib/coinone/public/orderbook/orders.rb
133
+ - lib/coinone/public/tickers.rb
134
+ - lib/coinone/public/tickers/ticker.rb
114
135
  - lib/coinone/version.rb
115
136
  homepage: https://github.com/ggomagundan/coinone
116
137
  licenses:
@@ -132,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
153
  version: '0'
133
154
  requirements: []
134
155
  rubyforge_project:
135
- rubygems_version: 2.6.8
156
+ rubygems_version: 2.6.10
136
157
  signing_key:
137
158
  specification_version: 4
138
159
  summary: Wrapping for coinone.co.kr API