public void Init() { this._credentials = base.ReadCredentials(); if (_credentials != null) { _shipStationService = this.ShipStationFactory.CreateServiceV2(this._credentials); } }
public WebRequestServices( ShipStationCredentials credentials ) { this._credentials = credentials; this.HttpClient = new HttpClient(); this.HttpClient.Timeout = TimeSpan.FromMinutes( MaxHttpRequestTimeoutInMinutes ); SetAuthorizationHeader(); this.InitSecurityProtocol(); }
public IShipStationService CreateServiceV2(ShipStationCredentials credentials, ShipStationTimeouts operationsTimeouts) { Condition.Requires(credentials, "credentials").IsNotNull(); if (string.IsNullOrWhiteSpace(credentials.PartnerKey)) { credentials.PartnerKey = this._partnerKey; } return(new ShipStationService(credentials, operationsTimeouts)); }
public void GivenInvalidCredentials_WhenGetOrdersAsyncIsCalled_ThenAuthorizationExceptionIsExpected() { var invalidCredentials = new ShipStationCredentials(this._credentials.ApiKey + Guid.NewGuid().ToString(), this._credentials.ApiSecret, this._credentials.PartnerKey); var service = this.ShipStationFactory.CreateServiceV2(invalidCredentials); var ex = Assert.Throws <AggregateException>(() => { service.GetOrdersAsync(DateTime.UtcNow.AddDays(-10), DateTime.UtcNow, CancellationToken.None).Wait(); }); ex.Should().NotBeNull(); ex.InnerException.Should().NotBeNull(); ex.InnerException.GetType().Should().Be(typeof(ShipStationUnauthorizedException)); }
public void Init() { const string credentialsFilePath = @"..\..\Files\ShipStationCredentials.csv"; Log.Logger = new LoggerConfiguration() .Destructure.ToMaximumDepth(100) .MinimumLevel.Verbose() .WriteTo.Console().CreateLogger(); NetcoLogger.LoggerFactory = new SerilogLoggerFactory(Log.Logger); var cc = new CsvContext(); var testConfig = cc.Read <TestConfig>(credentialsFilePath, new CsvFileDescription { FirstLineHasColumnNames = true }).FirstOrDefault(); if (testConfig != null) { this._credentials = new ShipStationCredentials(testConfig.ApiKey, testConfig.ApiSecret); } }
public async Task GivenInvalidCredentials_WhenUpdateOrdersAsyncIsCalled_ThenAuthorizationExceptionIsExpected() { var existingOrderId = "592317819"; var workingService = base.ShipStationFactory.CreateServiceV2(this._credentials); var order = await workingService.GetOrderByIdAsync(existingOrderId, CancellationToken.None); order.InternalNotes = "Some random note placed here #" + Guid.NewGuid().ToString(); var invalidCredentials = new ShipStationCredentials(this._credentials.ApiKey + Guid.NewGuid().ToString(), this._credentials.ApiSecret, this._credentials.PartnerKey); var service = this.ShipStationFactory.CreateServiceV2(invalidCredentials); var ex = Assert.Throws <AggregateException>(() => { service.UpdateOrderAsync(order, CancellationToken.None).Wait(); }); ex.Should().NotBeNull(); ex.InnerException.Should().NotBeNull(); ex.InnerException.GetType().Should().Be(typeof(ShipStationUnauthorizedException)); }
public ShipStationService(ShipStationCredentials credentials) : this(credentials, new ShipStationTimeouts()) { }
public ShipStationService(ShipStationCredentials credentials, ShipStationTimeouts timeouts, IWebRequestServices webServices = null) { this._webRequestServices = webServices ?? new WebRequestServices(credentials); this._timeouts = timeouts; }
public void Init() { this._credentials = base.ReadCredentials(); }
public IShipStationService CreateServiceV2(ShipStationCredentials credentials) { return(CreateServiceV2(credentials, new ShipStationTimeouts())); }
public ShipStationService(ShipStationCredentials credentials) { this._webRequestServices = new WebRequestServices(credentials); }
public WebRequestServices(ShipStationCredentials credentials) { this._credentials = credentials; }