coinone 0.2.1 → 0.3.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.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +0 -1
  4. data/CHANGE_LOG.md +10 -2
  5. data/Gemfile +3 -0
  6. data/LICENSE.txt +1 -1
  7. data/README.md +105 -5
  8. data/Rakefile +11 -2
  9. data/coinone.gemspec +1 -0
  10. data/lib/coinone/account.rb +14 -28
  11. data/lib/coinone/account/account_info.rb +54 -0
  12. data/lib/coinone/account/account_info/bank_info.rb +30 -0
  13. data/lib/coinone/account/account_info/email_info.rb +25 -0
  14. data/lib/coinone/account/account_info/fee_rates.rb +27 -0
  15. data/lib/coinone/account/account_info/fee_rates/fee_rate.rb +26 -0
  16. data/lib/coinone/account/account_info/mobile_info.rb +30 -0
  17. data/lib/coinone/account/account_info/virtual_account_info.rb +25 -0
  18. data/lib/coinone/account/balance.rb +48 -0
  19. data/lib/coinone/account/balance/normal_wallet.rb +32 -0
  20. data/lib/coinone/account/balance/wallet.rb +35 -0
  21. data/lib/coinone/connection.rb +11 -7
  22. data/lib/coinone/public.rb +4 -7
  23. data/lib/coinone/public/complete_orders.rb +3 -0
  24. data/lib/coinone/public/currency.rb +2 -0
  25. data/lib/coinone/public/orderbook.rb +16 -3
  26. data/lib/coinone/public/tickers.rb +5 -1
  27. data/lib/coinone/version.rb +1 -1
  28. metadata +26 -11
  29. data/lib/coinone/account/bank_info.rb +0 -30
  30. data/lib/coinone/account/email_info.rb +0 -23
  31. data/lib/coinone/account/fee_rate.rb +0 -27
  32. data/lib/coinone/account/fee_rate/btc.rb +0 -25
  33. data/lib/coinone/account/fee_rate/etc.rb +0 -25
  34. data/lib/coinone/account/fee_rate/eth.rb +0 -25
  35. data/lib/coinone/account/mobile_info.rb +0 -28
  36. data/lib/coinone/account/virtual_account_info.rb +0 -27
  37. data/lib/coinone/public/orderbook/orders.rb +0 -25
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 70f16d9aeb7c4a90669abc03eb6eac39ea0ba2c5
4
- data.tar.gz: c30b05413fa6b6e1618675f8af3f5a958f2c26b7
3
+ metadata.gz: 26be75820e3b1aa896a5128e17dd5f292763943b
4
+ data.tar.gz: d37fc6290bd507688f354c322f495b8867fe689d
5
5
  SHA512:
6
- metadata.gz: ec6d6240d305d10a7bc9e41f408a76cecc8841e6876ca83f4cca4fc8f0dfd8e5cc2b3d499a70b5835aadcb1993b79eac76f7bf99263be589732df9d0226d935f
7
- data.tar.gz: 1c0b91f1747a882689d03b5b3c822cdbdb5709ae0978c27a610d3c418dfe1a351b8b50789d16f91d97b1882dbc761d6d12ce515d28e02993f5fdad493605b671
6
+ metadata.gz: 4bc0d89cb228f8055b2f19bbd1de7c174c27bc270ff314d913f970bda31330621a347031204468c4cb9b721be3f865c3c2d3ef0eab19238d8b8d591bed68e90c
7
+ data.tar.gz: 23046fc8d17bce3f4df05e6bea3e385025821d89bcc641dca16da6c492b43b36abfaf8d46293c6aded2d858dc2a72ff3ac0ce2a71f1674c31fd5683d9c6d4d94
data/.gitignore CHANGED
@@ -11,3 +11,4 @@
11
11
  .DS_Store
12
12
  */.DS_Store
13
13
  Gemfile.lock
14
+ .env
@@ -3,7 +3,6 @@ language: ruby
3
3
  cache: bundler
4
4
 
5
5
  rvm:
6
- - 2.2
7
6
  - 2.3.0
8
7
  - ruby-head
9
8
 
@@ -1,4 +1,12 @@
1
1
  ## Release History
2
2
 
3
- * **v0.1.0** - 2017-03-08
4
- - Init Gem
3
+ * **v0.2.1** - 2017-03-08
4
+ - Porting `Public API`
5
+ - PUBLIC / Currency
6
+ - PUBLIC / OrderBook
7
+ - PUBLIC / Recent Complete Orders
8
+ - PUBLIC / Ticker
9
+
10
+ * **v0.1.0** - 2017-03-07
11
+ - Init Gem
12
+ - Porting `AccountV2 / Account Infomation`
data/Gemfile CHANGED
@@ -3,4 +3,7 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in coinone.gemspec
4
4
 
5
5
  gem 'pry'
6
+ gem "minitest"
7
+ gem 'dotenv'
8
+
6
9
  gemspec
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2017 ggomagundan
3
+ Copyright (c) 2017 Kai Park
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Coinone
2
- [![GemVersion](https://badge.fury.io/rb/coinone.svg)](https://badge.fury.io/rb/coinone)
2
+ [![GemVersion](https://badge.fury.io/rb/coinone.svg)](https://badge.fury.io/rb/coinone) ![](http://ruby-gem-downloads-badge.herokuapp.com/coinone?type=total) [![Code Climate](https://lima.codeclimate.com/github/ggomagundan/coinone/badges/gpa.svg)](https://lima.codeclimate.com/github/ggomagundan/coinone)
3
+ [![Build Status](https://travis-ci.org/ggomagundan/coinone.svg?branch=master)](https://travis-ci.org/ggomagundan/coinone) [![GitHub issues](https://img.shields.io/github/issues/ggomagundan/coinone.svg)](https://github.com/ggomagundan/coinone/issues) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/ggomagundan/coinone/master/LICENSE.txt)
3
4
 
4
5
  `Coinone` Gem is Ruby Language porting from Coinone API, and only support V2.
5
6
 
@@ -28,14 +29,71 @@ First, You set `ACCESS_TOKEN` and `SECRET_KEY` using [figaro](https://github.com
28
29
  ```ruby
29
30
  user = Coinone::Account.new(access_token: ENV['COINONE_ACCESS_TOKEN'], secret_key: ENV['COINONE_SECRET_KEY'])
30
31
 
31
- user.get_user_info
32
+ user_info = user.get_user_info
33
+
34
+ ```
35
+ AttributeName | Class | Description
36
+ ----------- | ------------- | -------------
37
+ result | String | Request's result
38
+ security_level | Integer | User's security level. Summation of authentications.
39
+ virtual_account_info ||Virtual account's information.
40
+ - depositor|String|Virtual account's depositor.
41
+ - account_number|String |Virtual account's number.
42
+ - bank_name|String |Virtual account's bank name.
43
+ mobile_info ||Mobile authentication's information.
44
+ - user_name|String |Mobile phone's user name.
45
+ - phone_number|String | Phone number.
46
+ - phone_corp|String| Mobile phone's corporation code.
47
+ - is_authenticated|Boolean | 'true' If a user is authenticated.
48
+ bank_info||User's bank information.
49
+ - depositor|String |Account's depositor.
50
+ - bank_code |String |Account's bankCode. ([Link](https://en.wikipedia.org/wiki/List_of_banks_in_South_Korea))
51
+ - account_number|String |Account's number.
52
+ - is_authenticated|Boolean |'true' if a user is authenticated.
53
+ email_info||User's email information.
54
+ - is_authenticated |Boolean | 'true' if a user is authenticated.
55
+ - email |String |User's email address.
56
+ fee_rates ||User's fee.
57
+ - btc | |User's fee.
58
+ - - maker |Float |Percent of BTC maker fee.
59
+ - - taker |Float |Percent of BTC taker fee.
60
+ - eth | |User's fee.
61
+ - - maker | Float |Percent of ETH maker fee.
62
+ - - taker|Float |Percent of ETH taker fee.
63
+ - etc | |User's fee.
64
+ - - maker |Float |Percent of ETC maker fee.
65
+ - - taker |Float |Percent of ETC taker fee.
66
+
67
+ - ACCOUNT V2 / Balance
68
+ ```ruby
69
+ user = Coinone::Account.new(access_token: ENV['COINONE_ACCESS_TOKEN'], secret_key: ENV['COINONE_SECRET_KEY'])
70
+
71
+ balance = user.get_balance
32
72
 
33
73
  ```
34
74
 
75
+
76
+ - ACCOUNT V2 / Daily Balance
77
+ - ACCOUNT V2 / Deposit Address
78
+ - ACCOUNT V2 / Virtual Account
79
+
35
80
  #### OAUTH
36
81
 
82
+ - OAUTH / Delete Access Token
83
+ - OAUTH / Get Access Token
84
+ - OAUTH / Get Request Token
85
+ - OAUTH / Refresh Access Token
86
+
37
87
  #### ORDER V2
38
88
 
89
+ - ORDER V2 / Cancel All Order
90
+ - ORDER V2 / Cancel Order
91
+ - ORDER V2 / Limit Buy
92
+ - ORDER V2 / Limit Sell
93
+ - ORDER V2 / Market Buy
94
+ - ORDER V2 / Market Sell
95
+ - ORDER V2 / My Complete Orders
96
+
39
97
  #### PUBLIC
40
98
 
41
99
  Not Need `ACCESS_TOKEN` and `SECRET_KEY`
@@ -47,6 +105,13 @@ currency = Coinone::Public.get_currency
47
105
 
48
106
  ```
49
107
 
108
+ AttributeName | Class | Description
109
+ ----------- | ------------- | -------------
110
+ result | String | Request's result
111
+ currency|Float |Currency Rate.
112
+ currency_type |String | Currency Type. Ex) USD, KRW..
113
+
114
+
50
115
  - PUBLIC / Orderbook
51
116
  ```ruby
52
117
  orderbook = Coinone::Public.get_orderbook # Default "BTC"
@@ -58,6 +123,17 @@ eth_orderbook = Coinone::Public.get_orderbook(currency: "eth") # ETH Orderbook
58
123
  etc_orderbook = Coinone::Public.get_orderbook(currency: "etc") # ETC Orderbook
59
124
 
60
125
  ```
126
+ AttributeName | Class | Description
127
+ ----------- | ------------- | -------------
128
+ result | String | Request's result
129
+ ask |Array|Ask List.
130
+ - price|Integer|Ask KRW price.
131
+ - qty|Float|Ask BTC(or ETH, ETC) quantity.
132
+ bid|Array|Bid List.
133
+ - price |Integer|Bid KRW price.
134
+ - qty|Float|Bid BTC(or ETH, ETC) quantity.
135
+ timestamp|Integer|Timestamp.
136
+ currency|String |Currency.
61
137
 
62
138
 
63
139
  - PUBLIC / Recent Complete Orders
@@ -77,6 +153,17 @@ etc_hour_complete_orders = Coinone::Public.get_complete_orders(currency: "etc",
77
153
  etc_day_complete_orders = Coinone::Public.get_complete_orders(currency: "etc", period: "day") # ETC and Hour Complete Orders
78
154
 
79
155
  ```
156
+ AttributeName | Class | Description
157
+ ----------- | ------------- | -------------
158
+ result | String | Request's result
159
+ completeOrders |Array|Recent complete orders.
160
+ - price|Integer|Ask KRW price.
161
+ - qty|Float|BTC(or ETH, ETC) quantity.
162
+ - timestamp|Integer|Timestamp.
163
+ timestamp|Integer|Timestamp.
164
+ currency|String |Currency.
165
+
166
+
80
167
 
81
168
  - PUBLIC / Ticker
82
169
  ```ruby
@@ -94,12 +181,18 @@ all_ticker = Coinone::Public.get_ticker(currency: "all") # ALL Ticker
94
181
 
95
182
  #### TRANSACTION V2
96
183
 
184
+ - TRANSACTION V2 / 2-Factor Authentication
185
+ - TRANSACTION V2 / Coin Transactions History
186
+ - TRANSACTION V2 / KRW Transactions History
187
+ - TRANSACTION V2 / Send Coin
188
+
189
+
97
190
  ## ToDo
98
191
  - [x] ACCOUNT V2 / Account Infomation
99
- - [ ] ACCOUNT V2 / Balance
192
+ - [x] ACCOUNT V2 / Balance
100
193
  - [ ] ACCOUNT V2 / Daily Balance
101
194
  - [ ] ACCOUNT V2 / Deposit Address
102
- - [ ] ACCOUNT V2 / Virtual Account
195
+ - [ ] ACCOUNT V2 / Virtual Account
103
196
 
104
197
  - [ ] OAUTH / Delete Access Token
105
198
  - [ ] OAUTH / Get Access Token
@@ -131,7 +224,7 @@ The Documentation is at [Coinone Docs](http://doc.coinone.co.kr/)
131
224
 
132
225
  ## Change Log
133
226
 
134
- Current Version 0.1.0
227
+ Current Version 0.2.1
135
228
 
136
229
  This link listing [Change Log](https://github.com/ggomagundan/coinone/blob/master/CHANGE_LOG.md)
137
230
 
@@ -151,5 +244,12 @@ This link listing [Change Log](https://github.com/ggomagundan/coinone/blob/maste
151
244
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
152
245
 
153
246
 
247
+ ## Donate
248
+
249
+ Welcome to Donation :)
250
+
251
+ - Ƀ BTC : 16MdVNJgvGYbVuaC6KrjGNy2RCrNsaPaZz
252
+ - Ξ ETH : 0xba920569e0a24459dbf5b2fcab9adf3e4a41b918
253
+ - ETC : 0xc45b10108920b5f20e574bbf021e73d93af5dbc8
154
254
 
155
255
 
data/Rakefile CHANGED
@@ -1,2 +1,11 @@
1
- require "bundler/gem_tasks"
2
- task :default => :spec
1
+ #require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << 'test'
6
+ end
7
+
8
+ desc "Run tests"
9
+ task :default => :test
10
+
11
+
@@ -35,6 +35,7 @@ Gem::Specification.new do |spec|
35
35
 
36
36
  spec.add_development_dependency "bundler", "~> 1.14"
37
37
  spec.add_development_dependency "rake", "~> 10.0"
38
+ spec.add_development_dependency "dotenv", "~> 2.2"
38
39
 
39
40
  spec.add_runtime_dependency "json", "~> 2.0.0", ">= 2.0.0"
40
41
  spec.add_dependency 'rest-client', '~> 2.0', '>= 2.0.1'
@@ -1,50 +1,36 @@
1
- require "coinone/account/bank_info"
2
- require "coinone/account/email_info"
3
- require "coinone/account/fee_rate"
4
- require "coinone/account/virtual_account_info"
5
- require "coinone/account/mobile_info"
1
+ require "coinone/account/account_info"
2
+ require "coinone/account/balance"
6
3
 
7
4
  module Coinone
8
5
 
9
6
  class Account
10
7
 
11
- attr_reader :security_level
12
8
  attr_reader :connection
13
- attr_reader :bank_info, :email_info, :fee_rate, :virtual_account_info, :mobile_info
9
+ attr_reader :account_info, :balance
14
10
 
15
11
  def initialize(options={}, connection=nil)
12
+
16
13
  @connection = connection || Connection.factory(options)
17
- @security_level = nil
18
- @bank_info = BankInfo.new()
19
- @email_info = EmailInfo.new()
20
- @fee_rate = FeeRate.new()
21
- @virtual_account_info = VirtualAccountInfo.new()
22
- @mobile_info = MobileInfo.new()
14
+ @account_info = AccountInfo.new()
15
+ @balance = Balance.new()
16
+
23
17
  end
24
18
 
25
19
 
26
20
  def get_user_info
27
21
  response = @connection.post( "/v2/account/user_info/")
28
22
 
29
- set_user_info(response)
30
- end
23
+ @account_info.update_user_info(response)
24
+ @account_info
31
25
 
32
- def set_user_info(params={})
26
+ end
33
27
 
34
- user_info = json[:userInfo]
35
- @security_level = user_info[:securityLevel].to_i
36
- bank_info = user_info[:bankInfo]
37
- email_info = user_info[:emailInfo]
38
- fee_rate = user_info[:feeRate]
39
- virtual_account_info = user_info[:virtualAccountInfo]
40
- mobile_info = user_info[:mobileInfo]
28
+ def get_balance
41
29
 
42
- @bank_info.update_info(bank_info)
43
- @email_info.update_info(email_info)
44
- @fee_rate.update_info(fee_rate)
45
- @virtual_account_info.update_info(virtual_account_info)
46
- @mobile_info.update_info(mobile_info)
30
+ response = @connection.post("/v2/account/balance/")
47
31
 
32
+ @balance.update_balance(response)
33
+ @balance
48
34
 
49
35
  end
50
36
 
@@ -0,0 +1,54 @@
1
+ require "coinone/account/account_info/bank_info"
2
+ require "coinone/account/account_info/email_info"
3
+ require "coinone/account/account_info/fee_rates"
4
+ require "coinone/account/account_info/virtual_account_info"
5
+ require "coinone/account/account_info/mobile_info"
6
+
7
+
8
+ module Coinone
9
+
10
+ class Account
11
+
12
+ class AccountInfo
13
+
14
+ attr_reader :result
15
+ attr_reader :security_level
16
+ attr_reader :bank_info, :email_info, :fee_rate, :virtual_account_info, :mobile_info
17
+
18
+ def initialize(options={})
19
+ @result = options[:result] || nil
20
+ @security_level = nil
21
+ @bank_info = BankInfo.new()
22
+ @email_info = EmailInfo.new()
23
+ @fee_rate = FeeRates.new()
24
+ @virtual_account_info = VirtualAccountInfo.new()
25
+ @mobile_info = MobileInfo.new()
26
+ update_user_info(options) if options.has_key? :userInfo
27
+ end
28
+
29
+ def update_user_info(params={})
30
+
31
+ user_info = params[:userInfo]
32
+ @security_level = user_info[:securityLevel].to_i
33
+ bank_info = user_info[:bankInfo]
34
+ email_info = user_info[:emailInfo]
35
+ fee_rate = user_info[:feeRate]
36
+ virtual_account_info = user_info[:virtualAccountInfo]
37
+ mobile_info = user_info[:mobileInfo]
38
+
39
+
40
+ @result = params[:result] if params.has_key? :result
41
+ @bank_info.update_info(bank_info)
42
+ @email_info.update_info(email_info)
43
+ @fee_rate.update_info(fee_rate)
44
+ @virtual_account_info.update_info(virtual_account_info)
45
+ @mobile_info.update_info(mobile_info)
46
+
47
+
48
+ end
49
+
50
+
51
+
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,30 @@
1
+ module Coinone
2
+ class Account
3
+ class AccountInfo
4
+ class BankInfo
5
+ attr_reader :depositor, :bank_code, :is_authenticated, :account_number
6
+
7
+ def initialize(params={})
8
+
9
+ @depositor = nil
10
+ @bank_code = nil
11
+ @is_authenticated = nil
12
+ @account_number = nil
13
+
14
+ update_info(params)
15
+ end
16
+
17
+ def update_info(params={})
18
+
19
+ @depositor = params[:depositor].strip if params.has_key? :depositor
20
+ @bank_code = params[:bankCode].strip if params.has_key? :bankCode
21
+ @is_authenticated = params[:isAuthenticated] == "true"
22
+ @account_number = params[:accountNumber].strip if params.has_key? :accountNumber
23
+
24
+ end
25
+ end
26
+
27
+ end
28
+ end
29
+ end
30
+
@@ -0,0 +1,25 @@
1
+ module Coinone
2
+
3
+ class Account
4
+ class AccountInfo
5
+ class EmailInfo
6
+ attr_reader :email, :is_authenticated
7
+
8
+ def initialize(params={})
9
+ @email = nil
10
+ @is_authenticated = nil
11
+
12
+ update_info(params)
13
+ end
14
+
15
+ def update_info(params={})
16
+ @email = params[:email].strip if params.has_key? :email
17
+ @is_authenticated = params[:isAuthenticated] == "true"
18
+ end
19
+ end
20
+
21
+ end
22
+ end
23
+ end
24
+
25
+
@@ -0,0 +1,27 @@
1
+ require "coinone/account/account_info/fee_rates/fee_rate"
2
+ module Coinone
3
+
4
+ class Account
5
+ class AccountInfo
6
+ class FeeRates
7
+ attr_reader :btc, :eth, :etc
8
+
9
+ def initialize(params={})
10
+ @btc = FeeRate.new()
11
+ @eth = FeeRate.new()
12
+ @etc = FeeRate.new()
13
+ update_info(params)
14
+ end
15
+
16
+ def update_info(params={})
17
+ @btc.update_info(params[:btc]) if params.has_key? :btc
18
+ @eth.update_info(params[:eth]) if params.has_key? :eth
19
+ @etc.update_info(params[:etc]) if params.has_key? :etc
20
+ end
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+
27
+
@@ -0,0 +1,26 @@
1
+ module Coinone
2
+ class Account
3
+ class AccountInfo
4
+ class FeeRates
5
+ class FeeRate
6
+ attr_reader :taker, :maker
7
+
8
+ def initialize(params={})
9
+ @taker = nil
10
+ @maker = nil
11
+ update_info(params)
12
+ end
13
+
14
+ def update_info(params={})
15
+ @taker = params[:taker].to_f if params.has_key? :taker
16
+ @maker = params[:maker].to_f if params.has_key? :maker
17
+ end
18
+
19
+ end
20
+ end
21
+
22
+ end
23
+ end
24
+ end
25
+
26
+
@@ -0,0 +1,30 @@
1
+ module Coinone
2
+
3
+ class Account
4
+ class AccountInfo
5
+ class MobileInfo
6
+ attr_reader :user_name, :phone_number, :phone_corp, :is_authenticated
7
+
8
+ def initialize(params={})
9
+ @user_name = nil
10
+ @phone_number = nil
11
+ @phone_corp = nil
12
+ @is_authenticated = nil
13
+ update_info(params)
14
+ end
15
+
16
+ def update_info(params={})
17
+
18
+ @user_name = params[:userName].strip if params.has_key? :userName
19
+ @phone_number = params[:phoneNumber].strip if params.has_key? :phoneNumber
20
+ @phone_corp = params[:phoneCorp].strip if params.has_key? :phoneCorp
21
+ @is_authenticated = params[:isAuthenticated] == "true"
22
+
23
+ end
24
+ end
25
+
26
+ end
27
+ end
28
+ end
29
+
30
+
@@ -0,0 +1,25 @@
1
+ module Coinone
2
+
3
+ class Account
4
+ class AccountInfo
5
+ class VirtualAccountInfo
6
+ attr_reader :depositor, :account_number, :bank_name
7
+
8
+ def initialize(params={})
9
+ @depositor = nil
10
+ @account_number = nil
11
+ @bank_name = nil
12
+ update_info(params)
13
+ end
14
+
15
+ def update_info(params={})
16
+ @depositor = params[:depositor].strip if params.has_key? :depositor
17
+ @account_number = params[:accountNumber].strip if params.has_key? :accountNumber
18
+ @bank_name = params[:bankName].strip if params.has_key? :bankName
19
+ end
20
+ end
21
+
22
+ end
23
+ end
24
+ end
25
+
@@ -0,0 +1,48 @@
1
+ require 'coinone/account/balance/wallet'
2
+ require 'coinone/account/balance/normal_wallet'
3
+
4
+ module Coinone
5
+
6
+ class Account
7
+
8
+ class Balance
9
+
10
+ attr_reader :result
11
+ attr_reader :normal_wallets, :btc, :eth, :etc
12
+
13
+ def initialize(options={})
14
+
15
+ @result = options[:result] || nil
16
+ @normal_wallets = []
17
+ @btc = Wallet.new()
18
+ @eth = Wallet.new()
19
+ @etc = Wallet.new()
20
+
21
+ keys = [:normalWallets, :btc, :eth, :eth]
22
+ update_balance(options) if keys.any? { |key| options.has_key? key}
23
+
24
+
25
+ end
26
+
27
+ def update_balance(params={})
28
+
29
+
30
+ @result = params[:result] if params.has_key? :result
31
+ if params.has_key? :normalWallets
32
+ @normal_wallets.clear
33
+ params[:normalWallets].each do |wallet|
34
+ @normal_wallets.push(NormalWallet.new(wallet))
35
+ end
36
+ end
37
+
38
+ @btc.update_wallet(params[:btc]) if params.has_key? :btc
39
+ @eth.update_wallet(params[:eth]) if params.has_key? :eth
40
+ @etc.update_wallet(params[:etc]) if params.has_key? :etc
41
+
42
+ end
43
+
44
+
45
+
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,32 @@
1
+ module Coinone
2
+
3
+ class Account
4
+ class Balance
5
+ class NormalWallet
6
+ attr_reader :balance, :label
7
+
8
+ def initialize(params={})
9
+ @balance = nil
10
+ @label = nil
11
+ update_wallet(params)
12
+ end
13
+
14
+ def update_wallet(params={})
15
+ @balance = params[:balance].to_d if params.has_key? :balance
16
+ @balance = params[:label] if params.has_key? :label
17
+
18
+ # If wanna Full Decimal
19
+ # => OBJ.to_digits
20
+ end
21
+
22
+ def balance
23
+ @balance.to_digits
24
+ end
25
+
26
+ end
27
+
28
+ end
29
+ end
30
+ end
31
+
32
+
@@ -0,0 +1,35 @@
1
+ module Coinone
2
+
3
+ class Account
4
+ class Balance
5
+ class Wallet
6
+ attr_reader :avail, :balance
7
+
8
+ def initialize(params={})
9
+ @avail = nil
10
+ @balance = nil
11
+ update_wallet(params)
12
+ end
13
+
14
+ def update_wallet(params={})
15
+ @avail = params[:avail].to_d if params.has_key? :avail
16
+ @balance = params[:balance].to_d if params.has_key? :balance
17
+ # If wanna Full Decimal
18
+ # => OBJ.to_digits
19
+ end
20
+
21
+ def avail
22
+ @avail.to_digits
23
+ end
24
+
25
+ def balance
26
+ @balance.to_digits
27
+ end
28
+
29
+ end
30
+
31
+ end
32
+ end
33
+ end
34
+
35
+
@@ -1,8 +1,7 @@
1
1
  require 'rest-client'
2
2
  require 'openssl'
3
3
  require 'addressable/uri'
4
-
5
- require 'coinone/error'
4
+ require 'base64'
6
5
 
7
6
  module Coinone
8
7
 
@@ -15,8 +14,8 @@ module Coinone
15
14
  AUTH_URI = "https://api.coinone.co.kr/oauth/access_token/"
16
15
  REFRESH_AUTH_URI = "https://api.coinone.co.kr/oauth/refresh_token/"
17
16
  DELETE_AUTH_URI = "https://api.coinone.co.kr/oauth/delete_token/"
18
- ACCESS_TOKEN = "ACESS_TOKEN"
19
- SECRET_KEY= "SECRET_KEY"
17
+ #ACCESS_TOKEN = "ACESS_TOKEN"
18
+ #SECRET_KEY= "SECRET_KEY"
20
19
 
21
20
  def self.factory(params) # :nodoc
22
21
  Connection.new(
@@ -59,12 +58,17 @@ module Coinone
59
58
 
60
59
  response = resource[ connection_uri ].post params, {'Content-Type': 'application/json', 'X-COINONE-PAYLOAD': payload, 'X-COINONE-SIGNATURE': signature }
61
60
 
61
+ #puts "Response : #{response}\n\n"
62
+ #puts "Response Body : #{response.body}\n\n"
63
+
62
64
  check_for_errors(response.body)
65
+
63
66
  JSON.parse(response.body, symbolize_names: true)
67
+
64
68
  end
65
69
 
66
70
  def create_coinone_signature( payload )
67
- OpenSSL::HMAC.hexdigest( 'sha512', SECRET_KEY.upcase, payload)
71
+ OpenSSL::HMAC.hexdigest( 'sha512', @secret_key.upcase, payload)
68
72
  end
69
73
 
70
74
  def create_coinone_payload( data )
@@ -73,8 +77,8 @@ module Coinone
73
77
 
74
78
  def check_for_errors(response)
75
79
  # {"errorCode"=>"130", "errorMessage"=>"V2 API Nonce value must be a positive integer", "result"=>"error"}
76
- response = JSON.parse(response)
77
- case response["errorCode"].to_i
80
+ response = JSON.parse(response)
81
+ case response["errorCode"].to_i
78
82
  when 11 then raise AccessTokenMissingError, response["errorMessage"]
79
83
  when 12 then raise InvalidAccessTokenError, response["errorMessage"]
80
84
  when 40 then raise InvalidAPIPermissionError, response["errorMessage"]
@@ -13,9 +13,8 @@ module Coinone
13
13
  @connection = connection || Connection.factory(options)
14
14
  response = @connection.get("/currency")
15
15
 
16
- puts response
17
-
18
16
  @currency = Currency.new(response)
17
+ @currency
19
18
 
20
19
  end
21
20
 
@@ -23,9 +22,8 @@ module Coinone
23
22
  @connection = connection || Connection.factory(options)
24
23
  response = @connection.get("/orderbook", options)
25
24
 
26
- puts response
27
-
28
25
  @orderbook = Orderbook.new(response)
26
+ @orderbook
29
27
 
30
28
  end
31
29
 
@@ -33,9 +31,8 @@ module Coinone
33
31
  @connection = connection || Connection.factory(options)
34
32
  response = @connection.get("/trades", options)
35
33
 
36
- puts response
37
-
38
34
  @complete_orders = CompleteOrders.new(response)
35
+ @complete_orders
39
36
  end
40
37
 
41
38
 
@@ -43,9 +40,9 @@ module Coinone
43
40
  @connection = connection || Connection.factory(options)
44
41
  response = @connection.get("/ticker", options)
45
42
 
46
- puts response
47
43
 
48
44
  @ticker = Tickers.new(response)
45
+ @ticker
49
46
 
50
47
 
51
48
  end
@@ -3,9 +3,11 @@ module Coinone
3
3
 
4
4
  module Public
5
5
  class CompleteOrders
6
+ attr_reader :result
6
7
  attr_reader :orders, :timestamp, :currency
7
8
 
8
9
  def initialize(params={})
10
+ @result = params[:result] || nil
9
11
  @orders = []
10
12
  @timestamp = params[:timestamp] || nil
11
13
  @currency= params[:currency] || nil
@@ -13,6 +15,7 @@ module Coinone
13
15
  end
14
16
 
15
17
  def push_orders(params)
18
+ @orders.clear
16
19
  params.each do |order|
17
20
  @orders.push(CompleteOrder.new(order))
18
21
  end
@@ -2,9 +2,11 @@ module Coinone
2
2
 
3
3
  module Public
4
4
  class Currency
5
+ attr_reader :result
5
6
  attr_reader :currency, :source, :currency_type
6
7
 
7
8
  def initialize(params={})
9
+ @result = params[:result] || nil
8
10
  @currency = params[:currency].to_f || nil
9
11
  @source = params[:source] || nil
10
12
  @currency_type = params[:currencyType] || nil
@@ -1,17 +1,30 @@
1
- require 'coinone/public/orderbook/orders'
1
+ require 'coinone/public/orderbook/order'
2
2
  module Coinone
3
3
 
4
4
  module Public
5
5
  class Orderbook
6
+ attr_reader :result
6
7
  attr_reader :ask, :bid, :timestamp, :currency
7
8
 
8
9
  def initialize(params={})
9
- @ask = Orders.new(params[:ask]) || []
10
- @bid = Orders.new(params[:bid]) || []
10
+ @result = params[:result] || nil
11
+ @ask = []
12
+ @bid = []
11
13
  @timestamp = params[:timestamp].to_i || nil
12
14
  @currency= params[:currency] || nil
15
+ push_orders(params[:ask], @ask) if params.has_key? :ask
16
+ push_orders(params[:bid], @bid) if params.has_key? :bid
13
17
  end
14
18
 
19
+ def push_orders(params, orders)
20
+ orders.clear
21
+ params.each do |order|
22
+ orders.push(Order.new(order))
23
+ end
24
+ end
25
+
26
+
27
+
15
28
  end
16
29
  end
17
30
 
@@ -3,14 +3,18 @@ module Coinone
3
3
 
4
4
  module Public
5
5
  class Tickers
6
- attr_reader :tickers
6
+ attr_reader :result
7
+ attr_reader :timestamp, :tickers
7
8
 
8
9
  def initialize(params={})
10
+ @result = params[:result] || nil
11
+ @result = params[:timestamp] || nil
9
12
  @tickers = []
10
13
  push_tickers(params)
11
14
  end
12
15
 
13
16
  def push_tickers(params)
17
+ @tickers.clear
14
18
  currency_list = [:btc, :eth, :etc]
15
19
  currency_list.each do |currency|
16
20
  if params.has_key? currency
@@ -1,3 +1,3 @@
1
1
  module Coinone
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
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.2.1
4
+ version: 0.3.0
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-08 00:00:00.000000000 Z
11
+ date: 2017-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: dotenv
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.2'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.2'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: json
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -113,14 +127,16 @@ files:
113
127
  - coinone.gemspec
114
128
  - lib/coinone.rb
115
129
  - lib/coinone/account.rb
116
- - lib/coinone/account/bank_info.rb
117
- - lib/coinone/account/email_info.rb
118
- - lib/coinone/account/fee_rate.rb
119
- - lib/coinone/account/fee_rate/btc.rb
120
- - lib/coinone/account/fee_rate/etc.rb
121
- - lib/coinone/account/fee_rate/eth.rb
122
- - lib/coinone/account/mobile_info.rb
123
- - lib/coinone/account/virtual_account_info.rb
130
+ - lib/coinone/account/account_info.rb
131
+ - lib/coinone/account/account_info/bank_info.rb
132
+ - lib/coinone/account/account_info/email_info.rb
133
+ - lib/coinone/account/account_info/fee_rates.rb
134
+ - lib/coinone/account/account_info/fee_rates/fee_rate.rb
135
+ - lib/coinone/account/account_info/mobile_info.rb
136
+ - lib/coinone/account/account_info/virtual_account_info.rb
137
+ - lib/coinone/account/balance.rb
138
+ - lib/coinone/account/balance/normal_wallet.rb
139
+ - lib/coinone/account/balance/wallet.rb
124
140
  - lib/coinone/connection.rb
125
141
  - lib/coinone/error.rb
126
142
  - lib/coinone/public.rb
@@ -129,7 +145,6 @@ files:
129
145
  - lib/coinone/public/currency.rb
130
146
  - lib/coinone/public/orderbook.rb
131
147
  - lib/coinone/public/orderbook/order.rb
132
- - lib/coinone/public/orderbook/orders.rb
133
148
  - lib/coinone/public/tickers.rb
134
149
  - lib/coinone/public/tickers/ticker.rb
135
150
  - lib/coinone/version.rb
@@ -1,30 +0,0 @@
1
- module Coinone
2
-
3
- class Account
4
- class BankInfo
5
- attr_reader :depositor, :bank_code, :is_authenticated, :account_number
6
-
7
- def initialize(params={})
8
-
9
- @depositor = nil
10
- @bank_code = nil
11
- @is_authenticated = nil
12
- @account_number = nil
13
-
14
- update_info(params)
15
- end
16
-
17
- def update_info(params={})
18
-
19
- @depositor = params[:depositor].strip if params.has_key? :depositor
20
- @bank_code = params[:bankCode].strip if params.has_key? :bankCode
21
- @is_authenticated = params[:isAuthenticated] == "true"
22
- @account_number = params[:accountNumber].strip if params.has_key? :accountNumber
23
-
24
- end
25
- end
26
-
27
- end
28
- end
29
-
30
-
@@ -1,23 +0,0 @@
1
- module Coinone
2
-
3
- class Account
4
- class EmailInfo
5
- attr_reader :email, :is_authenticated
6
-
7
- def initialize(params={})
8
- @email = nil
9
- @is_authenticated = nil
10
-
11
- update_info(params)
12
- end
13
-
14
- def update_info(params={})
15
- @email = params[:email].strip if params.has_key? :email
16
- @is_authenticated = params[:isAuthenticated] == "true"
17
- end
18
- end
19
-
20
- end
21
- end
22
-
23
-
@@ -1,27 +0,0 @@
1
- require "coinone/account/fee_rate/btc"
2
- require "coinone/account/fee_rate/eth"
3
- require "coinone/account/fee_rate/etc"
4
- module Coinone
5
-
6
- class Account
7
- class FeeRate
8
- attr_reader :btc, :eth, :etc
9
-
10
- def initialize(params={})
11
- @btc = Btc.new()
12
- @eth = Eth.new()
13
- @etc = Etc.new()
14
- update_info(params)
15
- end
16
-
17
- def update_info(params={})
18
- @btc.update_info(params[:btc]) if params.has_key? :btc
19
- @eth.update_info(params[:eth]) if params.has_key? :eth
20
- @etc.update_info(params[:etc]) if params.has_key? :etc
21
- end
22
- end
23
-
24
- end
25
- end
26
-
27
-
@@ -1,25 +0,0 @@
1
- module Coinone
2
-
3
- class Account
4
- class FeeRate
5
- class Btc
6
- attr_reader :taker, :maker
7
-
8
- def initialize(params={})
9
- @taker = nil
10
- @maker = nil
11
- update_info(params)
12
- end
13
-
14
- def update_info(params={})
15
- @taker = params[:taker].to_f if params.has_key? :taker
16
- @maker = params[:maker].to_f if params.has_key? :maker
17
- end
18
-
19
- end
20
- end
21
-
22
- end
23
- end
24
-
25
-
@@ -1,25 +0,0 @@
1
- module Coinone
2
-
3
- class Account
4
- class FeeRate
5
- class Etc
6
- attr_reader :taker, :maker
7
-
8
- def initialize(params={})
9
- @taker = nil
10
- @maker = nil
11
- update_info(params)
12
- end
13
-
14
- def update_info(params={})
15
- @taker = params[:taker].to_f if params.has_key? :taker
16
- @maker = params[:maker].to_f if params.has_key? :maker
17
- end
18
-
19
- end
20
- end
21
-
22
- end
23
- end
24
-
25
-
@@ -1,25 +0,0 @@
1
- module Coinone
2
-
3
- class Account
4
- class FeeRate
5
- class Eth
6
- attr_reader :taker, :maker
7
-
8
- def initialize(params={})
9
- @taker = nil
10
- @maker = nil
11
- update_info(params)
12
- end
13
-
14
- def update_info(params={})
15
- @taker = params[:taker].to_f if params.has_key? :taker
16
- @maker = params[:maker].to_f if params.has_key? :maker
17
- end
18
-
19
- end
20
- end
21
-
22
- end
23
- end
24
-
25
-
@@ -1,28 +0,0 @@
1
- module Coinone
2
-
3
- class Account
4
- class MobileInfo
5
- attr_reader :user_name, :phone_number, :phone_corp, :is_authenticated
6
-
7
- def initialize(params={})
8
- @user_name = nil
9
- @phone_number = nil
10
- @phone_corp = nil
11
- @is_authenticated = nil
12
- update_info(params)
13
- end
14
-
15
- def update_info(params={})
16
-
17
- @user_name = params[:userName].strip if params.has_key? :userName
18
- @phone_number = params[:phoneNumber].strip if params.has_key? :phoneNumber
19
- @phone_corp = params[:phoneCorp].strip if params.has_key? :phoneCorp
20
- @is_authenticated = params[:isAuthenticated] == "true"
21
-
22
- end
23
- end
24
-
25
- end
26
- end
27
-
28
-
@@ -1,27 +0,0 @@
1
- module Coinone
2
-
3
- class Account
4
- class VirtualAccountInfo
5
- attr_reader :depositor, :account_number, :bank_name
6
-
7
- def initialize(params={})
8
- @depositor = nil
9
- @account_number = nil
10
- @bank_name = nil
11
- update_info(params)
12
- end
13
-
14
- def update_info(params={})
15
- @depositor = params[:depositor].strip if params.has_key? :depositor
16
- @account_number = params[:accountNumber].strip if params.has_key? :accountNumber
17
- @bank_name = params[:bankName].strip if params.has_key? :bankName
18
- end
19
- end
20
-
21
- end
22
- end
23
-
24
-
25
-
26
-
27
-
@@ -1,25 +0,0 @@
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