wazirx 1.0.1 → 1.0.4
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 +4 -4
- data/lib/wazirx/client/websocket.rb +18 -12
- data/lib/wazirx/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01c782f112885c2acdc69e8702285ddfba65affea3905b9d6db70418b69d6079
|
4
|
+
data.tar.gz: f22e877e2871543b3d3ac8c6ed417b7582c302f4e014be06ba9f4ec04127a178
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8d23e24f0020484a5f253bcf8bafd32b6dccfca0a904e96ad6da60bf39044912e69a4af15e33118608d5600450667f63baae83e9ed78406ddf8a331789724a2
|
7
|
+
data.tar.gz: d36ff416c540bc43bad33c3151459c792f49fab19fb7067ff7ec20efedac924efc59f8058a71703119bf27ba050d2df70fe733a212fe8b2454d637fea27c8435
|
@@ -9,29 +9,30 @@ module Wazirx
|
|
9
9
|
# Public: String base url for WebSocket client to use
|
10
10
|
BASE_URL = 'wss://stream.wazirx.com/stream'.freeze
|
11
11
|
SUBSCRIBE = 'subscribe'
|
12
|
+
UNSUBSCRIBE = 'unsubscribe'
|
12
13
|
|
13
14
|
def initialize(api_key='', secret_key='')
|
14
15
|
@api_key = api_key
|
15
16
|
@secret_key = secret_key
|
16
17
|
end
|
17
18
|
|
18
|
-
def trades(symbol:, id: 0, action:SUBSCRIBE)
|
19
|
+
def trades(symbol:, id: 0, action: SUBSCRIBE, methods: {})
|
19
20
|
stream = get_mapped_streams(symbol, 'trades')
|
20
|
-
create_stream(streams: stream, id: id, action: action)
|
21
|
+
create_stream(streams: stream, id: id, action: action, methods: methods)
|
21
22
|
end
|
22
23
|
|
23
|
-
def all_market_ticker(id: 0,action:SUBSCRIBE)
|
24
|
+
def all_market_ticker(id: 0,action: SUBSCRIBE, methods: {})
|
24
25
|
stream = "!ticker@arr"
|
25
|
-
create_stream(streams: stream, id: id, action: action)
|
26
|
+
create_stream(streams: stream, id: id, action: action, methods: methods)
|
26
27
|
end
|
27
28
|
|
28
|
-
def depth(symbol:, id: 0, action:SUBSCRIBE)
|
29
|
+
def depth(symbol:, id: 0, action: SUBSCRIBE, methods: {})
|
29
30
|
stream = get_mapped_streams(symbol, 'depth')
|
30
|
-
create_stream(streams: stream, id: id, action: action)
|
31
|
+
create_stream(streams: stream, id: id, action: action, methods: methods)
|
31
32
|
end
|
32
33
|
|
33
|
-
def user_stream(streams:, id: 0, action: SUBSCRIBE)
|
34
|
-
create_stream(streams: streams, id: id, action: action, auth_key: get_auth_key)
|
34
|
+
def user_stream(streams:, id: 0, action: SUBSCRIBE, methods: {})
|
35
|
+
create_stream(streams: streams, id: id, action: action, methods: methods, auth_key: get_auth_key)
|
35
36
|
end
|
36
37
|
|
37
38
|
def multi_stream(streams:, id: 0, action: SUBSCRIBE)
|
@@ -66,19 +67,23 @@ module Wazirx
|
|
66
67
|
end
|
67
68
|
|
68
69
|
def subscribeEvent(streams=[], id=0, auth_key='')
|
69
|
-
@ws.send(JSON.dump({'event':SUBSCRIBE, 'streams':streams.flatten,'id':id, 'auth_key':auth_key}))
|
70
|
+
@ws.send(JSON.dump({'event': SUBSCRIBE, 'streams': streams.flatten, 'id': id, 'auth_key': auth_key}))
|
70
71
|
end
|
71
72
|
|
72
73
|
def unsubscribeEvent(streams=[], id=0, auth_key='')
|
73
|
-
@ws.send(JSON.dump({'event':
|
74
|
+
@ws.send(JSON.dump({'event': UNSUBSCRIBE, 'streams': streams.flatten, 'id': id}))
|
74
75
|
end
|
75
76
|
|
76
|
-
def create_stream(streams
|
77
|
-
@ws = Faye::WebSocket::Client.new(BASE_URL)
|
77
|
+
def create_stream(streams:, id:, action:, methods: {}, auth_key: '')
|
78
|
+
@ws = Faye::WebSocket::Client.new(BASE_URL, nil)
|
78
79
|
@ws.on :open do |event|
|
79
80
|
puts [:open]
|
80
81
|
if action == SUBSCRIBE
|
81
82
|
puts subscribeEvent(streams, id, auth_key)
|
83
|
+
EM.add_periodic_timer 300 do
|
84
|
+
@ws.send('ping')
|
85
|
+
puts [:message, 'Pinging websocket every 5 minutes']
|
86
|
+
end
|
82
87
|
else
|
83
88
|
puts unsubscribeEvent(streams, id, auth_key)
|
84
89
|
end
|
@@ -86,6 +91,7 @@ module Wazirx
|
|
86
91
|
|
87
92
|
@ws.on :message do |event|
|
88
93
|
puts [:message, JSON.load(event.data)]
|
94
|
+
methods[:message].call(event)
|
89
95
|
end
|
90
96
|
|
91
97
|
@ws.on :close do |event|
|
data/lib/wazirx/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wazirx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dibyajit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
131
|
- !ruby/object:Gem::Version
|
132
132
|
version: '0'
|
133
133
|
requirements: []
|
134
|
-
rubygems_version: 3.0.
|
134
|
+
rubygems_version: 3.0.3.1
|
135
135
|
signing_key:
|
136
136
|
specification_version: 4
|
137
137
|
summary: API Wrapper for the Wazirx cryptocurrency exchange.
|