public virtual IOperations Commit() { var u = MakeUri(UpdateUri, "commit=true"); _httpHelper.Get(u); return(this); }
public string GetPokemonDescription(string pokeName) { try { var pokemonId = GetPokemonId(pokeName); if (pokemonId == null) { throw new NotFoundException($"Cannot find the specified Pokemon: {pokeName}"); } var species = _httpHelper.Get($"{BaseUri}{PokemonSpeciesRequest}/{pokemonId}").Result; var entries = species.flavor_text_entries; if (entries != null) { string ret = entries[0].flavor_text.ToString(); // assumption - I am taking the first available flavour, as it wasn't specified in the requirements // whether it is need to use a specific flavor of pokemon. return(ret.Replace("\n", " ").Replace("\f", " ")); // I am removing the \n and \f for the text to be readable by a human } } catch (RuntimeBinderException e) // this is the exception thrown when a dynamic object can't find the property I was trying to bind { // I am returning null instead of allowing a general exception to be thrown which won't tell user what is wrong } return(null); }
private void loadCases(int clientId, int companyId) { try { string controller = $"/api/case/client?clientId={clientId}&companyid={companyId}"; string url = appConfig.apiBaseUrl + controller; var oCaseList = _httpHelper.Get <List <CaseVM> >(url); ddlCase.DataSource = oCaseList; ddlCase.DataTextField = "CaseName"; ddlCase.DataValueField = "CaseNumber"; ddlCase.DataBind(); } catch (Exception) { } }
private async Task <List <Article> > ScrapeArticles() { var articles = new List <Article>(); var feed = await httpHelper.Get(FeedUrl); if (string.IsNullOrEmpty(feed)) { throw new NullReferenceException($"Could not get feed from url {FeedUrl}"); } var parser = new RssParser(); var rss = parser.Parse(feed); var newestArticlesSchemas = rss.OrderByDescending(x => x.PublishDate).Take(10); foreach (var schema in newestArticlesSchemas) { if (schema.Categories.Contains("Vijesti")) { articles.Add(new Article { Source = NewsSource.IndexHr, Guid = GetGuidFromUrl(schema.InternalID), Title = schema.Title, Image = schema.ImageUrl, Text = await GetArticleText(schema.InternalID), Summary = schema.Summary, Keywords = keywordHelper.GetKeywordsFromTitle(schema.Title), SourceUrl = schema.InternalID }); } } return(articles); }
private async Task <List <Article> > ScrapeArticles() { var articles = new List <Article>(); var feed = await httpHelper.Get(FeedUrl); if (string.IsNullOrEmpty(feed)) { throw new Exception($"Could not get feed from url {FeedUrl}"); } var parser = new RssParser(); var rss = parser.Parse(feed); var newestArticlesSchemas = rss.OrderByDescending(x => x.PublishDate).Take(10); foreach (var schema in newestArticlesSchemas) { var document = await httpHelper.GetDocumentFromUrl(schema.InternalID); articles.Add(new Article { Source = NewsSource.PriznajemHr, Guid = GetGuidFromUrl(schema.InternalID), Title = schema.Title, Image = GetArticleImage(document), Text = await httpHelper.GetArticleText(schema.Content), Summary = await httpHelper.GetFirstParagraph(schema.Content), Keywords = keywordHelper.GetKeywordsFromTitle(schema.Title), SourceUrl = schema.InternalID }); } return(articles); }
public override async Task StartAsync(IJobExecutionContext context) { //Logic : HttpRequests will be sent this section , Job Data will be getting this section _result = await _jobService.GetJobByName(context.JobDetail.Key.Name.ToString()); if (_result.IsSuccess) { _jobDataDto = _result.Data?.JobDataDtoList?.FirstOrDefault(); if (_jobDataDto != null) { switch (_jobDataDto.Method.ToLower()) { case HttpMethodCodes.GET: await _httpHelper.Get(_jobDataDto.Url, _jobDataDto.Header, _jobDataDto.Body); break; case HttpMethodCodes.HEAD: break; case HttpMethodCodes.DELETE: break; case HttpMethodCodes.OPTIONS: break; case HttpMethodCodes.PATCH: break; case HttpMethodCodes.POST: await _httpHelper.PostAsync(_jobDataDto.Url, _jobDataDto.Header, _jobDataDto.Body); break; case HttpMethodCodes.PUT: break; case HttpMethodCodes.TRACE: break; default: //Handle Invalid Method Code break; } } } GC.Collect(); }
private void loadClients(string companyId) { try { string controller = $"/api/Client?Companyid={companyId}"; string url = appConfig.apiBaseUrl + controller; var oClientList = _httpHelper.Get <List <ClientVM> >(url); ddlClients.DataSource = oClientList; ddlClients.DataTextField = "ClientDisplayName"; ddlClients.DataValueField = "ClientId"; ddlClients.DataBind(); } catch (Exception) { } }
public async Task <IEnumerable <Race> > GetAll() { return(await _httpHelper.Get <Race>(_endpoint)); }
public async Task <IEnumerable <Customer> > GetAll() { return(await _httpHelper.Get <Customer>(_endpoint)); }