public void Create_DataCorrect_ItemCreated() { var user = UserFaker.Create(); var accessToken = Rand.RandomString(); var id = ServiceAccessToken.Create(user, accessToken, ServiceType.GitHub); var token = ServiceAccessToken.Find(id); Assert.NotNull(token); }
public LabelRecoveryRequestModel PopulateRequestData(CustomSettings customSettings, string trackingNumber) { // UPS Security UsernameToken usernameToken = new UsernameToken(); usernameToken.Username = customSettings.UPSSecurity_UserToken_Username; usernameToken.Password = customSettings.UPSSecurity_UserToken_Password; ServiceAccessToken serviceAccessToken = new ServiceAccessToken(); serviceAccessToken.AccessLicenseNumber = customSettings.UPSSecurity_ServiceAccessToken_AccessLicenseNumber; UPSSecurity UPSSecurity = new UPSSecurity(); UPSSecurity.UsernameToken = usernameToken; UPSSecurity.ServiceAccessToken = serviceAccessToken; // UPS Security -END // Label Specification LabelImageFormat labelImageFormat = new LabelImageFormat(); labelImageFormat.Code = "GIF"; LabelSpecification labelSpecification = new LabelSpecification(); labelSpecification.LabelImageFormat = labelImageFormat; labelSpecification.HttpUserAgent = "Mozilla/4.5"; // Label Specification - END Translate translate = new Translate(); translate.LanguageCode = "eng"; translate.DialectCode = "US"; translate.Code = "01"; LabelRecoveryRequest labelRecoveryRequest = new LabelRecoveryRequest(); labelRecoveryRequest.LabelSpecification = labelSpecification; labelRecoveryRequest.Translate = translate; labelRecoveryRequest.TrackingNumber = trackingNumber; // the below tracking number is allowed on the UPS test environment. //labelRecoveryRequest.TrackingNumber = "1Z12345E8791315413"; LabelRecoveryRequestModel labelRecoveryModel = new LabelRecoveryRequestModel(); labelRecoveryModel.UPSSecurity = UPSSecurity; labelRecoveryModel.LabelRecoveryRequest = labelRecoveryRequest; return(labelRecoveryModel); }
public static ServiceAccessToken Find(int id) { return(ServiceAccessToken.Find(id)); }
public static ServiceAccessToken Create(UserModel user, string accessToken, ServiceType serviceType) { return(Find(ServiceAccessToken.Create(user, accessToken, serviceType))); }
public static ServiceAccessToken Find(UserModel user, ServiceType serviceType) { return(ServiceAccessToken.Find(user, serviceType)); }
public static ServiceAccessToken FindBy(string col, string val) { return(ServiceAccessToken.FindBy(col, val)); }
public static ServiceAccessToken FindByGuid(string guid) { return(ServiceAccessToken.FindByGuid(guid)); }
/// <summary> Установка сервисного токена </summary> public void SetServiceToken(string token, int appid) { stoken = new ServiceAccessToken(token, appid); }
public ShipRequestModel PopulateRequestData(CustomSettings customSettings, AddRmaResult result, IUnitOfWork unitOfWork) { // UPS Security UsernameToken usernameToken = new UsernameToken(); usernameToken.Username = customSettings.UPSSecurity_UserToken_Username; usernameToken.Password = customSettings.UPSSecurity_UserToken_Password; ServiceAccessToken serviceAccessToken = new ServiceAccessToken(); serviceAccessToken.AccessLicenseNumber = customSettings.UPSSecurity_ServiceAccessToken_AccessLicenseNumber; UPSSecurity UPSSecurity = new UPSSecurity(); UPSSecurity.UsernameToken = usernameToken; UPSSecurity.ServiceAccessToken = serviceAccessToken; // UPS Security -END // Request Object TransactionReference transactionReference = new TransactionReference(); transactionReference.CustomerContext = result.OrderHistory.ErpOrderNumber; Request request = new Request(); request.RequestOption = "nonvalidate"; request.TransactionReference = transactionReference; // Request Object -END // Shipper Object Shipper shipper = new Shipper(); shipper.Name = string.IsNullOrEmpty(result.OrderHistory.STCompanyName) ? result.OrderHistory.BTCompanyName : result.OrderHistory.STCompanyName; shipper.ShipperNumber = customSettings.Shipper_ShipperNumber; Address shipToAddress = new Address(); shipToAddress.AddressLine = string.IsNullOrEmpty(result.OrderHistory.STAddress1) ? result.OrderHistory.BTAddress1 : result.OrderHistory.STAddress1; shipToAddress.City = string.IsNullOrEmpty(result.OrderHistory.STCity) ? result.OrderHistory.BTCity : result.OrderHistory.STCity; shipToAddress.StateProvinceCode = GetStateCode(result.OrderHistory, unitOfWork); shipToAddress.PostalCode = string.IsNullOrEmpty(result.OrderHistory.STPostalCode) ? result.OrderHistory.BTPostalCode : result.OrderHistory.STPostalCode; var country = result.OrderHistory.CustomerNumber.ElementAt(0) == '1' ? "US": "CA"; shipToAddress.CountryCode = country; shipper.Address = shipToAddress; // Shipper Object - END // Website address same for both US and CA Ship shipTo = new Ship(); shipTo.Name = "Brasseler USA"; shipTo.AttentionName = "RETURNS DEPT"; Phone shipTophone = new Phone(); shipTophone.Number = "9129258525"; shipTo.Phone = shipTophone; Address websiteAddress = new Address(); websiteAddress.AddressLine = "1 Brasseler Blvd"; websiteAddress.City = "Savannah"; websiteAddress.StateProvinceCode = "GA"; websiteAddress.PostalCode = "31419"; websiteAddress.CountryCode = "US"; shipTo.Address = websiteAddress; // Website address same for both US and CA - END // Ship From Addresses Ship shipFrom = new Ship(); shipFrom.Name = string.IsNullOrEmpty(result.OrderHistory.STCompanyName) ? result.OrderHistory.BTCompanyName : result.OrderHistory.STCompanyName; Phone shipFromphone = new Phone(); shipFromphone.Number = "9129258525"; shipFrom.Phone = shipFromphone; Address shipFromAddress = new Address(); shipFromAddress.AddressLine = string.IsNullOrEmpty(result.OrderHistory.STAddress1) ? result.OrderHistory.BTAddress1 : result.OrderHistory.STAddress1; shipFromAddress.City = string.IsNullOrEmpty(result.OrderHistory.STCity) ? result.OrderHistory.BTCity : result.OrderHistory.STCity; shipFromAddress.StateProvinceCode = GetStateCode(result.OrderHistory, unitOfWork); shipFromAddress.PostalCode = string.IsNullOrEmpty(result.OrderHistory.STPostalCode) ? result.OrderHistory.BTPostalCode : result.OrderHistory.STPostalCode; shipFromAddress.CountryCode = country; shipFrom.Address = shipFromAddress; // Ship From Addresses - END // Payment Information BillShipper billShipper = new BillShipper(); billShipper.AccountNumber = customSettings.PaymentInformation_ShipmentCharge_AccountNumber; ShipmentCharge shipmentCharge = new ShipmentCharge(); shipmentCharge.Type = "01"; shipmentCharge.BillShipper = billShipper; PaymentInformation paymentInformation = new PaymentInformation(); paymentInformation.ShipmentCharge = shipmentCharge; // Payment Information - END // Service Object LabelImageFormat service = new LabelImageFormat(); service.Code = "03"; service.Description = "Ground"; // Service Object - END // Return Service Object LabelImageFormat retrunService = new LabelImageFormat(); retrunService.Code = "9"; retrunService.Description = "Print Return Label"; // Return Service Object - END // Package Object Package package = new Package(); List <ReferenceNumber> referenceNumber = new List <ReferenceNumber>(); ReferenceNumber erpReferenceNumber = new ReferenceNumber(); erpReferenceNumber.Code = "01"; erpReferenceNumber.Value = "Customer #: " + (string.IsNullOrEmpty(result.OrderHistory.CustomerSequence) ? result.OrderHistory.CustomerNumber : result.OrderHistory.CustomerSequence); referenceNumber.Add(erpReferenceNumber); ReferenceNumber invoiceRefNumber = new ReferenceNumber(); invoiceRefNumber.Code = "02"; invoiceRefNumber.Value = "Invoice #: " + GetInvoiceNumber(result.OrderHistory.ErpOrderNumber, unitOfWork); referenceNumber.Add(invoiceRefNumber); LabelImageFormat packaging = new LabelImageFormat(); packaging.Code = "02"; packaging.Description = "Description"; LabelImageFormat unitOfMeasurement = new LabelImageFormat(); unitOfMeasurement.Code = "LBS"; unitOfMeasurement.Description = "Pounds"; PackageWeight packageWeight = new PackageWeight(); packageWeight.UnitOfMeasurement = unitOfMeasurement; packageWeight.Weight = "1"; package.ReferenceNumber = referenceNumber; package.Description = "Dental instruments/equipment"; package.Packaging = packaging; package.PackageWeight = packageWeight; // Package Object - END // Shipment Object Shipment shipment = new Shipment(); shipment.Description = "Return Label"; shipment.Shipper = shipper; shipment.ShipTo = shipTo; shipment.ShipFrom = shipFrom; shipment.PaymentInformation = paymentInformation; shipment.Service = service; shipment.ReturnService = retrunService; shipment.Package = package; // Shipment Object - END // Label Specification LabelImageFormat labelImageFormat = new LabelImageFormat(); labelImageFormat.Code = "GIF"; labelImageFormat.Description = "GIF"; LabelSpecification labelSpecification = new LabelSpecification(); labelSpecification.LabelImageFormat = labelImageFormat; labelSpecification.HttpUserAgent = "Mozilla/4.5"; // Label Specification - END // Shipment Request ShipmentRequest shipmentRequest = new ShipmentRequest(); shipmentRequest.Request = request; shipmentRequest.Shipment = shipment; shipmentRequest.LabelSpecification = labelSpecification; // Shipment Request - END // RMA Model ShipRequestModel shipRequestModel = new ShipRequestModel(); shipRequestModel.UPSSecurity = UPSSecurity; shipRequestModel.ShipmentRequest = shipmentRequest; // RMA Model - END return(shipRequestModel); }