コード例 #1
0
        /// <summary>
        /// Get Unshipped Order during a time period.
        /// </summary>
        public async void GetOrderInfo()
        {
            Console.WriteLine("GetOrderInfo");

            // Create Request
            var orderreq = new GetOrderInformationRequest(new GetOrderInformationRequestCriteria()
            {
                Status          = Newegg.Marketplace.SDK.Order.Model.OrderStatus.Unshipped,
                Type            = OrderInfoType.All,
                OrderDateFrom   = "2016-01-01 09:30:47",
                OrderDateTo     = "2017-12-17 09:30:47",
                OrderDownloaded = 0
            });

            // Send your request and get response
            var response = await ordercall.GetOrderInformation(null, orderreq);

            // Get data from the response
            GetOrderInformationResponseBody info = response.GetResponseBody();

            Console.WriteLine("info: " + info.OrderInfoList[0].OrderNumber + " " +
                              info.OrderInfoList[0].ShipToFirstName + " " + info.OrderInfoList[0].ShipToZipCode + " " + info.OrderInfoList[0].ShipToCountryCode);

            // Use the data pre you business
            Console.WriteLine(string.Format("There are {0} order(s) in the result.", info.OrderInfoList.Count.ToString()));
        }
コード例 #2
0
        public async Task GetOrderInformation()
        {
            var orderreq = new GetOrderInformationRequest(new GetOrderInformationRequestCriteria()
            {
                OrderNumberList = new string[] { "126239540" },
                Status          = OrderStatus.Invoiced,
                Type            = OrderInfoType.All,
                OrderDateFrom   = "2018-01-01 09:30:47",
                OrderDateTo     = "2018-12-17 09:30:47",
                OrderDownloaded = 0
            });

            var result = await fakeapi.GetOrderInformation(null, orderreq);

            Assert.IsType <GetOrderInformationResponse>(result);
            //Assert.Equal("126239540", result.ResponseBody.OrderInfoList[0].OrderNumber);
        }
コード例 #3
0
        public async Task GetOrderInformation_Json()
        {
            var orderreq = new GetOrderInformationRequest(new GetOrderInformationRequestCriteria()
            {
                OrderNumberList = new string[] { "41473642", "159243598" },
                Type            = OrderInfoType.All,
                OrderDateFrom   = "2018-01-01 09:30:47",
                OrderDateTo     = "2018-12-17 09:30:47",
                OrderDownloaded = 0
            });

            var result = await fakeapi_json.GetOrderInformation(null, orderreq);

            Assert.IsType <GetOrderInformationResponse>(result);
            Assert.True(result.ResponseBody.OrderInfoList.Count == 2);
        }
コード例 #4
0
        public async Task <GetOrderInformationResponse> CallApi()
        {
            string mockPath = HttpContext.Current.Server.MapPath(@"~/mocks/");

            // fix the formatting
            mockPath = mockPath.Replace(@"\", @"\\");

            string jsonString = @"{
  ""SellerID"": ""****"",
  ""Credentials"": {
                ""Authorization"": ""********************************"",
    ""SecretKey"": ""*******-****-****-****-************""
  },
  ""MockPath"": """ + mockPath + @""",
  ""Connection"": {
                ""RequestTimeoutMs"": 5000,
    ""AttemptsTimes"": 5,
    ""RetryIntervalMs"": 1000
  },
  ""APIFormat"": ""XML"",
  ""LogLevel"": ""Debug""
}";

            System.Diagnostics.Debug.WriteLine(jsonString);


            //APIConfig config = APIConfig.FromJsonFile(HttpContext.Current.Server.MapPath(@"~/Newegg.json"));
            APIConfig config = APIConfig.FromJson(jsonString);
            APIClient test   = new APIClient(config)
            {
                SimulationEnabled = true
            };

            orderCall = new OrderCall(test);
            var orderReq = new GetOrderInformationRequest(new GetOrderInformationRequestCriteria()
            {
                Status          = Newegg.Marketplace.SDK.Order.Model.OrderStatus.Unshipped,
                Type            = OrderInfoType.All,
                OrderDateFrom   = "2016-01-01 09:30:47",
                OrderDateTo     = "2017-12-17 09:30:47",
                OrderDownloaded = 0
            });

            return(await orderCall.GetOrderInformation(null, orderReq));
        }
コード例 #5
0
        public async Task GetOrderInformation_JSON()
        {
            var orderreq = new GetOrderInformationRequest(new GetOrderInformationRequestCriteria()
            {
                OrderNumberList = new string[] { "287811844" },
                Status          = OrderStatus.Voided,
                Type            = OrderInfoType.All,
                OrderDateFrom   = "2011-01-01 00:00:00",
                OrderDateTo     = "2019-01-01 00:00:00",
                OrderDownloaded = 0,
                CountryCode     = "USA",
                PremierOrder    = 0
            });

            var result = await fakeapi_json.GetOrderInformation(null, orderreq);

            Assert.IsType <GetOrderInformationResponse>(result);
            //Assert.Equal("287811844", result.ResponseBody.OrderInfoList[0].OrderNumber);
        }
コード例 #6
0
        public IActionResult Index()
        {
            APIConfig config       = APIConfig.FromJsonFile("newegg");
            APIClient client       = new APIClient(config);
            OrderCall ordercall    = new OrderCall(client);
            var       requestModel = new GetOrderInformationRequest()
            {
                OperationType = "GetOrderInfoRequest",
                RequestBody   = new GetOrderInformationRequestBody()
                {
                    PageIndex       = 0,
                    PageSize        = 20,
                    RequestCriteria = new GetOrderInformationRequestCriteria()
                    {
                    }
                }
            };
            var response = ordercall.GetOrderInformation(304, requestModel);

            return(View(response));
        }