示例#1
0
 /// <summary>
 /// Save watchlist.
 /// </summary>
 /// <param name="apiSaveWatchlistRequestDto">The watchlist to save.</param>
 /// <param name="callback"></param>
 /// <param name="state"></param>
 public virtual void BeginSaveWatchlist(ApiSaveWatchlistRequestDTO apiSaveWatchlistRequestDto, ReliableAsyncCallback callback, object state)
 {
     string uriTemplate = "/Save";
     _client.BeginRequest(RequestMethod.POST, "watchlist", uriTemplate , 
     new Dictionary<string, object>
     {
         { "apiSaveWatchlistRequestDto", apiSaveWatchlistRequestDto}
     },ContentType.JSON,ContentType.JSON, TimeSpan.FromMilliseconds(0), 30000,0 ,callback, state);
 }
示例#2
0
        // ***********************************
        // SaveWatchlist
        // ***********************************


        /// <summary>
        /// Save watchlist.
        /// </summary>
        /// <param name="apiSaveWatchlistRequestDto">The watchlist to save.</param>
        public virtual ApiSaveWatchlistResponseDTO SaveWatchlist(ApiSaveWatchlistRequestDTO apiSaveWatchlistRequestDto)
        {
            string uriTemplate = "/Save";
            return _client.Request<ApiSaveWatchlistResponseDTO>(RequestMethod.POST,"watchlist", uriTemplate ,
            new Dictionary<string, object>
            {
                { "apiSaveWatchlistRequestDto", apiSaveWatchlistRequestDto}
            },ContentType.JSON,ContentType.JSON, TimeSpan.FromMilliseconds(0),30000,0 );
        }
示例#3
0
 /// <summary>
 /// Save watchlist.
 /// </summary>
 /// <param name="apiSaveWatchlistRequestDto">The watchlist to save.</param>
 /// <param name="callback"></param>
 /// <param name="state"></param>
 public virtual void BeginSaveWatchlist(ApiSaveWatchlistRequestDTO apiSaveWatchlistRequestDto, ApiAsyncCallback<ApiSaveWatchlistResponseDTO> callback, object state)
 {
     _client.BeginRequest(callback, state, "watchlist", "/Save", "POST",
     new Dictionary<string, object>
     {
         { "apiSaveWatchlistRequestDto", apiSaveWatchlistRequestDto}
     }, TimeSpan.FromMilliseconds(0), "data");
 }
示例#4
0
        public void HowToUseWatchLists()
        {

            var rpcClient = BuildRpcClient();
            ListWatchlistResponseDTO watchlists;            

 #if FALSE

            // mocument cannot respond to changing server state
             
            // just deleting any existing watchlists - 

             watchlists = rpcClient.Watchlist.GetWatchlists();
            foreach (ApiClientAccountWatchlistDTO watchlist in watchlists.ClientAccountWatchlists)
            {
                rpcClient.Watchlist.DeleteWatchlist(new ApiDeleteWatchlistRequestDTO
                {
                    WatchlistId = watchlist.WatchlistId
                });
            }

            // look ma, no watchlists
            watchlists = rpcClient.Watchlist.GetWatchlists();
            Assert.AreEqual(0, watchlists.ClientAccountWatchlists.Length);

             
 #endif
            // create a watchlist. 
            // NOTE: do not specify WatchListId in either the ApiSaveWatchlistRequestDTO or any of the ApiClientAccountWatchlistItemDTO
            // this field is assigned by the server and is used only to delete the watchlist(s)

            // need a watchlist item
            var newWatchListItems = new[] {
                            new ApiClientAccountWatchlistItemDTO
                            {
                                DisplayOrder = 1,
                                MarketId = 71442
                            }
                        };

            // need a watchlist in which to place item
            var newWatchList = new ApiClientAccountWatchlistDTO
            {
                WatchlistDescription = "new watchlist",
                Items = newWatchListItems
            };

            // need an API input DTO containing the watchlist

            var watchListsToSave = new ApiSaveWatchlistRequestDTO
            {
                Watchlist = newWatchList
            };

            var saveResponse = rpcClient.Watchlist.SaveWatchlist(watchListsToSave);
            // this response is void of properties - nothing to test


            // lets verify that our watchlist was saved
            watchlists = rpcClient.Watchlist.GetWatchlists();
            Assert.AreEqual(1, watchlists.ClientAccountWatchlists.Length);


#if FALSE
            // mocument cannot yet simulate changing server state
           


            // we need the id from the sole watchlist in order to delete it.
            int watchListToDelete = watchlists.ClientAccountWatchlists[0].WatchlistId;

            var watchListsToDelete = new ApiDeleteWatchlistRequestDTO
            {
                WatchlistId = watchListToDelete
            };

            rpcClient.Watchlist.DeleteWatchlist(watchListsToDelete);

            // verify that there are no watchlistsToSave
            watchlists = rpcClient.Watchlist.GetWatchlists();
            Assert.AreEqual(0, watchlists.ClientAccountWatchlists.Length);
#endif

            rpcClient.LogOut();

            rpcClient.Dispose();
        }
示例#5
0
        // ***********************************
        // SaveWatchlist
        // ***********************************


        /// <summary>
        /// Save watchlist.
        /// </summary>
        /// <param name="apiSaveWatchlistRequestDto">The watchlist to save.</param>
        public virtual ApiSaveWatchlistResponseDTO SaveWatchlist(ApiSaveWatchlistRequestDTO apiSaveWatchlistRequestDto)
        {
            return _client.Request<ApiSaveWatchlistResponseDTO>("watchlist", "/Save", "POST",
            new Dictionary<string, object>
            {
                { "apiSaveWatchlistRequestDto", apiSaveWatchlistRequestDto}
            }, TimeSpan.FromMilliseconds(0), "data");
        }