Exemple #1
0
        private IResponse MultiPostcodeInformation(string postcodes, string supplierBaseUrl)
        {
            IResponse response = null;

            RestClient  client  = GetRestClient(supplierBaseUrl + SupplierResourceName);
            RestRequest request = new RestRequest();

            request.Method = Method.POST;

            SupplierBulkRequest supplierRequest = new SupplierBulkRequest();

            supplierRequest.postcodes = postcodes?.Split(",").Select(s => s.Trim()).ToArray();

            request.AddJsonBody(supplierRequest);

            SupplierBulkResponse supplierResponse = JsonConvert.DeserializeObject <SupplierBulkResponse>(client.Execute(request).Content);

            if (supplierResponse.status == (int)SupplierErrorCodes.Success)
            {
                response = MapToDTO(supplierResponse);
            }
            else
            {
                response = ErrorResponseFactory.GetErrorObject((SupplierErrorCodes)supplierResponse.status);
            }

            return(response);
        }
Exemple #2
0
        private IResponse SinglePostcodeInformation(string postcode, string supplierBaseUrl)
        {
            IResponse response = null;

            RestClient  client  = GetRestClient(supplierBaseUrl + SupplierResourceName + @"/" + postcode?.Trim());
            RestRequest request = new RestRequest();

            request.Method = Method.GET;

            SupplierResponse supplierResponse = JsonConvert.DeserializeObject <SupplierResponse>(client.Execute(request).Content);

            if (supplierResponse.status == (int)SupplierErrorCodes.Success)
            {
                response = MapToDTO(supplierResponse);
            }
            else
            {
                response = ErrorResponseFactory.GetErrorObject((SupplierErrorCodes)supplierResponse.status);
            }

            return(response);
        }