Exemplo n.º 1
0
        private PostcodeDetails MapToDTO(SupplierResponse supplierResponse)
        {
            PostcodeDetails details = new PostcodeDetails();

            details.Postcode              = supplierResponse.result.postcode;
            details.Coordinates           = new Coordinates();
            details.Coordinates.Longitude = supplierResponse.result.longitude;
            details.Coordinates.Latitude  = supplierResponse.result.latitude;

            return(details);
        }
Exemplo n.º 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);
        }