wazirx 1.0.2 → 1.0.3
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 +15 -12
- data/lib/wazirx/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50831a494d7b1403f54eb39b75e1b4b725def789f51105a0a7187f62d9b9e6d5
|
4
|
+
data.tar.gz: 8065c9e4ae429997d49a00e2a5b9774ae577e7f3dffef709742660a1275dec87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e83b1ccbe3b59a819a4ff312a8ab28353f6201053569f0d20f8598fa0a8e6385f7023bfd0967bf213e6af3b2fc43507046d6ce796dbb4db92b531e30ff67972a
|
7
|
+
data.tar.gz: 9e05060b90bc35eb64dd5ed1506c7af7c1b9dc8cb1520f02e29c3a2fe71d9b278a523522f0a310a817d71b04bfbb51fc172f6416934b02f4e26d909463b02576
|
@@ -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,21 +67,22 @@ 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: streams, id: id, action: action, methods:
|
77
|
+
def create_stream(streams: streams, id: id, action: action, methods: {}, auth_key:'')
|
77
78
|
@ws = Faye::WebSocket::Client.new(BASE_URL)
|
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
|
+
methods[:message].call(event)
|
82
84
|
EM.add_periodic_timer 300 do
|
83
|
-
@ws.ping BASE_URL
|
85
|
+
@ws.send('ping', BASE_URL)
|
84
86
|
puts [:message, 'pinged every 5 minutes']
|
85
87
|
end
|
86
88
|
else
|
@@ -95,6 +97,7 @@ module Wazirx
|
|
95
97
|
|
96
98
|
@ws.on :close do |event|
|
97
99
|
puts [:close, event.code, event.reason]
|
100
|
+
methods[:message].call(event)
|
98
101
|
@ws = nil
|
99
102
|
end
|
100
103
|
end
|
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.3
|
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-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|