coinone 0.5.0 → 0.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a3294629f31009d0067b41d9b57a5377dba3d923
4
- data.tar.gz: dd8de5708feeefa4a7d20e0e586190d128464335
3
+ metadata.gz: d5da7b71949a3c0fafec8740af9189ace5ae278b
4
+ data.tar.gz: 2fd80cc63ff3f2c2a78bedb3c591a12c2c0379a0
5
5
  SHA512:
6
- metadata.gz: 7b8d5d164202d26a3aa9e8910ca069429866f9834c779109e9e13eed763d0bda5de8b4fcfe8166f0201e1be21eee5827b22bb3601d2802406d07e7d5a3b72b70
7
- data.tar.gz: 7c61e7efb3d99baa7ab292cd9ae4d960b38ae778bf2fb094f4903229d77313c15f7a91ae1bf63e38f2daa3f00af4033b4a7278f7dfbe3afecabbd2c2118238c9
6
+ metadata.gz: a9ca0a844d907b6098282659a1d9f2dd4620f1911d57ecb132d0ad006f3313a3529876535c33e5fb0b873e75dc929f92f014f9ec35cbedfc83662a7734e842a6
7
+ data.tar.gz: 5d0632cf3511e345d74d00f99f340c6c48e950ec57175ccd9980630db236c02532133c9e2a3efde40e11aacb663028a1124283f50619a6d6907d9d6cf43e8a7d
@@ -1,6 +1,12 @@
1
1
  ## Release History
2
2
 
3
- * **v0.5.0** - 2017-03-15
3
+ * **v0.6.0** - 2017-03-30
4
+ - Porting `TransactionV2 / 2-Factor Authentication`
5
+ - Porting `TransactionV2 / Coin TransactionsHistory`
6
+ - Porting `TransactionV2 / KRW Transactions History`
7
+ - Porting `TransactionV2 / Send Coin`
8
+
9
+ * **v0.5.0** - 2017-03-29
4
10
  - Porting `OrderV2 / Cancel All Order`
5
11
  - Porting `OrderV2 / Cancel Order`
6
12
  - Porting `OrderV2 / Limit Buy`
data/README.md CHANGED
@@ -134,7 +134,7 @@ deposit_address = user.get_deposit_address
134
134
  ```ruby
135
135
  user = Coinone::Account.new(access_token: ENV['COINONE_ACCESS_TOKEN'], secret_key: ENV['COINONE_SECRET_KEY'])
136
136
 
137
- virtual_address = user.get_virtual_address
137
+ virtual_address = user.get_virtual_account
138
138
 
139
139
  ```
140
140
 
@@ -382,10 +382,98 @@ all_ticker = Coinone::Public.get_ticker(currency: "all") # ALL Ticker
382
382
  #### TRANSACTION V2
383
383
 
384
384
  - TRANSACTION V2 / 2-Factor Authentication
385
+
386
+ ```ruby
387
+ transaction = Coinone::Transaction.new(access_token: ENV['COINONE_ACCESS_TOKEN'], secret_key: ENV['COINONE_SECRET_KEY'])
388
+
389
+ krw_2factor = transaction.get_auth_number(type: "krw")
390
+
391
+ btc_2factor = transaction.get_auth_number(type: "btc")
392
+
393
+ eth_2factor = transaction.get_auth_number(type: "eth")
394
+
395
+ etc_2factor = transaction.get_auth_number(type: "etc")
396
+
397
+ ```
398
+
399
+ |AttributeName | Class | Description|
400
+ |----------- | ------------- | -------------|
401
+ |result | String | Request's result|
402
+
385
403
  - TRANSACTION V2 / Coin Transactions History
404
+
405
+ ```ruby
406
+ transaction = Coinone::Transaction.new(access_token: ENV['COINONE_ACCESS_TOKEN'], secret_key: ENV['COINONE_SECRET_KEY'])
407
+
408
+ btc_history = transaction.get_coin_history(currency: "btc")
409
+
410
+ eth_history = transaction.get_coin_history(currency: "eth")
411
+
412
+ etc_history = transaction.get_coin_history(currency: "etc")
413
+
414
+ ```
415
+
416
+ |AttributeName | Class | Description|
417
+ |----------- | ------------- | -------------|
418
+ |result | String | Request's result|
419
+ |histories|Array|Coin transactions history.|
420
+ |- txid |String|Transaction ID.|
421
+ |- type |String|Transaction type. send: "send", receive: "receive".|
422
+ |- from |String|From address.|
423
+ |- to |String|To address.|
424
+ |- confirmations |Integer|Confirmations.|
425
+ |- quantity |Float|Transaction quantity.|
426
+ |- timestamp |Integer|Timestamp.|
427
+
386
428
  - TRANSACTION V2 / KRW Transactions History
429
+
430
+ ```ruby
431
+ transaction = Coinone::Transaction.new(access_token: ENV['COINONE_ACCESS_TOKEN'], secret_key: ENV['COINONE_SECRET_KEY'])
432
+
433
+ krw_history = transaction.get_krw_history()
434
+
435
+ krw_history.histories.first.process_level_to_s # Change process_level to Level String
436
+ => "Deposit Completed"
437
+
438
+
439
+ ```
440
+
441
+ |AttributeName | Class | Description|
442
+ |----------- | ------------- | -------------|
443
+ |result | String | Request's result|
444
+ |histories|Array|KRW transactions history.|
445
+ |- bank_code |Integer|Bank code.|
446
+ |- account_number |String|Bank account number.|
447
+ |- depositor |String|Depositor's name|
448
+ |- amount |Integer|Transaction amount.|
449
+ |- process_level |Integer|KRW transaction's process level. 1: Deposit Completed, 2: Request Withdrawal, 3: Request Accepted, 4: Withrawal Canceled, 5: Withdrawal Completed.|
450
+ |- timestamp |Integer|Timestamp.|
451
+
387
452
  - TRANSACTION V2 / Send Coin
388
453
 
454
+ ```ruby
455
+ transaction = Coinone::Transaction.new(access_token: ENV['COINONE_ACCESS_TOKEN'], secret_key: ENV['COINONE_SECRET_KEY'])
456
+
457
+ btc_send_coin = transaction.send_coin(currency: "btc", address: "xxxxxxxxxxxxxxxxx", auth_number: "XXXX", qty: 1)
458
+ btc_send_coin.transaction_url # BTC Transaction Tracker URL
459
+ => "https://blockchain.info/tx/xxxxxxxxxxxxxxxxx"
460
+
461
+ eth_send_coin = transaction.send_coin(currency: "eth", address: "0x#####", auth_number: "XXXX", qty: 1)
462
+ eth_send_coin.transaction_url # ETH Transaction Tracker URL
463
+ => "https://etherscan.io/tx/0x##########"
464
+
465
+ etc_send_coin = transaction.send_coin(currency: "etc", address: "0x#####", auth_number: "XXXX", qty: 1)
466
+ etc_send_coin.transaction_url # ETC Transaction Tracker URL
467
+ => "https://gastracker.io/tx/0x#####"
468
+
469
+
470
+ ```
471
+
472
+ |AttributeName | Class | Description|
473
+ |----------- | ------------- | -------------|
474
+ |result | String | Request's result|
475
+ |txid | String | TxID|
476
+
389
477
 
390
478
  ## ToDo
391
479
  - [x] ACCOUNT V2 / Account Infomation
@@ -413,10 +501,10 @@ all_ticker = Coinone::Public.get_ticker(currency: "all") # ALL Ticker
413
501
  - [x] PUBLIC / Recent Complete Orders
414
502
  - [x] PUBLIC / Ticker
415
503
 
416
- - [ ] TRANSACTION V2 / 2-Factor Authentication
417
- - [ ] TRANSACTION V2 / Coin Transactions History
418
- - [ ] TRANSACTION V2 / KRW Transactions History
419
- - [ ] TRANSACTION V2 / Send Coin
504
+ - [x] TRANSACTION V2 / 2-Factor Authentication
505
+ - [x] TRANSACTION V2 / Coin Transactions History
506
+ - [x] TRANSACTION V2 / KRW Transactions History
507
+ - [x] TRANSACTION V2 / Send Coin
420
508
 
421
509
  ## Full documentation
422
510
 
@@ -424,7 +512,7 @@ The Documentation is at [Coinone Docs](http://doc.coinone.co.kr/)
424
512
 
425
513
  ## Change Log
426
514
 
427
- Current Version 0.5.0
515
+ Current Version 0.6.0
428
516
 
429
517
  This link listing [Change Log](https://github.com/ggomagundan/coinone/blob/master/CHANGE_LOG.md)
430
518
 
@@ -36,6 +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
  spec.add_development_dependency "dotenv", "~> 2.2"
39
+ spec.add_development_dependency "faraday", "~> 0.11.0"
39
40
 
40
41
  spec.add_runtime_dependency "json", "~> 2.0.0", ">= 2.0.0"
41
42
  spec.add_dependency 'rest-client', '~> 2.0', '>= 2.0.1'
@@ -4,6 +4,7 @@ module Coinone
4
4
  require 'coinone/connection'
5
5
  require 'coinone/account'
6
6
  require 'coinone/order'
7
+ require 'coinone/transaction'
7
8
  require 'coinone/public'
8
9
  require 'coinone/error'
9
10
  end
@@ -21,7 +21,7 @@ module Coinone
21
21
  def update_response(params={})
22
22
 
23
23
  @result = params[:result] if params.has_key? :result
24
- if params[:completeOrders].present?
24
+ if !params[:completeOrders].nil?
25
25
  @complete_orders = []
26
26
  params[:completeOrders].each do |complete_order|
27
27
  @complete_orders.push(CompleteOrder.new(complete_order))
@@ -22,7 +22,7 @@ module Coinone
22
22
  def update_response(params={})
23
23
 
24
24
  @result = params[:result] if params.has_key? :result
25
- if params[:limitOrders].present?
25
+ if !params[:limitOrders].nil?
26
26
  @limit_orders = []
27
27
  params[:limitOrders].each do |limit_order|
28
28
  @limit_orders.push(LimitOrder.new(limit_order))
@@ -0,0 +1,60 @@
1
+ require 'coinone/transaction/auth_number_response'
2
+ require 'coinone/transaction/coin_history'
3
+ require 'coinone/transaction/krw_history'
4
+ require 'coinone/transaction/send_coin_response'
5
+
6
+ module Coinone
7
+
8
+ class Transaction
9
+
10
+ attr_reader :connection
11
+ attr_reader :auth_number_response, :coin_history, :krw_history, :send_coin_response
12
+
13
+ def initialize(options={}, connection=nil)
14
+
15
+ @connection = connection || Connection.factory(options)
16
+ @auth_number_response = AuthNumberResponse.new()
17
+ @coin_history = CoinHistory.new()
18
+ @krw_history = KrwHistory.new()
19
+ @send_coin_response = SendCoinResponse.new()
20
+
21
+ end
22
+
23
+
24
+ def get_auth_number(options={})
25
+ response = @connection.post( "/v2/transaction/auth_number/", options)
26
+
27
+ @auth_number_response.update_response(response)
28
+ @auth_number_response
29
+
30
+ end
31
+
32
+ def get_coin_history(options={})
33
+
34
+ response = @connection.post("/v2/transaction/history/", options)
35
+
36
+ @coin_history.update_histories(response)
37
+ @coin_history
38
+
39
+ end
40
+
41
+ def get_krw_history(options={})
42
+
43
+ response = @connection.post("/v2/transaction/krw/history/", options)
44
+
45
+ @krw_history.update_histories(response)
46
+ @krw_history
47
+
48
+ end
49
+
50
+ def send_coin(options={})
51
+
52
+ response = @connection.post("/v2/transaction/coin/", options)
53
+ #response = {txid: "Txid"}
54
+
55
+ @send_coin_response.update_response(response.merge({ currency: options[:currency]}))
56
+ @send_coin_response
57
+
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,26 @@
1
+ module Coinone
2
+
3
+ class Transaction
4
+
5
+ class AuthNumberResponse
6
+
7
+ attr_reader :result
8
+
9
+ def initialize(options={})
10
+
11
+ @result = options[:result] || nil
12
+
13
+ update_response(options)
14
+
15
+
16
+ end
17
+
18
+ def update_response(params={})
19
+
20
+ @result = params[:result] if params.has_key? :result
21
+
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,36 @@
1
+ require 'coinone/transaction/coin_history/history'
2
+
3
+ module Coinone
4
+
5
+ class Transaction
6
+
7
+ class CoinHistory
8
+
9
+ attr_reader :result
10
+ attr_reader :histories
11
+
12
+ def initialize(options={})
13
+
14
+ @result = options[:result] || nil
15
+ @histories = []
16
+
17
+ update_histories(options)
18
+
19
+
20
+ end
21
+
22
+ def update_histories(params={})
23
+
24
+ @result = params[:result] if params.has_key? :result
25
+ if !params[:transactions].nil?
26
+ @histories = []
27
+ params[:transactions].each do |transaction|
28
+ @histories.push(History.new(transaction))
29
+ end
30
+ end
31
+
32
+ end
33
+
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,42 @@
1
+
2
+ module Coinone
3
+
4
+ class Transaction
5
+
6
+ class CoinHistory
7
+
8
+ class History
9
+
10
+ attr_reader :txid, :type, :from, :to, :confirmations, :quantity, :timestamp
11
+
12
+ def initialize(options={})
13
+
14
+ @txid = nil
15
+ @type = nil
16
+ @from = nil
17
+ @to = nil
18
+ @confirmations = nil
19
+ @quantity = nil
20
+ @timestamp = nil
21
+
22
+ update_history(options)
23
+
24
+ end
25
+
26
+ def update_history(params={})
27
+
28
+
29
+ @txid = params[:txid] if params.has_key? :txid
30
+ @type = params[:type] if params.has_key? :type
31
+ @from = params[:from] if params.has_key? :from
32
+ @to = params[:to] if params.has_key? :to
33
+ @confirmations = params[:confirmations].to_i if params.has_key? :confirmations
34
+ @quantity = params[:quantity].to_f if params.has_key? :quantity
35
+ @timestamp = params[:timestamp].to_i if params.has_key? :timestamp
36
+
37
+ end
38
+ end
39
+
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,36 @@
1
+ require 'coinone/transaction/krw_history/history'
2
+
3
+ module Coinone
4
+
5
+ class Transaction
6
+
7
+ class KrwHistory
8
+
9
+ attr_reader :result
10
+ attr_reader :histories
11
+
12
+ def initialize(options={})
13
+
14
+ @result = options[:result] || nil
15
+ @histories = []
16
+
17
+ update_histories(options)
18
+
19
+
20
+ end
21
+
22
+ def update_histories(params={})
23
+
24
+ @result = params[:result] if params.has_key? :result
25
+ if !params[:krwHistory].nil?
26
+ @histories = []
27
+ params[:krwHistory].each do |history|
28
+ @histories.push(History.new(history))
29
+ end
30
+ end
31
+
32
+ end
33
+
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,48 @@
1
+ module Coinone
2
+
3
+ class Transaction
4
+
5
+ class KrwHistory
6
+ class History
7
+
8
+ attr_reader :bank_code, :account_number, :depositor, :amount, :process_level, :timestamp
9
+
10
+ def initialize(options={})
11
+
12
+ @bank_code = nil
13
+ @account_number = nil
14
+ @depositor = nil
15
+ @amount = nil
16
+ @process_level = nil
17
+ @timestamp = nil
18
+
19
+ update_history(options)
20
+
21
+
22
+ end
23
+
24
+ def update_history(params={})
25
+
26
+ @bank_code = params[:bankCode].to_i if (params.has_key? :bankCode) && !params[:bankCode].nil?
27
+ @account_number = params[:accountNumber].strip if (params.has_key? :accountNumber) && !params[:accountNumber].nil?
28
+ @depositor = params[:depositor].strip if (params.has_key? :depositor) && !params[:depositor].nil?
29
+ @amount = params[:amount].to_i if params.has_key? :amount
30
+ @process_level = params[:processLevel].to_i if (params.has_key? :processLevel) && !params[:processLevel].nil?
31
+ @timestamp = params[:timestamp].to_i if params.has_key? :timestamp
32
+
33
+ end
34
+
35
+ def process_level_to_s
36
+ level_list = ["", "Deposit Completed", "Request Withdrawal", "Request Accepted", "Withrawal Canceled", "Withdrawal Completed"]
37
+ if @process_level.blank?
38
+ str = ""
39
+ else
40
+ str = level_list[@process_level]
41
+ end
42
+ str
43
+ end
44
+
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,42 @@
1
+
2
+ module Coinone
3
+
4
+ class Transaction
5
+
6
+ class SendCoinResponse
7
+
8
+ attr_reader :result
9
+ attr_reader :txid, :currency
10
+
11
+ def initialize(options={})
12
+
13
+ @result = options[:result] || nil
14
+ @txid = nil
15
+ @currency = options[:currency] || nil
16
+
17
+ update_response(options)
18
+
19
+
20
+ end
21
+
22
+ def update_response(params={})
23
+
24
+ @result = params[:result] if params.has_key? :result
25
+ @txid = params[:txid] if params.has_key? :txid
26
+ @currency = params[:currency].downcase if params.has_key? :currency
27
+
28
+ end
29
+
30
+ def transaction_url
31
+
32
+ url = nil
33
+ url = "https://blockchain.info/tx/#{txid}" if @currency == "btc"
34
+ url = "https://etherscan.io/tx/#{txid}" if @currency == "eth"
35
+ url = "https://gastracker.io/tx/#{txid}" if @currency == "etc"
36
+
37
+ url
38
+ end
39
+
40
+ end
41
+ end
42
+ end
@@ -1,3 +1,3 @@
1
1
  module Coinone
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.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.5.0
4
+ version: 0.6.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-29 00:00:00.000000000 Z
11
+ date: 2017-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: faraday
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.11.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.11.0
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: json
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -163,6 +177,13 @@ files:
163
177
  - lib/coinone/public/orderbook/order.rb
164
178
  - lib/coinone/public/tickers.rb
165
179
  - lib/coinone/public/tickers/ticker.rb
180
+ - lib/coinone/transaction.rb
181
+ - lib/coinone/transaction/auth_number_response.rb
182
+ - lib/coinone/transaction/coin_history.rb
183
+ - lib/coinone/transaction/coin_history/history.rb
184
+ - lib/coinone/transaction/krw_history.rb
185
+ - lib/coinone/transaction/krw_history/history.rb
186
+ - lib/coinone/transaction/send_coin_response.rb
166
187
  - lib/coinone/version.rb
167
188
  homepage: https://github.com/ggomagundan/coinone
168
189
  licenses: