protected override async Task <IndexHistoryData> LoadDataAsync(string secId, DateTime day) { var boardgroupId = 9; string date = day.Date.ToString("yyyy-MM-dd"); var url = _config.PrepareUrl(boardgroupId, secId, new Dictionary <string, string> { ["sort_order"] = "desc", ["till"] = date, ["limit"] = "1", }); IndexHistoryData result = null; try { var data = await _httpClientService.Get <IndexHistoryData[]>(url, _config.ObjectPath); result = data.FirstOrDefault(); } catch (ServiceResponseException) { } return(result); }
private async Task <SecurityStaticData> GetCurrentSecurity(string secType, DateTime date) { var url = _marketConf.PrepareUrl(FuturesBoardgroupId, null, new Dictionary <string, string> { ["sort_column"] = "LASTDELDATE", ["sort_order"] = "asc", ["sectypes"] = secType, }); var token = await _getService.Get <JToken>(url, "$.[1].securities[1]"); var staticDataBySecType = token .Children() .Select(t => new SecurityStaticData(t.Value <string>("SECID")) { AssetCode = t.Value <string>("ASSETCODE"), LastDelDate = t.Value <DateTime>("LASTDELDATE") }) .OrderBy(s => s.LastDelDate) .ToList(); var skipped = staticDataBySecType.Where(s => s.LastDelDate > date.AddDays(CurrentContractGapInDays)).ToList(); if (!skipped.Any()) { _logger.LogWarning( "After {days} days there are no contacts for sectype {secType}. Will try to return current contract.", CurrentContractGapInDays, secType); } return((skipped.Any() ? skipped : staticDataBySecType).FirstOrDefault()); }
protected override async Task <CurrencyHistoryData> LoadDataAsync(string secId, DateTime day) { var bg = await _staticDataService.GetBoardgroup(secId); if (bg == null) { return(null); } string date = day.ToString("yyyy-MM-dd"); var url = _config.PrepareUrl(bg.Id, secId, new Dictionary <string, string> { ["sort_order"] = "desc", ["till"] = date, ["limit"] = "10", }); CurrencyHistoryData result = null; try { var data = await _httpClientService.Get <CurrencyHistoryData[]>(url, _config.ObjectPath); result = data.FirstOrDefault(d => d.WAPRICE != null); } catch (ServiceResponseException) { } return(result); }
public async Task <ApiResponse> InstituteHospitalList() { LogManager.LogStartFunction(MethodBase.GetCurrentMethod().DeclaringType.ToString(), MethodBase.GetCurrentMethod().Name); JArray result = await _httpClientService.Get <JArray>(_dataProvider.dataProviderApiUrl, _dataProvider.InstituteListApi + "getInstituteHospitalList"); LogManager.LogEndFunction(MethodBase.GetCurrentMethod().DeclaringType.ToString(), MethodBase.GetCurrentMethod().Name); return(new ApiOkResponse(result)); }
public async Task <ApiResponse> Get(string listName) { LogManager.LogStartFunction(MethodBase.GetCurrentMethod().DeclaringType.ToString(), MethodBase.GetCurrentMethod().Name); JArray result = await _httpClientService.Get <JArray>(_dataProvider.dataProviderApiUrl, _dataProvider.GeneralListsApi, listName); LogManager.LogEndFunction(MethodBase.GetCurrentMethod().DeclaringType.ToString(), MethodBase.GetCurrentMethod().Name); return(new ApiOkResponse(result)); }
public async Task <ViewModel> Balance(long id) { var httpResponse = await httpClientService.Get <RequestResponseModel>($"AtomTransaction/{id}"); if (httpResponse.IsSuccessStatusCode) { var httpResult = JsonConvert.DeserializeObject <RequestResponseModel>(await httpResponse.Content.ReadAsStringAsync()); return(mapper.Map <ViewModel>(httpResult)); } return(new ViewModel() { Successful = false, Message = "unable to process, please try after sometimes" }); }
public HttpResponseMessage GetReleasesByArtist(string artist_id) { Guid tmp; if (!Guid.TryParse(artist_id, out tmp)) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Invalid Request")); } try { string Url = string.Format("http://musicbrainz.org/ws/2/release/?query=arid:{0}", artist_id); var result = _httpClient.Get(Url, PAGE_SIZE); if (result == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } return(Request.CreateResponse(HttpStatusCode.OK, new { releases = result })); } catch (Exception) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Something went wrong")); } }
public async Task <IEnumerable <T> > GetAll(string requestUri) { var result = await _httpClientService .Get <IEnumerable <T> >(requestUri); return(result); }
public bool Login(string username, string password) { try { ApplicationSession.userName = username; ApplicationSession.userPassword = password; HttpResponseMessage APIResponse = httpClientService.Get($"api/User?username={username}&password={password}"); if (APIResponse.IsSuccessStatusCode) { string JsonContent = APIResponse.Content.ReadAsStringAsync().Result; User matchingUser = JsonConvert.DeserializeObject <User>(JsonContent); if (matchingUser != null) { applicationSessionService.AddUserIntoApplicationSession(matchingUser); return(true); } } ApplicationSession.userName = string.Empty; ApplicationSession.userPassword = string.Empty; return(false); } catch (Exception) { return(false); } }
public async Task <T> Get(string requestUri) { var result = await _httpClientService .Get <T>(requestUri); return(result); }
public async Task <StarCitizenUser> GetUser(string handle) { var requestUrl = string.Format(_config.ApiRequestUrl, _config.ApiKey, $"user/{handle}"); var content = await _httpService.Get(requestUrl); var data = JObject.Parse(content); var profileData = data["data"]?["profile"]; var organizationData = data["data"]?["organization"]; var user = new StarCitizenUser { Profile = ParseUserProfile(profileData), Organization = ParseUserOrganizationInfo(organizationData) }; return(user); }
public async Task <MenuItem[]> Get(int menuId) { var result = await _httpClientService.Get <MenuItem[]>(_dataProvider.dataProviderApiUrl, _dataProvider.MenuApi, menuId.ToString()); return(result); }
public int GetUserIdOwnerByVehicleId(int vehicleId) { try { HttpResponseMessage APIResponse = httpClientService.Get($"api/Vehicle/GetUserIdOwnerByVehicleId?vehicleId={vehicleId}"); if (APIResponse.IsSuccessStatusCode) { string JsonContent = APIResponse.Content.ReadAsStringAsync().Result; int userIdOwner = JsonConvert.DeserializeObject <int>(JsonContent); return(userIdOwner); } return(0); } catch (Exception) { throw; } }
public async Task <IViewComponentResult> InvokeAsync() { var response = await _service.Get(_appSettings.RestApiUrl); if (!response.Success) { return(View(new List <Employee>())); } return(View(response.EmployeeList)); }
public IEnumerable <Message> GetMessageListByOrderId(int orderId) { try { HttpResponseMessage APIResponse = httpClientService.Get($"api/Message/GetByOrderId?orderId={orderId}"); if (APIResponse.IsSuccessStatusCode) { string JsonContent = APIResponse.Content.ReadAsStringAsync().Result; IEnumerable <Message> matchingOrderList = JsonConvert.DeserializeObject <IEnumerable <Message> >(JsonContent); if (matchingOrderList != null) { return(matchingOrderList); } } return(Enumerable.Empty <Message>()); } catch (Exception) { throw; } }
public IEnumerable <Timetable> GetTimetableListPerDay(int year, int month, int day) { try { HttpResponseMessage APIResponse = httpClientService.Get($"api/Timetable/GetPerDay?year={year}&month={month}&day={day}"); if (APIResponse.IsSuccessStatusCode) { string JsonContent = APIResponse.Content.ReadAsStringAsync().Result; IEnumerable <Timetable> matchingTimetableList = JsonConvert.DeserializeObject <IEnumerable <Timetable> >(JsonContent); if (matchingTimetableList != null) { return(matchingTimetableList); } } return(Enumerable.Empty <Timetable>()); } catch (Exception) { throw; } }
public IEnumerable <Order> GetAllOrderList() { try { HttpResponseMessage APIResponse = httpClientService.Get($"api/Order"); if (APIResponse.IsSuccessStatusCode) { string JsonContent = APIResponse.Content.ReadAsStringAsync().Result; IEnumerable <Order> matchingOrderList = JsonConvert.DeserializeObject <IEnumerable <Order> >(JsonContent); if (matchingOrderList != null) { return(matchingOrderList); } } return(Enumerable.Empty <Order>()); } catch (Exception) { throw; } }
public async Task <IActionResult> Edit(int id) { var response = await _service.Get(id, _appSetings.RestApiUrl); if (!response.Success) { return(View("NotFound")); } var employeeResource = _converter.ConvertFromModel(response.Employee); return(View(employeeResource)); }
private async Task Kick() { try { var link = $"https://{_configuration["Domain"]}"; await _httpClientService.Get(link); _logger.LogDebug("Kicked"); } catch (Exception e) { _logger.LogError(e.Message); } }
public long GetApkVersion() { try { HttpResponseMessage APIResponse = httpClientService.Get($"api/AndroidPackageKit"); if (APIResponse.IsSuccessStatusCode) { string result = APIResponse.Content.ReadAsStringAsync().Result; return(long.Parse(result)); } return(0); } catch (Exception) { throw; } }
public IEnumerable <VehicleModel> GetVehicleModelListByVehicleBrandId(int vehicleBrandId) { try { HttpResponseMessage APIResponse = httpClientService.Get($"api/VehicleModel/GetByVehicleBrandId?vehicleBrandId={vehicleBrandId}"); if (APIResponse.IsSuccessStatusCode) { string JsonContent = APIResponse.Content.ReadAsStringAsync().Result; IEnumerable <VehicleModel> matchingVehicleModelList = JsonConvert.DeserializeObject <IEnumerable <VehicleModel> >(JsonContent); if (matchingVehicleModelList != null) { return(matchingVehicleModelList); } } return(Enumerable.Empty <VehicleModel>()); } catch (Exception) { throw; } }
private async Task <IEnumerable <TimeStampHistoryData> > GetDataForDate(TypedSecurity sec, DateTime from) { var result = Enumerable.Empty <TimeStampHistoryData>(); JToken token = null; var url = _conf.PrepareUrl(sec.Type, sec.BoardgroupId, sec.SecId, new Dictionary <string, string> { ["from"] = from.ToString("yyyy-MM-dd"), }); try { token = await _getService.Get <JToken>(url, _conf.ObjectPath); } catch (ServiceUnavailableException) { _logger.LogWarning( "{secId} minute history data not found. Url: {url}", sec.SecId, url); } if (token != null && token.Type == JTokenType.Array) { result = token .Children() .Select(t => new TimeStampHistoryData( sec.SecId, t.First.Value <long>(), t.Last.Value <float?>()) ) .ToList(); } return(result); }
public async Task SignOut(Toast toast = default(Toast)) { await httpClientService.Get("api/user/SignOut", toast); await authenticationStateProvider.MarkUserAsSignedOut(); }