Module: Coinbot::WebSock::Coinbase
- Defined in:
- lib/coinbot/web_sock/coinbase.rb
Class Method Summary collapse
-
.connect(opts = {}) ⇒ Object
- Supported Method Parameters
-
Coinbot::WebSock.connect( ).
-
.help ⇒ Object
Display Usage for this Module.
- .subscribe_message(opts = {}) ⇒ Object
Class Method Details
.connect(opts = {}) ⇒ Object
- Supported Method Parameters
-
Coinbot::WebSock.connect( )
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/coinbot/web_sock/coinbase.rb', line 13 public_class_method def self.connect(opts = {}) option_choice = opts[:option_choice] env = opts[:env] cb_pro_ws_feed = 'wss://ws-feed.pro.coinbase.com' cb_pro_ws_feed = 'wss://ws-feed-public.sandbox.pro.coinbase.com' if env[:env] == :sandbox if option_choice.proxy tls_opts = { verify_peer: false } proxy_opts = { origin: option_choice.proxy } ws = Faye::WebSocket::Client.new( cb_pro_ws_feed, [], tls: tls_opts, proxy: proxy_opts, ping: 30 ) else ws = Faye::WebSocket::Client.new( cb_pro_ws_feed, [], ping: 30 ) end ws rescue Interrupt # Exit Gracefully if CTRL+C is Pressed During Session Coinbot.exit_gracefully(which_self: self) rescue StandardError => e raise e end |
.help ⇒ Object
Display Usage for this Module
87 88 89 90 91 |
# File 'lib/coinbot/web_sock/coinbase.rb', line 87 public_class_method def self.help puts "USAGE: logger = #{self}.create() " end |
.subscribe_message(opts = {}) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/coinbot/web_sock/coinbase.rb', line 51 public_class_method def self.(opts = {}) option_choice = opts[:option_choice] env = opts[:env] product_id = option_choice.symbol.to_s.gsub('_', '-').upcase api_secret = env[:api_secret] api_signature_response = Coinbot::API.generate_signature( api_secret: api_secret ) api_key = env[:api_key] api_passphrase = env[:api_passphrase] = api_signature_response[:api_timestamp] api_signature = api_signature_response[:api_signature] "{ \"type\": \"subscribe\", \"product_ids\": [ \"#{product_id}\" ], \"channels\": [ \"heartbeat\", \"level2\", \"ticker\", \"user\" ], \"key\": \"#{api_key}\", \"passphrase\": \"#{api_passphrase}\", \"timestamp\": \"#{}\", \"signature\": \"#{api_signature}\" }" rescue StandardError => e raise e end |