bittrex-enterprise 0.4 → 0.5

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
  SHA256:
3
- metadata.gz: eae4397d0819fa5d406afa4a5bf77acc5b631d3de0fe4531e27f8fc36d83d51a
4
- data.tar.gz: 1f9f329dee24e1f5210ae99dc8c596eb0717844691cabda872ccedca886dcc65
3
+ metadata.gz: c6f8406456ef73d808ac31d37cba80b1c27f54712aa596438608888db2eafc56
4
+ data.tar.gz: e77fdc8c06fe316aec6d13673e74fb0e653cbba65c3820fd60ca72604c68412e
5
5
  SHA512:
6
- metadata.gz: f1e37728d4e1eed1e80ba49a0e44bb77bc3ca8e47645beb66d63984693ee865267d246ef7964103514023082ffdcb069d5c1f2a66d7c145abefc15e99b0b0215
7
- data.tar.gz: 25aa853140dcdf70885a8d882587f24b456542b0b1f1c6d00d6dfead51dffb959338a6d0a7e757971c73055f7190a707ae19bfeb0081599d8ff4e797ccfee707
6
+ metadata.gz: f186e187657ecfa2533e2563b6e38ea4ded457d58045054457eaaab91d98b5666cac9e18fd2ef84344936827ea1e3067698d9fdf668f28d229a4b8ef1cc0289d
7
+ data.tar.gz: 8a4068905e753eb88369e0611231d8dcfc217f3ff5fe47669d297782629321b167f41d1a55f8439043bf96fca9924cf19ab98c4c7bd9cf21049308de95571258
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bittrex-enterprise (0.3)
4
+ bittrex-enterprise (0.4)
5
5
  addressable (~> 2.6)
6
6
  httparty (~> 0.17)
7
7
  json (~> 2.2)
@@ -8,9 +8,12 @@ module BittrexEnterprise
8
8
 
9
9
  # -------------------------------------- LIST ------------------------------------------------
10
10
  # List deposit addresses that have been requested or provisioned.
11
+ #
12
+ # ------ PARAMS ------
13
+ # sub_account_id: string - optional - ID of the subaccount to use for this call
11
14
  # --------------------------------------------------------------------------------------------
12
- def self.list
13
- get_signed 'addresses'
15
+ def self.list(sub_account_id=nil)
16
+ get_signed 'addresses', sub_account_id: sub_account_id
14
17
  end
15
18
 
16
19
 
@@ -20,9 +23,11 @@ module BittrexEnterprise
20
23
  #
21
24
  # ------ PARAMS ------
22
25
  # currency_symbol - string - required - the currency ID to provision a new address for
26
+ #
27
+ # sub_account_id: string - optional - ID of the subaccount to use for this call
23
28
  # --------------------------------------------------------------------------------------------
24
- def self.create(currency_symbol)
25
- post_signed 'addresses', currencySymbol: currency_symbol
29
+ def self.create(currency_symbol, sub_account_id=nil)
30
+ post_signed 'addresses', currencySymbol: currency_symbol, sub_account_id: sub_account_id
26
31
  end
27
32
 
28
33
 
@@ -32,9 +37,10 @@ module BittrexEnterprise
32
37
  # ------ PARAMS ------
33
38
  # currency_symbol - string - required - symbol of the currency to retrieve the deposit
34
39
  # address for
40
+ # sub_account_id: string - optional - ID of the subaccount to use for this call
35
41
  # --------------------------------------------------------------------------------------------
36
- def self.status(currency_symbol)
37
- get_signed 'addresses/{currencySymbol}', currencySymbol: currency_symbol
42
+ def self.status(currency_symbol, sub_account_id=nil)
43
+ get_signed 'addresses/{currencySymbol}', currencySymbol: currency_symbol, sub_account_id: sub_account_id
38
44
  end
39
45
 
40
46
  end
@@ -11,7 +11,7 @@ module ApiHelpers
11
11
 
12
12
  def get(api_group, params = {})
13
13
  params.compact!
14
- api_group, params = setup_params(api_group, params)
14
+ api_group, params, sub_account_id = setup_params(api_group, params)
15
15
 
16
16
  begin
17
17
  response = HTTParty.get(base_uri + api_group, query: params)
@@ -22,12 +22,7 @@ module ApiHelpers
22
22
  end
23
23
 
24
24
  def get_signed(api_group, params = {})
25
- params.compact!
26
- api_group, params = setup_params(api_group, params)
27
-
28
- url = base_uri + api_group
29
-
30
- headers = setup_headers('GET', url)
25
+ api_group, params, sub_account_id, headers, url = setup_call(api_group, params, 'GET')
31
26
 
32
27
  begin
33
28
  response = HTTParty.get(url, {query: params, headers: headers})
@@ -38,13 +33,7 @@ module ApiHelpers
38
33
  end
39
34
 
40
35
  def post_signed(api_group, params = {})
41
-
42
- params.compact!
43
- api_group, params = setup_params(api_group, params)
44
-
45
- url = base_uri + api_group
46
-
47
- headers = setup_headers('POST', url, params.to_json)
36
+ api_group, params, sub_account_id, headers, url = setup_call(api_group, params, 'POST')
48
37
 
49
38
  begin
50
39
  response = HTTParty.post(url, {body: params.to_json, headers: headers})
@@ -55,12 +44,7 @@ module ApiHelpers
55
44
  end
56
45
 
57
46
  def delete_signed(api_group)
58
- params.compact!
59
- api_group, params = setup_params(api_group, params)
60
-
61
- url = base_uri + api_group
62
-
63
- headers = setup_headers('DELETE', url, params)
47
+ api_group, params, sub_account_id, headers, url = setup_call(api_group, params, 'DELETE')
64
48
 
65
49
  begin
66
50
  response = HTTParty.delete(url, {body: params, headers: headers})
@@ -70,21 +54,35 @@ module ApiHelpers
70
54
  end
71
55
  end
72
56
 
57
+ private
58
+
59
+ def setup_call(api_group, params, method)
60
+ params.compact!
61
+ api_group, params, sub_account_id = setup_params(api_group, params)
62
+
63
+ url = base_uri + api_group
64
+
65
+ headers = setup_headers(method, url, params, sub_account_id)
66
+
67
+ [api_group, params, sub_account_id, headers, url]
68
+ end
69
+
73
70
  def setup_params(api_group, params)
71
+ sub_account_id = params.delete(:sub_account_id) || ''
74
72
  matchArr = api_group.match(/{(\D*)}/)&.captures
75
73
  if matchArr
76
74
  matchArr.each do |m|
77
75
  api_group.gsub!("{#{m}}", params.delete(m.to_sym))
78
76
  end
79
77
  end
80
- [api_group, params]
78
+ [api_group, params, sub_account_id]
81
79
  end
82
80
 
83
- def setup_headers(method, uri, content='')
81
+ def setup_headers(method, uri, params='', api_subaccount_id='')
84
82
  api_key = BittrexEnterprise.configuration.key
85
83
  api_timestamp = DateTime.now.strftime('%Q')
86
- api_content_hash = create_content_sign(content)
87
- api_subaccount_id = '' # TODO: make this work with Subaccounts
84
+ params = params.to_json if method == 'POST'
85
+ api_content_hash = create_content_sign(params)
88
86
  pre_sign = [api_timestamp, uri, method, api_content_hash, api_subaccount_id].join('')
89
87
  api_signature = create_sign_hmac(pre_sign)
90
88
 
@@ -96,7 +94,7 @@ module ApiHelpers
96
94
  "Api-Signature": api_signature
97
95
  }
98
96
 
99
- # headers['Api-Subaccount-Id'] = api_subaccount_id if api_subaccount_id
97
+ headers['Api-Subaccount-Id'] = api_subaccount_id if api_subaccount_id != ''
100
98
 
101
99
  headers
102
100
  end
@@ -9,9 +9,12 @@ module BittrexEnterprise
9
9
  # ---------------------------------------- LIST ----------------------------------------------
10
10
  # List account balances across available currencies. Returns a Balance entry for each
11
11
  # currency for which there is either a balance or an address.
12
+ #
13
+ # ------ PARAMS ------
14
+ # sub_account_id: string - optional - ID of the subaccount to use for this call
12
15
  # --------------------------------------------------------------------------------------------
13
- def self.list
14
- get_signed 'balances'
16
+ def self.list(sub_account_id='')
17
+ get_signed 'balances', sub_account_id: sub_account_id
15
18
  end
16
19
 
17
20
 
@@ -22,9 +25,10 @@ module BittrexEnterprise
22
25
  # ------ PARAMS ------
23
26
  # currency_symbol: string - required - unique symbol of the currency to retrieve the
24
27
  # account balance for
28
+ # sub_account_id: string - optional - ID of the subaccount to use for this call
25
29
  # --------------------------------------------------------------------------------------------
26
- def self.info(currency_symbol)
27
- get_signed 'balances/{currencySymbol}', currencySymbol: currency_symbol
30
+ def self.info(currency_symbol, sub_account_id='')
31
+ get_signed 'balances/{currencySymbol}', currencySymbol: currency_symbol, sub_account_id: sub_account_id
28
32
  end
29
33
 
30
34
  end
@@ -12,7 +12,10 @@ module BittrexEnterprise
12
12
  #
13
13
  # ------ PARAMS ------ PARAMS MUST BE PASSED AS KEY VALUE PAIRS
14
14
  # status - string enum [PENDING] - optional - filter by an open deposit status
15
+ #
15
16
  # currencySymbol - string - optional - filter by currency
17
+ #
18
+ # sub_account_id: string - optional - ID of the subaccount to use for this call
16
19
  # --------------------------------------------------------------------------------------------
17
20
  def self.open(params={})
18
21
  get_signed 'deposits/open', params
@@ -47,6 +50,8 @@ module BittrexEnterprise
47
50
  # endDate - string(date-time) - Filters out result after this timestamp. Uses the same format
48
51
  # as StartDate. Either, both, or neither of StartDate and EndDate can be set. The only
49
52
  # constraint on the pair is that, if both are set, then EndDate cannot be before StartDate.
53
+ #
54
+ # sub_account_id: string - optional - ID of the subaccount to use for this call
50
55
  # --------------------------------------------------------------------------------------------
51
56
  def self.closed(params={})
52
57
  get_signed 'deposits/closed', params
@@ -58,9 +63,11 @@ module BittrexEnterprise
58
63
  #
59
64
  # ------ PARAMS ------
60
65
  # tx_id - string - required - the transaction id to lookup
66
+ #
67
+ # sub_account_id: string - optional - ID of the subaccount to use for this call
61
68
  # --------------------------------------------------------------------------------------------
62
- def self.by_tx_id(tx_id)
63
- get_signed 'deposits/ByTxId/{tdId}', txId: tx_id
69
+ def self.by_tx_id(tx_id, sub_account_id='')
70
+ get_signed 'deposits/ByTxId/{tdId}', txId: tx_id, sub_account_id: sub_account_id
64
71
  end
65
72
 
66
73
 
@@ -69,9 +76,11 @@ module BittrexEnterprise
69
76
  #
70
77
  # ------ PARAMS ------
71
78
  # deposit_id - string - required - (guid-formatted string) - ID of the deposit to retrieve
79
+ #
80
+ # sub_account_id: string - optional - ID of the subaccount to use for this call
72
81
  # --------------------------------------------------------------------------------------------
73
- def self.retrieve(deposit_id)
74
- get_signed 'deposits/{depositId}', depositId: deposit_id
82
+ def self.retrieve(deposit_id, sub_account_id='')
83
+ get_signed 'deposits/{depositId}', depositId: deposit_id, sub_account_id: sub_account_id
75
84
  end
76
85
 
77
86
  end
@@ -1,3 +1,3 @@
1
1
  module BittrexEnterprise
2
- VERSION = '0.4'
2
+ VERSION = '0.5'
3
3
  end
@@ -15,6 +15,8 @@ module BittrexEnterprise
15
15
  # filter by an open withdrawal status
16
16
  #
17
17
  # currencySymbol - string - optional - filter by currency
18
+ #
19
+ # sub_account_id: string - optional - ID of the subaccount to use for this call
18
20
  # --------------------------------------------------------------------------------------------
19
21
  def self.open(params={})
20
22
  get_signed 'withdrawals/open', params
@@ -49,6 +51,8 @@ module BittrexEnterprise
49
51
  # endDate - string(date-time) - Filters out result after this timestamp. Uses the same format
50
52
  # as StartDate. Either, both, or neither of StartDate and EndDate can be set. The only
51
53
  # constraint on the pair is that, if both are set, then EndDate cannot be before StartDate.
54
+ #
55
+ # sub_account_id: string - optional - ID of the subaccount to use for this call
52
56
  # --------------------------------------------------------------------------------------------
53
57
  def self.closed(params={})
54
58
  get_signed 'withdrawals/closed', params
@@ -60,9 +64,11 @@ module BittrexEnterprise
60
64
  #
61
65
  # ------ PARAMS ------
62
66
  # tx_id - string - required - the transaction id to lookup
67
+ #
68
+ # sub_account_id: string - optional - ID of the subaccount to use for this call
63
69
  # --------------------------------------------------------------------------------------------
64
- def self.by_tx_id(tx_id)
65
- get_signed 'withdrawals/ByTxId/{txId}', txId: tx_id
70
+ def self.by_tx_id(tx_id, sub_account_id='')
71
+ get_signed 'withdrawals/ByTxId/{txId}', txId: tx_id, sub_account_id: sub_account_id
66
72
  end
67
73
 
68
74
 
@@ -71,9 +77,11 @@ module BittrexEnterprise
71
77
  #
72
78
  # ------ PARAMS ------
73
79
  # withdrawal_id - string - required - (guid-formatted string) - ID of withdrawal to retrieve
80
+ #
81
+ # sub_account_id: string - optional - ID of the subaccount to use for this call
74
82
  # --------------------------------------------------------------------------------------------
75
- def self.by_tx_id(withdrawal_id)
76
- get_signed 'withdrawals/{withdrawalId}', withdrawalId: tx_id
83
+ def self.retrieve(withdrawal_id, sub_account_id='')
84
+ get_signed 'withdrawals/{withdrawalId}', withdrawalId: withdrawal_id, sub_account_id: sub_account_id
77
85
  end
78
86
 
79
87
 
@@ -82,9 +90,11 @@ module BittrexEnterprise
82
90
  #
83
91
  # ------ PARAMS ------
84
92
  # withdrawal_id - string - required - (guid-formatted string) - ID of withdrawal to cancel
93
+ #
94
+ # sub_account_id: string - optional - ID of the subaccount to use for this call
85
95
  # --------------------------------------------------------------------------------------------
86
- def self.cancel(withdrawal_id)
87
- delete_signed 'withdrawals/{withdrawalId}', withdrawalId: withdrawal_id
96
+ def self.cancel(withdrawal_id, sub_account_id='')
97
+ delete_signed 'withdrawals/{withdrawalId}', withdrawalId: withdrawal_id, sub_account_id: sub_account_id
88
98
  end
89
99
 
90
100
 
@@ -97,9 +107,12 @@ module BittrexEnterprise
97
107
  # "currencySymbol": "string",
98
108
  # "quantity": "number (double)",
99
109
  # "cryptoAddress": "string",
100
- # "cryptoAddressTag": "string"
110
+ # "cryptoAddressTag": "string",
111
+ # "sub_account_id": "string"
101
112
  # }
102
- # *** REQUIRED - id, currencySymbol, quantity, cryptoAddress ***
113
+ # *** REQUIRED - currencySymbol, quantity, cryptoAddress ***
114
+ #
115
+ # sub_account_id: string - optional - ID of the subaccount to use for this call
103
116
  # --------------------------------------------------------------------------------------------
104
117
  def self.create(new_withdrawal={})
105
118
  post_signed 'withdrawals', new_withdrawal
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bittrex-enterprise
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.4'
4
+ version: '0.5'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vertbase
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-27 00:00:00.000000000 Z
11
+ date: 2019-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -187,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
187
187
  - !ruby/object:Gem::Version
188
188
  version: '0'
189
189
  requirements: []
190
- rubygems_version: 3.0.3
190
+ rubygems_version: 3.0.4
191
191
  signing_key:
192
192
  specification_version: 4
193
193
  summary: Ruby implementation of the Bittrex v3 API