コード例 #1
0
        public async Task <IActionResult> Execute(JObject jObj)
        {
            if (jObj == null)
            {
                throw new ArgumentNullException(nameof(jObj));
            }

            var searchUpsLocations = _requestBuilder.GetLocationsParameter(jObj);

            searchUpsLocations.Credentials = new client.Params.UpsCredentials
            {
                LicenseNumber = Constants.UpsCredentials._accessLicenseNumber,
                UserName      = Constants.UpsCredentials._userName,
                Password      = Constants.UpsCredentials._password
            };
            var result = await _upsClient.GetLocations(searchUpsLocations);

            if (result.Response != null && result.Response.Error != null)
            {
                var error = _responseBuilder.GetError(ErrorCodes.Request, result.Response.Error.ErrorDescription);
                return(_controllerHelper.BuildResponse(HttpStatusCode.BadRequest, error));
            }

            return(new OkObjectResult(_responseBuilder.GetUpsLocations(result)));
        }