Пример #1
0
        public string GetDownload(ConfirmRequest downloadReqeust)
        {
            var dateTime  = DateTime.Now.ToUniversalTime();
            var secure    = new ParamSecure(Config.Secret, Config.ApiKey, dateTime, downloadReqeust);
            var signature = secure.Sign();

            var client = new RestClient(Config.GrailTravelHost);

            Console.WriteLine(downloadReqeust.GetURL());
            var request = new RestRequest($"/api/v2/online_orders/{downloadReqeust.online_order_id}/online_tickets?online_order_id={downloadReqeust.online_order_id}", Method.GET);

            request.AddHeader("From", Config.ApiKey);
            request.AddHeader("Date", dateTime.ToString("r"));
            request.AddHeader("Authorization", signature);

            var response = client.Get(request);

            return(response.Content);
        }
Пример #2
0
        public string PostConfirm(ConfirmRequest confirmReqeust)
        {
            var dateTime  = DateTime.Now.ToUniversalTime();
            var secure    = new ParamSecure(Config.Secret, Config.ApiKey, dateTime, confirmReqeust);
            var signature = secure.Sign();

            var client = new RestClient(Config.GrailTravelHost);

            Console.WriteLine(confirmReqeust.GetURL());
            var request = new RestRequest($"/api/v2/online_orders/{confirmReqeust.online_order_id}/online_confirmations", Method.POST);

            request.AddHeader("From", Config.ApiKey);
            request.AddHeader("Date", dateTime.ToString("r"));
            request.AddHeader("Authorization", signature);

            request.RequestFormat = DataFormat.Json;
            request.AddBody(confirmReqeust);

            var response = client.Post(request);

            return(response.Content);
        }