Пример #1
0
        public async void DeleteWorkingOrder()
        {
            RestCommands.Post Post = new RestCommands.Post();
            RestCommands.IGResponse <Model.WorkingOrder.DeleteWorkingOrderResponse> Response = await Post.Execute <Model.WorkingOrder.DeleteWorkingOrderResponse>(this.Session.BaseURL + "/workingorders/otc" + "/" + IGWorkingOrderData.DealId, Session, RestCommands.Post.CommandType.Delete, "2");

            Console.WriteLine("Delete WO status code: " + Response.StatusCode);
        }
Пример #2
0
        public async void SendWorkingOrderRequest()
        {
            RestCommands.Post Post = new RestCommands.Post();
            RestCommands.IGResponse <Model.WorkingOrder.CreateWorkingOrderResponse> Response = await Post.Execute <Model.WorkingOrder.CreateWorkingOrderResponse>(this.Session.BaseURL + "/workingorders/otc", Session, RestCommands.Post.CommandType.Post, "2", GetWorkingOrderRequestContent());

            DealReference = Response.Response.DealReference;
            Console.WriteLine("Creation of WO Deal Ref: " + DealReference);
        }
Пример #3
0
        public async void GetTradeConfirm()
        {
            RestCommands.Post Post = new RestCommands.Post();
            RestCommands.IGResponse <Model.Trading.TradeConfirmResponse> Response = await Post.Execute <Model.Trading.TradeConfirmResponse>(this.Session.BaseURL + "/confirms" + "/" + DealReference, Session, RestCommands.Post.CommandType.Get, "1");

            if (Response.Response != null)
            {
                IGWorkingOrderData = Response.Response;
            }

            Console.WriteLine("Confirm WO Trade Status code: " + Response.Response.DealStatus);
            Console.WriteLine("DealID: " + Response.Response.DealId);
        }
Пример #4
0
        public async Task <IGResponse <T> > Execute <T>(String URL, Authentication.Session Session, CommandType commandType, String Version, Object ContentBody = null)
        {
            HttpContent SendContent = null;

            if (ContentBody != null)
            {
                String SerializeObject = JsonConvert.SerializeObject(ContentBody);

                SendContent = new StringContent(SerializeObject,
                                                Encoding.UTF8,
                                                "application/json");    //CONTENT-TYPE header
            }

            using (HttpClient c = new HttpClient())
            {
                SetDefaultHeaders(c, Session, Version);

                HttpResponseMessage response = new HttpResponseMessage();

                switch (commandType)
                {
                case CommandType.Get:
                    response = c.GetAsync(URL).Result;
                    break;

                case CommandType.Post:
                    response = c.PostAsync(URL, SendContent).Result;
                    break;

                case CommandType.Delete:
                    response = c.DeleteAsync(URL).Result;
                    break;
                }

                using (HttpContent ReceivedContent = response.Content)
                {
                    string mycontent = await ReceivedContent.ReadAsStringAsync();//.result ;

                    IGResponse <T> iGResponse = new IGResponse <T>();

                    iGResponse.Response    = JsonConvert.DeserializeObject <T>(mycontent);
                    iGResponse.StatusCode  = response.StatusCode;
                    iGResponse.httpHeaders = response.Headers;

                    return(iGResponse);
                }
            }
        }