protected BaseApiController(IRepository <TEntity> repository, IEntityExpressionsBuilder entityExpressionsBuilder, IApiQuery apiQuery, IApiHelper apiHelper) { EntityRepository = repository ?? throw new ArgumentNullException(nameof(repository)); EntityExpressionsBuilder = entityExpressionsBuilder ?? throw new ArgumentNullException(nameof(entityExpressionsBuilder)); ApiQuery = apiQuery ?? throw new ArgumentNullException(nameof(apiQuery)); ApiHelper = apiHelper ?? throw new ArgumentNullException(nameof(apiHelper)); }
protected IRestRequest PrepareRequest(string resourceUrl, IApiQuery query = null) { query = query ?? new ApiQuery(); var request = new RestRequest(resourceUrl, HttpRetrievalMethod, DataFormat.Json); request.AddParameter(CONTENT_TYPE_TEXT_PLAIN, query.GetQueryString(), ParameterType.RequestBody); return(request); }
public async Task<TApiQueryResult> Query<TApiQueryResult>(IApiQuery<TApiQueryResult> query) { if (String.IsNullOrEmpty(query.ApiKey)) query.ApiKey = _options.ApiKey; if (String.IsNullOrEmpty(query.ApiKey)) throw new Exception("Api key required."); return await _webClient.Query(query); }
public async Task <TApiQueryResult> Query <TApiQueryResult>(IApiQuery <TApiQueryResult> query) { using (var webClient = new System.Net.WebClient()) { webClient.QueryString = query.Parameters.Aggregate(new NameValueCollection(), (seed, current) => { seed.Add(current.Key, current.Value); return(seed); }); var json = await webClient.DownloadStringTaskAsync(QUERY_URL); return(_deserializer.Deserialize <TApiQueryResult>(json)); } }
public IEnumerable <GameEngine> GetGameEngines(IApiQuery query = null) { IRestRequest req = PrepareRequest(RESOURCE_GAME_ENGINES, query); var gameEnginesResponse = _restClient.Post <List <GameEngine> >(req); Exception exception = BuildExceptionForResponse(gameEnginesResponse); if (exception != null) { throw exception; } return(gameEnginesResponse?.Data); }
public async Task <IEnumerable <GameEngineLogo> > GetGameEngineLogosAsync(IApiQuery query = null) { IRestRequest req = PrepareRequest(RESOURCE_GAME_ENGINE_LOGOS, query); var response = await _restClient.ExecutePostAsync <List <GameEngineLogo> >(req); Exception exception = BuildExceptionForResponse(response); if (exception != null) { throw exception; } return(response?.Data); }
public async Task <TApiQueryResult> Query <TApiQueryResult>(IApiQuery <TApiQueryResult> query) { using (var webClient = new System.Net.WebClient()) { webClient.QueryString = query.Parameters.Aggregate(new NameValueCollection(), (seed, current) => { seed.Add(current.Key, current.Value); return(seed); }); using (var stream = await webClient.OpenReadTaskAsync(QUERY_URL)) { var result = _deserializer.Deserialize <TApiQueryResult>(stream); return(result); } } }
public NoteFileController(IRepository <NoteFile> repository, IEntityExpressionsBuilder entityExpressionsBuilder, IApiQuery apiQuery, IApiHelper apiHelper, INoteFileService noteFileService) : base(repository, entityExpressionsBuilder, apiQuery, apiHelper) { _noteFileService = noteFileService; }
public CategoryController(IRepository <NoteCategory> repository, IEntityExpressionsBuilder entityExpressionsBuilder, IApiQuery apiQuery, IApiHelper apiHelper) : base(repository, entityExpressionsBuilder, apiQuery, apiHelper) { }
public ApiHelper(IApiQuery apiQuery) { _apiQuery = apiQuery; }
public ApiHelper(IApiQuery apiQuery, IOptions <RestApiOptions> options) { _apiQuery = apiQuery ?? throw new ArgumentNullException(nameof(apiQuery)); _showFullErrorInfo = options.Value.ApiException.ShowFullErrorInfo; }