/// <summary> /// This method is called when an agent receives a new token /// </summary> /// <param name="token">FCM token from agent</param> /// <returns>Async method</returns> public async Task PushNewToken(TokenDetail token) { if (token == null || string.IsNullOrEmpty(token.Token)) { return; } if (string.IsNullOrEmpty(token.Device)) { token.Device = "desktop"; } if (string.IsNullOrEmpty(token.Version)) { token.Version = "pre-alpha"; } var currentUserDetails = await CurrentUserDetails(); var livechatUserToken = uow.GetRepository <LivechatUserTokenRepository>(); // TODO: Get AuthToken from query/header instead of param await livechatUserToken.PersistTokenDetail(new LivechatUserToken { AuthToken = currentUserDetails.AuthToken, PushToken = token.Token, Device = token.Device, Version = token.Version, LivechatUserId = currentUserDetails.LivechatUserId, Role = currentUserDetails.Role, Stores = string.Join(",", currentUserDetails.Stores) }); }
private static void AssertTokenDetail(TokenDetail c) { c.Name.Should().NotBeNullOrWhiteSpace(); foreach (var t in c.Tokens) { t.Token.Should().NotBeNullOrWhiteSpace(); } }
public async Task <TokenDetail> GetToken() { TokenDetail tk = new TokenDetail(); tk.name = "name"; //tk.email = "email"; // tk.token = "test token"; return(tk); }
public TokenDetail Add(TokenDetail detail) { try { _context.TokenDetails.Add(detail); _context.SaveChanges(); } catch (Exception e) { ExceptionLogger.Log(e); } return(detail); }
public async Task <IActionResult> UnRegisterToken([FromBody] TokenDetail token) { var livechatUserToken = uow.GetRepository <LivechatUserTokenRepository>(); await livechatUserToken.RemoveTokenDetail(new LivechatUserToken { AuthToken = token.AuthToken, PushToken = token.Token, Device = token.Device, Version = token.Version, LivechatUserId = token.LivechatUserId }); return(Ok()); }
public TokenDetail Update(TokenDetail detailChanges) { try { var detail = _context.TokenDetails.Attach(detailChanges); detail.State = EntityState.Modified; _context.SaveChanges(); } catch (Exception e) { ExceptionLogger.Log(e); } return(detailChanges); }
public async Task <IActionResult> RegisterToken([FromBody] TokenDetail token) { // Persists on database // TODO: Get AuthToken from query/header instead of param var user = HttpContext.User; var livechatUserToken = uow.GetRepository <LivechatUserTokenRepository>(); await livechatUserToken.PersistTokenDetail(new LivechatUserToken { AuthToken = user.FindFirstValue("AuthToken") ?? "", PushToken = token.Token, Device = token.Device, Version = token.Version, LivechatUserId = user.FindFirstValue("LivechatUserId") ?? "", Role = user.FindFirstValue(ClaimTypes.Role) ?? "", Stores = user.FindFirstValue("Stores") ?? "" }); return(Ok()); }
public TokenDetail Delete(int id) { TokenDetail detail = null; try { detail = _context.TokenDetails.Find(id); if (detail != null) { _context.TokenDetails.Remove(detail); _context.SaveChanges(); } } catch (Exception e) { ExceptionLogger.Log(e); } return(detail); //return null; }
static void TestRateManager() { RateService.RateServiceClient client = new RateServiceClient(); Console.WriteLine("Get the Token Rate List"); foreach (TokenRateData t in client.GetTokenRateListAsync().GetAwaiter().GetResult()) { Console.WriteLine("Token {0} Bid/Ask {1}/{2}", t.TokenId, t.BidRate, t.AskRate); } Console.WriteLine("Testing Token Pair Rate Data for @[email protected]"); TokenPairRateData tokenPairRateData = client.GetTokenPairRateAsync("@AAPL", "@BT.A").GetAwaiter().GetResult(); Console.WriteLine("Token Pair Rates"); Console.WriteLine("Token Pair {0}/{1} Bid/Offer {2}/{3}", tokenPairRateData.Token1Id, tokenPairRateData.Token2Id, tokenPairRateData.BidRate, tokenPairRateData.AskRate); Console.WriteLine("Token1 {0} Bid/Offer {1}/{2}", tokenPairRateData.Token1Id, tokenPairRateData.Token1BidRate, tokenPairRateData.Token1AskRate); Console.WriteLine("Token2 {0} Bid/Offer {1}/{2}", tokenPairRateData.Token2Id, tokenPairRateData.Token2BidRate, tokenPairRateData.Token2AskRate); Console.WriteLine(); Console.WriteLine("Cross Currency Rates"); Console.WriteLine("Currency Pair {0}-{1} Bid/Offer {2}/{3}", tokenPairRateData.Currency1, tokenPairRateData.Currency2, tokenPairRateData.CurrencyPairBidRate, tokenPairRateData.CurrencyPairAskRate); Console.WriteLine("Token1 Price Currency {0} Bid/Offer {1}/{2}", tokenPairRateData.Currency1, tokenPairRateData.Currency1BidRate, tokenPairRateData.Currency1AskRate); Console.WriteLine("Token2 Price Currency {0} Bid/Offer {1}/{2}", tokenPairRateData.Currency2, tokenPairRateData.Currency2BidRate, tokenPairRateData.Currency2AskRate); Console.WriteLine("Press Any Key"); Console.ReadKey(); Console.WriteLine(); Console.WriteLine("GetTokenDetail Test @AAPL"); TokenDetail tokenDetailRecord = client.GetTokenDetailAsync("@AAPL").GetAwaiter().GetResult(); Console.WriteLine("Token Detail for {0} TradingView Symbol {1}", tokenDetailRecord.TokenId, tokenDetailRecord.TradingViewSymbol); Console.WriteLine("Press Any Key"); Console.ReadKey(); //Console.WriteLine("Test the Get List Methods"); //var assetList = client.GetAssetListAsync().GetAwaiter().GetResult(); //foreach (string s in assetList) // Console.WriteLine("Asset {0} returned", s); //var tokenList = client.GetTokenListAsync().GetAwaiter().GetResult(); //foreach (string s in tokenList) // Console.WriteLine("Token {0} returned", s); //Console.WriteLine("Press any key to continue"); //Console.ReadKey(); //Console.WriteLine("Asset Subscription Test"); #region Test Asset Rate Subscription //client.AssetRateUpdateReceived += Client_AssetRateUpdateReceived; //client.SubscribeToAssetRateUpdateAsync("GOOG"); //client.SubscribeToAssetRateUpdateAsync("AAPL"); //Console.WriteLine("Press any key to continue"); //Console.ReadKey(); //client.UnSubscribeToAssetRateUpdateAsync("GOOG"); //client.UnSubscribeToAssetRateUpdateAsync("AAPL"); #endregion //Console.WriteLine("Token Subscription Test"); //Console.ReadKey(); #region Test Token Rate Subscription //client.TokenRateUpdateReceived += Client_TokenRateUpdateReceived; //client.SubscribeToTokenRateUpdateAsync("@GOOG"); //client.SubscribeToTokenRateUpdateAsync("@AAPL"); //Console.WriteLine("Press any key to continue"); //Console.ReadKey(); //client.UnSubscribeToTokenRateUpdateAsync("@GOOG"); //client.UnSubscribeToTokenRateUpdateAsync("@AAPL"); #endregion //Console.WriteLine("Test Completed"); //Console.WriteLine("Currency Pair Subscription Test"); //Console.ReadKey(); //client.CurrencyPairRateUpdateReceived += Client_CurrencyPairRateUpdateReceived; //client.SubscribeToCurrencyPairRateUpdateAsync("EUR", "USD"); //Console.WriteLine("Subscribing to currency pair EUR/USD"); //Console.ReadKey(); //client.UnSubscribeToCurrencyPairRateUpdateAsync("EUR", "USD"); //Console.WriteLine("Unsubscribed from EUR/USD"); //Console.ReadKey(); Console.WriteLine("Token Pair Subscription Test"); Console.ReadKey(); client.TokenPairRateUpdateReceived += Client_TokenPairRateUpdateReceived; client.SubscribeToTokenPairRateUpdateAsync("@AAPL", "@BT.A"); Console.WriteLine("Press any key to continue"); Console.ReadKey(); client.UnSubscribeToTokenPairRateUpdateAsync("@AAPL", "@BT.A"); Console.WriteLine("Unsubscribed from @AAPL/@BT.A"); Console.WriteLine("Test completed ..."); Console.ReadKey(); }