public Worker( IWebApiClient webApiClient, ILogger <Worker> logger) { _webApiClient = webApiClient; _logger = logger; }
public static Task <TResult> GetAsync <TResult>(this IWebApiClient webApiClient, Priority priority, string path, int retryCount, int sleepDuration, CancellationToken cancellationToken = default(CancellationToken)) { return(PollyDecorator( () => webApiClient.GetAsync <TResult>(priority, path, cancellationToken), retryCount, sleepDuration)); }
public WebApi(IBitmovinApiClientFactory apiClientFactory) { _apiClient = apiClientFactory.CreateClient <IWebApiClient>(); Domains = new DomainsApi(apiClientFactory); Status = new StatusApi(apiClientFactory); Download = new DownloadApi(apiClientFactory); }
public MockDataStore() { _webApiClient = WebApiClientFactory.Get <IStarwarsApi>("https://swapi.co/api", false, () => new SampleHttpClientHandler()); items = new List <Starships>(); var mockItems = new List <Starships> { new Starships { Id = Guid.NewGuid().ToString(), name = "First starship", model = "This is an item description." }, new Starships { Id = Guid.NewGuid().ToString(), name = "Second starship", model = "This is an item description." }, new Starships { Id = Guid.NewGuid().ToString(), name = "Third starship", model = "This is an item description." }, new Starships { Id = Guid.NewGuid().ToString(), name = "Fourth starship", model = "This is an item description." }, new Starships { Id = Guid.NewGuid().ToString(), name = "Fifth starship", model = "This is an item description." }, new Starships { Id = Guid.NewGuid().ToString(), name = "Sixth starship", model = "This is an item description." } }; foreach (var item in mockItems) { items.Add(item); } }
// test post call public static async Task <string> PostRawPostmanEcho(bool forceRefresh = false) { IWebApiClient <IPostmanEcho> webApiClient = WebApiClientFactory.Get <IPostmanEcho>("https://postman-echo.com/", false); PostObject postObject = new PostObject(); postObject.testName = "hello world"; postObject.testDate = DateTime.Now.ToString(); var postObjectResult = await webApiClient.Call( (service) => service.PostObject(postObject), Priority.UserInitiated, 2, (ex) => true, 60); var postResult = await webApiClient.Call( (service) => service.Post("test"), Priority.UserInitiated, 2, (ex) => true, 60); Console.WriteLine("\t Post string: "); ConvertJson(postResult); Console.WriteLine("\t Post object: "); ConvertJson(postObjectResult); return(postResult); }
// 2 ways to check an object. One from json printed, the other an object from the api // the first way is more modular and works for any json, the second more adjusted for SWAPI public static async Task <IEnumerable <Starships> > GetStarShipItemsAsync(bool forceRefresh = false) { IWebApiClient <IStarwarsApi> _webApiClient = WebApiClientFactory.Get <IStarwarsApi>("https://swapi.co/api", true); var jsonresult = await _webApiClient.Call( (service) => service.GetTask(), Priority.UserInitiated, 2, (ex) => true, 60); var result = await _webApiClient.Call( (service) => service.GetStarships(), Priority.UserInitiated, 2, (ex) => true, 60); // checking the get call with a quick timeout try { var timeoutresult = await _webApiClient.Call( (service) => service.GetTask(), Priority.UserInitiated, 2, (ex) => true, 3); } catch (Exception e) { Console.WriteLine("This call is longer then 3 seconds, but will display anyway of working correctly"); } ConvertJson(jsonresult); return(result.Results); }
public static Task <TResult> DeleteAsync <TResult>(this IWebApiClient webApiClient, Priority priority, string path, int retryCount, Func <int, TimeSpan> sleepDurationProvider, CancellationToken cancellationToken = default(CancellationToken)) { return(PollyDecorator( () => webApiClient.DeleteAsync <TResult>(priority, path, cancellationToken), retryCount, sleepDurationProvider)); }
public static Task <TResult> PutAsync <TContent, TResult>(this IWebApiClient webApiClient, Priority priority, string path, int retryCount, Func <int, TimeSpan> sleepDurationProvider, TContent content = default(TContent), IHttpContentResolver contentResolver = null, CancellationToken cancellationToken = default(CancellationToken)) { return(PollyDecorator( () => webApiClient.PutAsync <TContent, TResult>(priority, path, cancellationToken: cancellationToken), retryCount, sleepDurationProvider)); }
public ApiFactory(IApiServiceLocator apiLocator) { var apiBaseUrl = apiLocator.GetServiceLocation(typeof(TService).Name); this.client = new WebApiClient(); this.client.BaseUrl = apiBaseUrl; this.executeMethods = new ConcurrentDictionary <Type, Action <Castle.DynamicProxy.IInvocation> >(); }
public ApiFactory(IServiceProvider serviceProvider) { var locator = (IApiServiceLocator)serviceProvider.GetService(typeof(IApiServiceLocator)); var serviceLocation = locator.GetServiceLocation(typeof(TService).Name); this.client = new WebApiClient(); this.client.BaseUrl = serviceLocation; this.executeMethods = new ConcurrentDictionary <Type, Action <Castle.DynamicProxy.IInvocation> >(); }
public TaskManager(ITasksStorage tasksStorage, IServerStorage serversStorage, IWebApiClient apiClient) { this.tasksStorage = tasksStorage; this.serversStorage = serversStorage; this.apiClient = apiClient; this.RunAddOrUpdateProductTasks(); this.RunDeleteProductTasks(); }
internal AdminApi(IWebApiClient client) { Apps = new AdminAppsApi(client); Conversations = new AdminConversationsApi(client); Emoji = new AdminEmojiApi(client); InviteRequests = new AdminInviteRequestsApi(client); Teams = new AdminTeamsApi(client); Users = new AdminUsersApi(client); }
public BaseClient(IWebApiClient apiClient) { if (apiClient == null) { throw new ArgumentNullException(nameof(apiClient)); } this.apiClient = apiClient; }
public override async Task Prepare <TConfiguration>(IWebApiClient <TConfiguration> client) { await base.Prepare <TConfiguration>(client).ConfigureAwait(false); if (!IsTokenUseable()) { await this.RefreshToken(client).ConfigureAwait(false); } }
public MovieService(IRepository <Movie> movieRepository, IRepository <Director> directorRepository, IRepository <Actor> actorRepository, IRepository <Country> countryRepository, IRepository <Genre> genreRepository, IWebApiClient movieWebApiClient) { _movieRepository = movieRepository; _directoRepository = directorRepository; _actorRepository = actorRepository; _movieWebApiClient = movieWebApiClient; _countryRepository = countryRepository; _genreRepository = genreRepository; }
public SendSmsRequestReceivedConsumerShould() { _configuration = new SmsConfiguration { Password = "******", ServiceUrl = "http://localhost/send-sms", User = "******", }; _webApiClient = Substitute.For <IWebApiClient>(); }
public ServerManager(IServerStorage storage, IWebApiClient apiClient, ITaskManager taskManager) { this.storage = storage; this.storage.Servers.CollectionChanged += (s, e) => { this.Initialize(); }; this.apiClient = apiClient; this.taskManager = taskManager; this.Cache = new Cache(); this.Initialize(); }
public ServiceUnitTest() { _movieRepositoryMock = new Mock <IRepository <Movie> >(); _actorRepositoryMock = new Mock <IRepository <Actor> >(); _directorRepositoryMock = new Mock <IRepository <Director> >(); _countryRepositoryMock = new Mock <IRepository <Country> >(); _genreRepositoryMock = new Mock <IRepository <Genre> >(); _movieWebApiClientMock = new CsfdWebApiClient(); _service = new MovieService(_movieRepositoryMock.Object, _directorRepositoryMock.Object, _actorRepositoryMock.Object, _countryRepositoryMock.Object, _genreRepositoryMock.Object, _movieWebApiClientMock); }
public Worker( IWebApiClient webApiClient, IGrpcClient grpcClient, IMyConfiguration myConfiguration, ILogger <Worker> logger) { _webApiClient = webApiClient; _grpcClient = grpcClient; _myConfiguration = myConfiguration; _logger = logger; }
public SellersViewModel(IServerManager manager, IWebApiClient apiClient) { this.manager = manager; this.manager.SelectedServerChanged += this.OnSelectedServerChanged; this.apiClient = apiClient; this.Waste = new ObservableCollection<Waste>(); this.Sells = new ObservableCollection<Sell>(); this.Search = new RelayCommand(this.HandleSearch, this.CanSearch); }
private async Task RefreshToken <TConfiguration>(IWebApiClient <TConfiguration> client) where TConfiguration : IWebApiConfiguration { var token = await this.TokenProvider.GetToken(this).ConfigureAwait(false); var encoder = new DeflatedSamlTokenHeaderEncoder(); var bearer = encoder.Encode(((GenericXmlSecurityToken)token).TokenXml.OuterXml); this.TokenValidTo = token.ValidTo; client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", bearer); }
public ShardService(IWebApiClient webApiClient) { this.webApiClient = webApiClient ?? new WebApiClient(); this.webApiClient.Scheme = "http"; this.webApiClient.Host = "drsantesupervisorapidevsk.azurewebsites.net"; WebApiClient.OnResponseReceived += (sender, args) => { httpStatusCode = args.ResponseStatusCode; }; }
internal Action(IWebApiClient webApiClient) { _webApiClient = webApiClient; _user = new Lazy<IUser>(() => new User(_webApiClient)); _project = new Lazy<IProject>(() => new Project(_webApiClient)); _invitation = new Lazy<IInvitation>(() => new Invitation(_webApiClient)); _application = new Lazy<IApplication>(() => new Application(_webApiClient)); _version = new Lazy<IVersion>(() => new Version(_webApiClient)); _serverSetting = new Lazy<IServerSetting>(() => new ServerSetting(_webApiClient)); _service = new Lazy<IService>(() => new Service(_webApiClient)); }
public SendSmsRequestReceivedConsumer( IWebApiClient webApiClient, IPublishEndpoint publishEndpoint, ISmsClient smsClient, ISmsRepository smsRepository, ILogger <SendSmsRequestReceivedConsumer> logger) { _webApiClient = webApiClient; _publishEndpoint = publishEndpoint; _smsClient = smsClient; _smsRepository = smsRepository; _logger = logger; }
public NotificationManager( IEmailClient emailClient, ITemplateService templateEngine, IWebApiClient webApiClient, ISmsClient smsClient, ISmsRepository smsRepository) { _emailClient = emailClient ?? throw new ArgumentNullException(nameof(emailClient)); _templateEngine = templateEngine ?? throw new ArgumentNullException(nameof(templateEngine)); _webApiClient = webApiClient ?? throw new ArgumentNullException(nameof(webApiClient)); _smsClient = smsClient ?? throw new ArgumentNullException(nameof(smsClient)); _smsRepository = smsRepository ?? throw new ArgumentNullException(nameof(smsRepository)); }
public ReportDetailsViewModel(IWebApiClient apiClient, DateTime date, HttpClient client) { this.apiClient = apiClient; this.date = date; this.Waste = new ObservableCollection<Waste>(); this.Sells = new ObservableCollection<Sell>(); this.Shipments = new ObservableCollection<Shipment>(); this.Cancel = new RelayCommand(this.HandleCancel); this.ShowPdf = new RelayCommand(this.HandleShowPdf, this.CanShowPdf); this.Initialize(client, date); }
public LicenseExpirationNoticeTask( INotificationFacade notificationFacade, IOAuthClient oAuthClient, IWebApiClient webApiClient, ApplicationConfiguration applicationConfiguration, IWebHostEnvironment hostingEnvironment, ILogger <LicenseExpirationNoticeTask> logger) { _notificationFacade = notificationFacade; _oAuthClient = oAuthClient; _webApiClient = webApiClient; _applicationConfiguration = applicationConfiguration; _hostingEnvironment = hostingEnvironment; _logger = logger; }
// test login and authorization methods public static async Task <string> AuthenticatePostmanEcho(bool forceRefresh = false) { // this is how you do a basic auth, todo: how to convert to dictionary headers, i would use value? //var authData = string.Format("{0}:{1}", "postman", "password"); //var authHeaderValue = Convert.ToBase64String(Encoding.UTF8.GetBytes(authData)); //AuthenticationHeaderValue value = new AuthenticationHeaderValue(authHeaderValue, authData); // this basic auth way is working now but less clear imo IDictionary <string, string> authValues = new Dictionary <string, string> { { "postman", "password" } }; // OAuth isn't working, how do you add the headers for these //IDictionary<string, string> oAuthValues = new Dictionary<string, string> //{ // {"oauth_consumer_key", "D+EdQ-RKCGzna7bv9YD57c-%@2Nu7" }, // {"oauth_signature_method", "HMAC-SHA1" }, // {"oauth_timestamp", "1472121261"}, // {"oauth_nonce", "oauth_nonce" }, // {"oauth_version", "1.0" }, // {"oauth_signature", "s0rK92Myxx7ceUBVzlMaxiiXU00"} //}; IWebApiClient <IPostmanEcho> basicAuthWebApiClient = WebApiClientFactory.Get <IPostmanEcho>("https://postman-echo.com/", false, defaultHeaders: authValues); //IWebApiClient<IPostmanEcho> oAuthWebApiClient = WebApiClientFactory.Get<IPostmanEcho>("https://postman-echo.com/", false, () => new SampleHttpClientHandler(), oAuthValues); var basicAuthResult = await basicAuthWebApiClient.Call( (service) => service.BasicAuth(), Xablu.WebApiClient.Enums.Priority.UserInitiated, 2, (ex) => true, 60); //var oAuthResult = await oAuthWebApiClient.Call( // (service) => service.OAuth(), // Xablu.WebApiClient.Enums.Priority.UserInitiated, // 2, // (ex) => true, // 60); Console.WriteLine("\t basic auth: "); ConvertJson(basicAuthResult); //Console.WriteLine("\t oauth: "); //ConvertJson(oAuthResult); return(basicAuthResult); }
public WebDownloadProjectViewModel(IRegionManager regionManager, IUntappdService untappdService, IWebApiClient webApiClient, IModuleManager moduleManager, IInteractionRequestService interactionRequestService) : base(moduleManager, regionManager) { this.untappdService = untappdService; this.webApiClient = webApiClient; this.moduleManager = moduleManager; this.interactionRequestService = interactionRequestService; CheckAccessTokenCommand = new DelegateCommand <string>(CheckAccessToken); FulllDownloadButtonCommand = new DelegateCommand(FulllDownloadCheckins); FirstDownloadButtonCommand = new DelegateCommand(FirstDownloadCheckins); ToEndDownloadButtonCommand = new DelegateCommand(ToEndDownloadCheckins); BeerUpdateButtonCommand = new DelegateCommand(UpdateBeers); OkButtonCommand = new DelegateCommand(Exit); }
public DailyReportTask( INotificationFacade notificationFacade, IWebHostEnvironment hostingEnvironment, ILogger <DailyReportTask> logger, IWebApiClient webApiClient, IOAuthClient oAuthClient, IReportClient reportClient, IStatsRepository statsRepository) { _notificationFacade = notificationFacade; _hostingEnvironment = hostingEnvironment; _logger = logger; _webApiClient = webApiClient; _oAuthClient = oAuthClient; _reportClient = reportClient; _statsRepository = statsRepository; }
public GitHubUserInfoService(IWebApiClient client, IGitHubRepoConfig config) { this.client = client; this.config = config; }
public AdminAnalyticsApi(IWebApiClient client) { _client = client; }
public ReportsController(IStoresService storesService, IWebApiClient apiClient) { this.storesService = storesService; this.apiClient = apiClient; }
public FinMindApi(IWebApiClient webApi) { _webApi = webApi; //_token = File.ReadAllText(@"D:/VDisk/SNL/finmind.key"); }
internal Invitation(IWebApiClient webApiClient) { _webApiClient = webApiClient; }
public MeasureService(IWebApiClient apiClient) { _apiClient = apiClient; }
internal Version(IWebApiClient webApiClient) { _webApiClient = webApiClient; }
public PlantPowerService(IWebApiClient apiClient) { _apiClient = apiClient; }
internal Project(IWebApiClient webApiClient) { _webApiClient = webApiClient; }
public AppsApi(IWebApiClient client) { _client = client; }
/// <summary> /// Initializes a new instance of the <see cref="BaseController"/> class. /// </summary> protected BaseController() { this.client = new WebApiClient(); }
public WebIssueTypeCommand(IIssueHandler issueHandler, IWebApiClient client) : base("IssueType", "Simulate the web issue type command") { _issueHandler = issueHandler; _client = client; }
public WebCommands(IIssueHandler issueHandler, IWebApiClient client) : base("Web") { RegisterCommand(new WebIssueTypeCommand(issueHandler, client)); }
public void Setup() { var mockClient = new Mock <IWebApiClient>(); mockClient.Setup(method => method.GetData(It.IsAny <string>(), null)) .Returns(JsonConvert.SerializeObject(items)); mockClient.Setup(method => method.GetData(It.IsAny <string>(), It.Is <string>(x => x != null))) .Returns <string, string>((name, data) => { var item = items.FirstOrDefault(x => x.Code == data); if (item != null) { return(JsonConvert.SerializeObject(item)); } return(null); }); mockClient.Setup(method => method.AddData(It.IsAny <string>(), It.IsAny <string>())) .Returns <string, string>((name, data) => { try { var item = JsonConvert.DeserializeObject <Item>(data); items.Add(item); return(true); } catch (Exception) { return(false); } }); mockClient.Setup(method => method.EditData(It.IsAny <string>(), It.IsAny <string>())) .Returns <string, string>((name, data) => { try { var item = JsonConvert.DeserializeObject <Item>(data); var edited = items.FirstOrDefault(x => x.Code == item.Code); if (edited != null) { edited.Description = item.Description; edited.Rate = item.Rate; return(true); } return(false); } catch (Exception) { return(false); } }); mockClient.Setup(method => method.DeleteData(It.IsAny <string>(), It.IsAny <string>())) .Callback <string, string>((name, data) => { var item = items.FirstOrDefault(x => x.Code == data); if (item != null) { items.Remove(item); } }) .Verifiable("Failed"); client = mockClient.Object; }
internal Application(IWebApiClient webApiClient) { _webApiClient = webApiClient; }
internal Service(IWebApiClient webApiClient) { _webApiClient = webApiClient; Log = new Log(webApiClient); }
internal ServerSetting(IWebApiClient webApiClient) { _webApiClient = webApiClient; }