Esempio n. 1
0
        /// <inheritdoc />
        public CoinbaseWebsocketClient(ICoinbaseCommunicator communicator)
        {
            ConValidations.ValidateInput(communicator, nameof(communicator));

            _communicator = communicator;
            _messageReceivedSubscription = _communicator.MessageReceived.Subscribe(HandleMessage);
        }
        /// Stream wallet snapshot manually
        /// </summary>
        /// <param name="communicator"></param>
        /// <param name="apiKey"></param>
        /// <param name="apiSecret"></param>
        /// <param name="passphrase"></param>
        /// <returns></returns>
        public static async Task StreamWalletsSnapshot(ICoinbaseCommunicator communicator,
                                                       string apiKey,
                                                       string apiSecret,
                                                       string passphrase)
        {
            var authentication = new CoinbaseAuthentication(apiKey, apiSecret, passphrase);
            var request        =
                await CoinbaseHttpClient.SendHttpRequest(authentication, apiKey, apiSecret, passphrase, "/accounts");

            var wallets = WalletResponse.FromJson(request);

            var snapshot = new WalletsSnapshotResponse();

            snapshot.Wallets = wallets;
            snapshot.Type    = ChannelType.WalletsSnapshot;

            var serialized = JsonConvert.SerializeObject(snapshot, CoinbaseJsonSerializer.Settings);

            communicator.StreamFakeMessage(ResponseMessage.TextMessage(serialized));
        }