Skip to content

Commit 0865ba5

Browse files
committed
chore: rename files to snake_case
1 parent c2b5916 commit 0865ba5

34 files changed

+580
-557
lines changed

.rubocop.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Layout/LineLength:
2+
Enabled: false

lib/cryptomarket/client.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
require_relative 'httpManager'
1+
# frozen_string_literal: true
2+
3+
require_relative 'http_manager'
24

35
module Cryptomarket
46
# Creates a new rest client

lib/cryptomarket/constants.rb

Lines changed: 76 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,123 @@
1+
# frozen_string_literal: true
2+
13
module Cryptomarket
24
module Args
35
module Sort
4-
ASC = 'ASC'.freeze
5-
DESC = 'DESC'.freeze
6+
ASC = 'ASC'
7+
DESC = 'DESC'
68
end
79

8-
module Period
9-
_1_MINS = 'M1'.freeze
10-
_3_MINS = 'M3'.freeze
11-
_5_MINS = 'M5'.freeze
12-
_15_MINS = 'M15'.freeze
13-
_30_MINS = 'M30'.freeze
14-
_1_HOURS = 'H1'.freeze
15-
_4_HOURS = 'H4'.freeze
16-
_1_DAYS = 'D1'.freeze
17-
_7_DAYS = 'D7'.freeze
18-
_1_MONTHS = '1M'.freeze
10+
module Period # rubocop:disable Style/Documentation
11+
_1_MINS = 'M1' # rubocop:disable Naming/VariableName
12+
_3_MINS = 'M3' # rubocop:disable Naming/VariableName
13+
_5_MINS = 'M5' # rubocop:disable Naming/VariableName
14+
_15_MINS = 'M15' # rubocop:disable Naming/VariableName
15+
_30_MINS = 'M30' # rubocop:disable Naming/VariableName
16+
_1_HOURS = 'H1' # rubocop:disable Naming/VariableName
17+
_4_HOURS = 'H4' # rubocop:disable Naming/VariableName
18+
_1_DAYS = 'D1' # rubocop:disable Naming/VariableName
19+
_7_DAYS = 'D7' # rubocop:disable Naming/VariableName
20+
_1_MONTHS = '1M' # rubocop:disable Naming/VariableName
1921
end
2022

2123
module Side
22-
BUY = 'buy'.freeze
23-
SELL = 'sell'.freeze
24+
BUY = 'buy'
25+
SELL = 'sell'
2426
end
2527

2628
module OrderType
27-
LIMIT = 'limit'.freeze
28-
MARKET = 'market'.freeze
29-
STOP_LIMIT = 'stopLimit'.freeze
30-
STOP_MARKET = 'stopMarket'.freeze
31-
TAKE_PROFIT_LIMIT = 'takeProfitLimit'.freeze
32-
TAKE_PROFIT_MARKET = 'takeProfitMarket'.freeze
29+
LIMIT = 'limit'
30+
MARKET = 'market'
31+
STOP_LIMIT = 'stopLimit'
32+
STOP_MARKET = 'stopMarket'
33+
TAKE_PROFIT_LIMIT = 'takeProfitLimit'
34+
TAKE_PROFIT_MARKET = 'takeProfitMarket'
3335
end
3436

3537
module TimeInForce
36-
GTC = 'GTC'.freeze # Good till canceled
37-
IOC = 'IOC'.freeze # Immediate or cancell
38-
FOK = 'FOK'.freeze # Fill or kill
39-
DAY = 'Day'.freeze # Good for the day
40-
GTD = 'GDT'.freeze # Good till date
38+
GTC = 'GTC' # Good till canceled
39+
IOC = 'IOC' # Immediate or cancell
40+
FOK = 'FOK' # Fill or kill
41+
DAY = 'Day' # Good for the day
42+
GTD = 'GDT' # Good till date
4143
end
4244

4345
module IdentifyBy
44-
USERNAME = 'username'.freeze
45-
EMAIL = 'email'.freeze
46+
USERNAME = 'username'
47+
EMAIL = 'email'
4648
end
4749

4850
module Offchain
49-
NEVER = 'never'.freeze
50-
OPTIONALLY = 'optionally'.freeze
51-
REQUIRED = 'required'.freeze
51+
NEVER = 'never'
52+
OPTIONALLY = 'optionally'
53+
REQUIRED = 'required'
5254
end
5355

5456
module Account
55-
SPOT = 'spot'.freeze
56-
WALLET = 'wallet'.freeze
57+
SPOT = 'spot'
58+
WALLET = 'wallet'
5759
end
5860

5961
module TransactionType
60-
DEPOSIT = 'DEPOSIT'.freeze
61-
WITHDRAW = 'WITHDRAW'.freeze
62-
TRANSFER = 'TRANSFER'.freeze
63-
SAWAP = 'SAWAP'.freeze
62+
DEPOSIT = 'DEPOSIT'
63+
WITHDRAW = 'WITHDRAW'
64+
TRANSFER = 'TRANSFER'
65+
SAWAP = 'SAWAP'
6466
end
6567

6668
module TransactionSubtype
67-
UNCLASSIFIED = 'UNCLASSIFIED'.freeze
68-
BLOCKCHAIN = 'BLOCKCHAIN'.freeze
69-
AIRDROP = 'AIRDROP'.freeze
70-
AFFILIATE = 'AFFILIATE'.freeze
71-
STAKING = 'STAKING'.freeze
72-
BUY_CRYPTO = 'BUY_CRYPTO'.freeze
73-
OFFCHAIN = 'OFFCHAIN'.freeze
74-
FIAT = 'FIAT'.freeze
75-
SUB_ACCOUNT = 'SUB_ACCOUNT'.freeze
76-
WALLET_TO_SPOT = 'WALLET_TO_SPOT'.freeze
77-
SPOT_TO_WALLET = 'SPOT_TO_WALLET'.freeze
78-
WALLET_TO_DERIVATIVES = 'WALLET_TO_DERIVATIVES'.freeze
79-
DERIVATIVES_TO_WALLET = 'DERIVATIVES_TO_WALLET'.freeze
80-
CHAIN_SWITCH_FROM = 'CHAIN_SWITCH_FROM'.freeze
81-
CHAIN_SWITCH_TO = 'CHAIN_SWITCH_TO'.freeze
82-
INSTANT_EXCHANGE = 'INSTANT_EXCHANGE'.freeze
69+
UNCLASSIFIED = 'UNCLASSIFIED'
70+
BLOCKCHAIN = 'BLOCKCHAIN'
71+
AIRDROP = 'AIRDROP'
72+
AFFILIATE = 'AFFILIATE'
73+
STAKING = 'STAKING'
74+
BUY_CRYPTO = 'BUY_CRYPTO'
75+
OFFCHAIN = 'OFFCHAIN'
76+
FIAT = 'FIAT'
77+
SUB_ACCOUNT = 'SUB_ACCOUNT'
78+
WALLET_TO_SPOT = 'WALLET_TO_SPOT'
79+
SPOT_TO_WALLET = 'SPOT_TO_WALLET'
80+
WALLET_TO_DERIVATIVES = 'WALLET_TO_DERIVATIVES'
81+
DERIVATIVES_TO_WALLET = 'DERIVATIVES_TO_WALLET'
82+
CHAIN_SWITCH_FROM = 'CHAIN_SWITCH_FROM'
83+
CHAIN_SWITCH_TO = 'CHAIN_SWITCH_TO'
84+
INSTANT_EXCHANGE = 'INSTANT_EXCHANGE'
8385
end
8486

8587
module TransactionStatus
86-
CREATED = 'CREATED'.freeze
87-
PENDING = 'PENDING'.freeze
88-
FAILED = 'FAILED'.freeze
89-
SUCCESS = 'SUCCESS'.freeze
90-
ROLLED_BACK = 'ROLLED_BACK'.freeze
88+
CREATED = 'CREATED'
89+
PENDING = 'PENDING'
90+
FAILED = 'FAILED'
91+
SUCCESS = 'SUCCESS'
92+
ROLLED_BACK = 'ROLLED_BACK'
9193
end
9294

9395
module SortBy
94-
CREATED_AT = 'created_at'.freeze
95-
ID = 'id'.freeze
96+
CREATED_AT = 'created_at'
97+
ID = 'id'
9698
end
9799

98100
module Contingency
99-
ALL_OR_NONE = 'allOrNone'.freeze
100-
AON = 'allOrNone'.freeze
101-
ONE_CANCEL_OTHER = 'oneCancelOther'.freeze
102-
OCO = 'oneCancelOther'.freeze
103-
ONE_TRIGGER_OTHER = 'oneTriggerOther'.freeze
104-
OTO = 'oneTriggerOther'.freeze
105-
ONE_TRIGGER_ONE_CANCEL_OTHER = 'oneTriggerOneCancelOther'.freeze
106-
OTOCO = 'oneTriggerOneCancelOther'.freeze
101+
ALL_OR_NONE = 'allOrNone'
102+
AON = 'allOrNone'
103+
ONE_CANCEL_OTHER = 'oneCancelOther'
104+
OCO = 'oneCancelOther'
105+
ONE_TRIGGER_OTHER = 'oneTriggerOther'
106+
OTO = 'oneTriggerOther'
107+
ONE_TRIGGER_ONE_CANCEL_OTHER = 'oneTriggerOneCancelOther'
108+
OTOCO = 'oneTriggerOneCancelOther'
107109
end
108110

109111
module NotificationType
110-
SNAPSHOT = 'snapshot'.freeze
111-
UPDATE = 'update'.freeze
112-
DATA = 'data'.freeze
113-
COMMAND = 'command'.freeze
112+
SNAPSHOT = 'snapshot'
113+
UPDATE = 'update'
114+
DATA = 'data'
115+
COMMAND = 'command'
114116
end
115117

116118
module SubscriptionMode
117-
UPDATES = 'updates'.freeze
118-
BATCHES = 'batches'.freeze
119+
UPDATES = 'updates'
120+
BATCHES = 'batches'
119121
end
120122
end
121123
end
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'net/http'
24
require 'uri'
35
require 'json'

lib/cryptomarket/exceptions.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Cryptomarket
24
class SDKException < ::StandardError
35
end
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
1+
# frozen_string_literal: true
2+
13
require 'net/http'
24
require 'uri'
35
require 'json'
46
require 'base64'
57
require 'rest-client'
68
require 'date'
79
require_relative 'exceptions'
8-
require_relative 'CredentialFactory'
10+
require_relative 'credential_factory'
911

1012
module Cryptomarket
1113
# Manager of http requests to the cryptomarket server
1214
class HttpManager
1315
Request = Data.define(:uri, :endpoint, :payload, :headers, :is_json)
14-
@@api_url = 'https://api.exchange.cryptomkt.com'
15-
@@api_version = '/api/3/'
16+
@@API_URL = 'https://api.exchange.cryptomkt.com' # rubocop:disable Naming/VariableName,Style/ClassVars
17+
@@API_VERSION = '/api/3/' # rubocop:disable Naming/VariableName,Style/ClassVars
1618

1719
def initialize(api_key:, api_secret:, window: nil)
1820
@credential_factory = CredentialFactory(api_key, api_secret, window)
1921
end
2022

2123
def make_request(method:, endpoint:, params: nil, public: false)
22-
uri = URI(@@api_url + version_as_str + endpoint)
24+
uri = URI(@@API_URL + version_as_str + endpoint)
2325
payload = build_payload(params)
2426
headers = build_headers(method, endpoint, params, public)
2527
if ((method.upcase == 'GET') || (method.upcase == 'PUT')) && !payload.nil?
@@ -30,7 +32,7 @@ def make_request(method:, endpoint:, params: nil, public: false)
3032
end
3133

3234
def make_post_request(method:, endpoint:, params: nil)
33-
uri = URI(@@api_url + version_as_str + endpoint)
35+
uri = URI(@@API_URL + version_as_str + endpoint)
3436
payload = build_payload(params)
3537
do_request(Request[method, uri, payload, build_post_headers(endpoint, payload), true])
3638
end
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'securerandom'
24
require_relative 'client_base'
35

@@ -42,7 +44,8 @@ def wait_authed
4244
#
4345
# https://api.exchange.cryptomkt.com/#socket-session-authentication
4446
#
45-
# +Proc+ +callback+:: Optional. A +Proc+ to call with the result data. It takes two arguments, err and result. err is None for successful calls, result is None for calls with error: Proc.new {|err, result| ...}
47+
# +Proc+ +callback+:: Optional. A +Proc+ to call with the result data. It takes two arguments, err and result.
48+
# err is None for successful calls, result is None for calls with error: Proc.new {|err, result| ...}
4649

4750
def authenticate(callback = nil)
4851
timestamp = Time.now.to_i * 1000
@@ -51,7 +54,7 @@ def authenticate(callback = nil)
5154
message += @window.to_s unless @window.nil?
5255
signature = OpenSSL::HMAC.hexdigest digest, @api_secret, message.to_s
5356
params = build_auth_payload timestamp, signature
54-
send_by_id('login', callback, params)
57+
request('login', callback, params)
5558
end
5659

5760
def build_auth_payload(timestamp, signature)

lib/cryptomarket/websocket/callbackCache.rb renamed to lib/cryptomarket/websocket/callback_cache.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
require_relative 'reusableCallback'
1+
# frozen_string_literal: true
2+
3+
require_relative 'reusable_callback'
24

35
module Cryptomarket
46
module Websocket
@@ -9,7 +11,7 @@ def initialize
911
@reusable_callbacks = {}
1012
@next_id = 1
1113
end
12-
14+
1315
def _get_next_id
1416
next_id = @next_id
1517
@next_id += 1

0 commit comments

Comments
 (0)