public virtual void SetupConfiguration <T>(T request, IUPSConfiguration configuration) where T : IShipRequest { request.LabelSpecification = request?.LabelSpecification ?? configuration?.LabelConfiguration?.LabelSpecification ?? Configuration?.LabelConfiguration?.LabelSpecification; request.Request = request?.Request ?? new RequestType() { RequestOption = new string[] { "validate" }, TransactionReference = new TransactionReferenceType { CustomerContext = configuration?.Authentication?.CustomerContext ?? Configuration.Authentication.CustomerContext } }; if (request.Shipment != null) { request.Shipment.Shipper = request?.Shipment?.Shipper ?? configuration?.ShipperConfiguration?.Shipper ?? Configuration?.ShipperConfiguration?.Shipper; request.Shipment.PaymentInformation = request?.Shipment?.PaymentInformation ?? configuration?.PaymentInfoConfiguration?.PaymentInformation ?? Configuration?.PaymentInfoConfiguration?.PaymentInformation; } }
public async Task <INativeLabelRecoveryResponse> ProcessLabelRecoveryAsync(ILabelRecoveryRequest request, IUPSConfiguration configuration = null) { UpsLabelRecovery.UPSSecurity upsSecurity = configuration != null?SetupAuthentication <UpsLabelRecovery.UPSSecurity>(configuration?.Authentication) : UPSLabelRecoveryAuthenticationDetail; request.Request = request?.Request ?? new RequestType() { RequestOption = new string[] { "validate" }, TransactionReference = new TransactionReferenceType { CustomerContext = configuration?.Authentication?.CustomerContext ?? Configuration.Authentication.CustomerContext } }; var upsRequest = BuildRequest <LabelRecoveryRequest, UpsLabelRecovery.LabelRecoveryRequest>((LabelRecoveryRequest)request, LabelRecoveryMapperConfiguration); if (AppSetupConfiguration.WriteXmlRequest) { WriteXML(upsRequest); } //var client = new UpsLabelRecovery.PortTypeClient(); string endPointUrl = AppSetupConfiguration.IsProductionEnvironment ? AppSetupConfiguration?.Urls?.ProductionEndPoint?.LabelRecoveryServiceUrl : AppSetupConfiguration?.Urls?.TestEndPoint?.LabelRecoveryServiceUrl; var client = new UpsLabelRecovery.PortTypeClient(endPointUrl, AppSetupConfiguration.TimeOut, AppSetupConfiguration?.UserId, AppSetupConfiguration?.Password); var response = await client.ProcessLabelRecoveryAsync(upsSecurity, upsRequest); if (AppSetupConfiguration.WriteXmlResponse) { WriteXML(response); } var nativeResponse = BuildResponse <UpsLabelRecovery.LabelRecoveryResponse1, NativeLabelRecoveryResponse>(response, LabelRecoveryMapperConfiguration); if (nativeResponse.IsSuccessful && LabelConfiguration.SaveLabelFile && AppSetupConfiguration.SaveLabelFileAfterLabelRecoverySuccess) { SaveLabels(response?.LabelRecoveryResponse?.Items, out List <string> labelFiles); nativeResponse.LabelFiles = labelFiles; } nativeResponse.Message = nativeResponse.IsSuccessful ? string.Format(MessageConfiguration.SuccessfulLabelRecovery, request?.TrackingNumber) : string.Format(MessageConfiguration.FailedLabelRecovery, request?.TrackingNumber); return(nativeResponse); }
public async Task <INativeShipConfirmResponse> ProcessShipConfirmAsync(IShipConfirmRequest request, IUPSConfiguration configuration = null) { Ship.UPSSecurity upsSecurity = configuration != null?SetupAuthentication <Ship.UPSSecurity>(configuration?.Authentication) : UPSShipmentAuthenticationDetail; SetupConfiguration(request, configuration); var shipmentRequest = BuildRequest <ShipConfirmRequest, Ship.ShipConfirmRequest>((ShipConfirmRequest)request, ShipmentMapperConfiguration); //var client = new Ship.ShipPortTypeClient(); string endPointUrl = AppSetupConfiguration.IsProductionEnvironment ? AppSetupConfiguration?.Urls?.ProductionEndPoint?.ShipServiceUrl : AppSetupConfiguration?.Urls?.TestEndPoint?.ShipServiceUrl; var client = new Ship.ShipPortTypeClient(endPointUrl, AppSetupConfiguration.TimeOut, AppSetupConfiguration?.UserId, AppSetupConfiguration?.Password); if (AppSetupConfiguration.WriteXmlRequest) { WriteXML(shipmentRequest); } var response = await client.ProcessShipConfirmAsync(upsSecurity, shipmentRequest); if (AppSetupConfiguration.WriteXmlResponse) { WriteXML(response.ShipConfirmResponse); } var nativeResponse = BuildResponse <Ship.ShipConfirmResponse1, NativeShipConfirmResponse>(response, ShipmentMapperConfiguration); nativeResponse.Message = nativeResponse.IsSuccessful ? string.Format(MessageConfiguration.SuccessfulShipConfirmCreation, nativeResponse.MasterTrackingReferenceNumber) : string.Format(MessageConfiguration.FailedShipConfirmCreation); return(nativeResponse); }
public async Task <INativePickupGetServiceCenterFacilitiesResponse> ProcessPickupGetServiceCenterFacilitiesAsync(IPickupGetServiceCenterFacilitiesRequest request, IUPSConfiguration configuration = null) { Pickup.UPSSecurity upsSecurity = configuration != null?SetupAuthentication <Pickup.UPSSecurity>(configuration?.Authentication) : UPSPickupAuthenticationDetail; request.Request = request?.Request ?? new RequestType() { RequestOption = new string[] { "validate" }, TransactionReference = new TransactionReferenceType { CustomerContext = configuration?.Authentication?.CustomerContext ?? Configuration.Authentication.CustomerContext } }; var pickupRequest = BuildRequest <PickupGetServiceCenterFacilitiesRequest, Pickup.PickupGetServiceCenterFacilitiesRequest>((PickupGetServiceCenterFacilitiesRequest)request, PickupMapperConfiguration); //var client = new Pickup.PickupPortTypeClient(); string endPointUrl = AppSetupConfiguration.IsProductionEnvironment ? AppSetupConfiguration?.Urls?.ProductionEndPoint?.PickupServiceUrl : AppSetupConfiguration?.Urls?.TestEndPoint?.PickupServiceUrl; var client = new Pickup.PickupPortTypeClient(endPointUrl, AppSetupConfiguration.TimeOut, AppSetupConfiguration?.UserId, AppSetupConfiguration?.Password); if (AppSetupConfiguration.WriteXmlRequest) { WriteXML(pickupRequest); } var response = await client.ProcessPickupGetServiceCenterFacilitiesAsync(upsSecurity, pickupRequest); if (AppSetupConfiguration.WriteXmlResponse) { WriteXML(response); } var nativeResponse = BuildResponse <Pickup.PickupGetServiceCenterFacilitiesResponse1, NativePickupGetServiceCenterFacilitiesResponse>(response, PickupMapperConfiguration); nativeResponse.Message = nativeResponse.IsSuccessful ? MessageConfiguration.SuccessfulGetServiceCenterFacilities : MessageConfiguration.FailedGetServiceCenterFacilities; return(nativeResponse); }
public async Task <INativePickupCreationResponse> ProcessPickupCreationAsync(IPickupCreationRequest request, IUPSConfiguration configuration = null) { Pickup.UPSSecurity upsSecurity = configuration != null?SetupAuthentication <Pickup.UPSSecurity>(configuration?.Authentication) : UPSPickupAuthenticationDetail; request.Request = request?.Request ?? new RequestType() { RequestOption = new string[] { "Pickup" }, TransactionReference = new TransactionReferenceType { CustomerContext = configuration?.Authentication?.CustomerContext ?? Configuration.Authentication.CustomerContext } }; var pickupRequest = BuildRequest <PickupCreationRequest, Pickup.PickupCreationRequest>((PickupCreationRequest)request, PickupMapperConfiguration); //var client = new Pickup.PickupPortTypeClient(); string endPointUrl = AppSetupConfiguration.IsProductionEnvironment ? AppSetupConfiguration?.Urls?.ProductionEndPoint?.PickupServiceUrl : AppSetupConfiguration?.Urls?.TestEndPoint?.PickupServiceUrl; var client = new Pickup.PickupPortTypeClient(endPointUrl, AppSetupConfiguration.TimeOut, AppSetupConfiguration?.UserId, AppSetupConfiguration?.Password); if (AppSetupConfiguration.WriteXmlRequest) { WriteXML(pickupRequest); } //var xsdFiles = new Dictionary<string, string>(); //xsdFiles.Add(@"E:\POC\UPS\Pickup\PickupforPACKAGEWebService\SCHEMAS-WSDLs\PickupWebServiceSchema.xsd", "http://www.ups.com/XMLSchema/XOLTWS/Pickup/v1.1"); //xsdFiles.Add(@"E:\POC\UPS\Pickup\PickupforPACKAGEWebService\SCHEMAS-WSDLs\common.xsd", "http://www.ups.com/XMLSchema/XOLTWS/Common/v1.0"); //xsdFiles.Add(@"E:\POC\UPS\Pickup\PickupforPACKAGEWebService\SCHEMAS-WSDLs\Error1.1.xsd", "http://www.ups.com/XMLSchema/XOLTWS/Error/v1.1"); //xsdFiles.Add(@"E:\POC\UPS\Pickup\PickupforPACKAGEWebService\SCHEMAS-WSDLs\UPSSecurity.xsd", "http://www.ups.com/XMLSchema/XOLTWS/UPSS/v1.0"); //var isValid = Validate(pickupRequest, xsdFiles, out string errorMessage); //if (!isValid) // throw new System.Exception(errorMessage); var response = await client.ProcessPickupCreationAsync(upsSecurity, pickupRequest); if (Configuration.AppSetupConfiguration.WriteXmlResponse) { WriteXML(response); } var nativeResponse = BuildResponse <Pickup.PickupCreationResponse1, NativePickupCreationResponse>(response, PickupMapperConfiguration); nativeResponse.Message = nativeResponse.IsSuccessful ? string.Format(MessageConfiguration.SuccessfulPickupCreation, nativeResponse?.PickupConfirmationNumber) : string.Format(MessageConfiguration.FailedPickupCreation); return(nativeResponse); }
public async Task <INativeVoidShipmentResponse> ProcessVoidAsync(IVoidShipmentRequest request, IUPSConfiguration configuration = null) { Void.UPSSecurity upsSecurity = configuration != null?SetupAuthentication <Void.UPSSecurity>(configuration?.Authentication) : UPSVoidAuthenticationDetail; request.Request = request?.Request ?? new RequestType() { RequestOption = new string[] { "validate" }, TransactionReference = new TransactionReferenceType { CustomerContext = configuration?.Authentication?.CustomerContext ?? Configuration.Authentication.CustomerContext } }; var voidRequest = BuildRequest <VoidShipmentRequest, Void.VoidShipmentRequest>((VoidShipmentRequest)request, VoidMapperConfiguration); //var client = new Void.VoidPortTypeClient(); string endPointUrl = AppSetupConfiguration.IsProductionEnvironment ? AppSetupConfiguration?.Urls?.ProductionEndPoint?.VoidServiceUrl : AppSetupConfiguration?.Urls?.TestEndPoint?.VoidServiceUrl; var client = new Void.VoidPortTypeClient(endPointUrl, AppSetupConfiguration.TimeOut, AppSetupConfiguration?.UserId, AppSetupConfiguration?.Password); if (AppSetupConfiguration.WriteXmlRequest) { WriteXML(voidRequest); } var response = await client.ProcessVoidAsync(upsSecurity, voidRequest); if (AppSetupConfiguration.WriteXmlResponse) { WriteXML(response); } var nativeResponse = BuildResponse <Void.VoidShipmentResponse1, NativeVoidShipmentResponse>(response, VoidMapperConfiguration); if (request?.VoidShipment?.TrackingNumber?.Count() > 0) { if (nativeResponse.IsSuccessful) { if (nativeResponse?.DeletedPackageTrackingNumberList?.Count > 0) { nativeResponse.Message = string.Format(MessageConfiguration.SuccessfulPackageDeletion, request?.VoidShipment?.ShipmentIdentificationNumber, nativeResponse?.DeletedPackageTrackingNumbers); } if (nativeResponse?.AlreadyDeletedPackageTrackingNumberList?.Count > 0) { nativeResponse.Message += string.Format(MessageConfiguration.AlreadyDeletedPackage, request?.VoidShipment?.ShipmentIdentificationNumber, nativeResponse?.AlreadyDeletedPackageTrackingNumbers); } if (nativeResponse?.FailedDeletionPackageTrackingNumberList?.Count > 0) { nativeResponse.Message += string.Format(MessageConfiguration.FailedPackageDeletion, request?.VoidShipment?.ShipmentIdentificationNumber, nativeResponse?.FailedDeletionPackageTrackingNumbers); } } else { nativeResponse.Message = string.Format(MessageConfiguration.FailedPackageDeletion, request?.VoidShipment?.ShipmentIdentificationNumber, request?.VoidShipment?.TrackingNumber); } } else { nativeResponse.Message = nativeResponse.IsSuccessful && nativeResponse.IsDeleted ? string.Format(MessageConfiguration.SuccessfulShipmentDeletion, request?.VoidShipment?.ShipmentIdentificationNumber) : string.Format(MessageConfiguration.FailedShipmentDeletion, request?.VoidShipment?.ShipmentIdentificationNumber); } return(nativeResponse); }
public async Task <INativeTrackResponse> ProcessTrackAsync(ITrackCriteria criteria, IUPSConfiguration configuration = null) { Track.UPSSecurity upsSecurity = configuration != null?SetupAuthentication <Track.UPSSecurity>(configuration?.Authentication) : UPSTrackAuthenticationDetail; var trackRequest = new Track.TrackRequest { InquiryNumber = criteria.TrackingReferenceNumber, PickupDateRange = new Track.PickupDateRangeType { BeginDate = criteria?.PickupDateRange?.BeginDate, EndDate = criteria?.PickupDateRange?.EndDate }, ReferenceNumber = new Track.ReferenceNumberType { Code = criteria?.ReferenceNumber?.Code, Value = criteria?.ReferenceNumber?.Value }, ShipperNumber = criteria?.ShipperNumber, Request = criteria?.RequestType != null ? new Track.RequestType { RequestOption = criteria?.RequestType?.RequestOption, SubVersion = criteria?.RequestType?.SubVersion, TransactionReference = criteria?.RequestType?.TransactionReference?.CustomerContext != null ? new Track.TransactionReferenceType { CustomerContext = criteria?.RequestType?.TransactionReference?.CustomerContext } : UPSTrackTransactionReference } : new Track.RequestType() { RequestOption = new string[] { "validate" }, TransactionReference = new Track.TransactionReferenceType { CustomerContext = configuration?.Authentication?.CustomerContext ?? Configuration.Authentication.CustomerContext } }, TrackingOption = criteria?.TrackingOption }; trackRequest.TrackingOption = trackRequest?.TrackingOption ?? configuration?.TrackConfiguration?.TrackingOption ?? Configuration?.TrackConfiguration?.TrackingOption; Track.TrackPortTypeClient client = new Track.TrackPortTypeClient(); if (Configuration.AppSetupConfiguration.WriteXmlRequest) { WriteXML(trackRequest); } var response = await client.ProcessTrackAsync(upsSecurity, trackRequest); if (Configuration.AppSetupConfiguration.WriteXmlResponse) { WriteXML(response); } //var nativeResponse = BuildNativeTrackResponse(response); var nativeResponse = BuildResponse <Track.TrackResponse1, NativeTrackResponse>(response, TrackShipmentMapperConfiguration); nativeResponse.Message = nativeResponse.IsSuccessful ? string.Format(MessageConfiguration.SuccessfulShipmentTracking, criteria?.TrackingReferenceNumber) : string.Format(MessageConfiguration.FailedShipmentTracking, criteria?.TrackingReferenceNumber); return(nativeResponse); }
public async Task <INativeTrackResponse> ProcessTrackAsync(ITrackRequest request, IUPSConfiguration configuration = null) { Track.UPSSecurity upsSecurity = configuration != null?SetupAuthentication <Track.UPSSecurity>(configuration?.Authentication) : UPSTrackAuthenticationDetail; request.Request = request?.Request ?? new RequestType() { RequestOption = new string[] { "validate" }, TransactionReference = new TransactionReferenceType { CustomerContext = configuration?.Authentication?.CustomerContext ?? Configuration.Authentication.CustomerContext } }; request.TrackingOption = request?.TrackingOption ?? configuration?.TrackConfiguration?.TrackingOption ?? Configuration?.TrackConfiguration?.TrackingOption; //var trackRequest = BuildTrackRequest(request); var trackRequest = BuildRequest <TrackRequest, Track.TrackRequest>((TrackRequest)request, TrackShipmentMapperConfiguration); if (AppSetupConfiguration.WriteXmlRequest) { WriteXML(trackRequest); } //var client = new Track.TrackPortTypeClient(); string endPointUrl = AppSetupConfiguration.IsProductionEnvironment ? AppSetupConfiguration?.Urls?.ProductionEndPoint?.TrackServiceUrl : AppSetupConfiguration?.Urls?.TestEndPoint?.TrackServiceUrl; var client = new Track.TrackPortTypeClient(endPointUrl, AppSetupConfiguration.TimeOut, AppSetupConfiguration?.UserId, AppSetupConfiguration?.Password); var response = await client.ProcessTrackAsync(upsSecurity, trackRequest); if (AppSetupConfiguration.WriteXmlResponse) { WriteXML(response); } //var nativeResponse = BuildNativeTrackResponse(response); var nativeResponse = BuildResponse <Track.TrackResponse1, NativeTrackResponse>(response, TrackShipmentMapperConfiguration); nativeResponse.Message = nativeResponse.IsSuccessful ? string.Format(MessageConfiguration.SuccessfulShipmentTracking, request?.InquiryNumber) : string.Format(MessageConfiguration.FailedShipmentTracking, request?.InquiryNumber); return(nativeResponse); }