All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.konfigthis.newscatcherapi.client.api.SourcesApiGenerated Maven / Gradle / Ivy

/*
 * NewsCatcher-V3 Production API
 *  

Visit our website https://newscatcherapi.com * * The version of the OpenAPI document: 3.2.16 * Contact: [email protected] * * NOTE: This class is auto generated by Konfig (https://konfigthis.com). * Do not edit the class manually. */ package com.konfigthis.newscatcherapi.client.api; import com.konfigthis.newscatcherapi.client.ApiCallback; import com.konfigthis.newscatcherapi.client.ApiClient; import com.konfigthis.newscatcherapi.client.ApiException; import com.konfigthis.newscatcherapi.client.ApiResponse; import com.konfigthis.newscatcherapi.client.Configuration; import com.konfigthis.newscatcherapi.client.Pair; import com.konfigthis.newscatcherapi.client.ProgressRequestBody; import com.konfigthis.newscatcherapi.client.ProgressResponseBody; import com.google.gson.reflect.TypeToken; import java.io.IOException; import com.konfigthis.newscatcherapi.client.model.SourceResponse; import com.konfigthis.newscatcherapi.client.model.SourcesRequest; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.ws.rs.core.GenericType; public class SourcesApiGenerated { private ApiClient localVarApiClient; private int localHostIndex; private String localCustomBaseUrl; public SourcesApiGenerated() throws IllegalArgumentException { this(Configuration.getDefaultApiClient()); } public SourcesApiGenerated(ApiClient apiClient) throws IllegalArgumentException { if (apiClient.getApiKey() == null) { throw new IllegalArgumentException("\"x-api-token\" is required but no API key was provided. Please set \"x-api-token\" with ApiClient#setApiKey(String)."); } this.localVarApiClient = apiClient; } public ApiClient getApiClient() { return localVarApiClient; } public void setApiClient(ApiClient apiClient) { this.localVarApiClient = apiClient; } public int getHostIndex() { return localHostIndex; } public void setHostIndex(int hostIndex) { this.localHostIndex = hostIndex; } public String getCustomBaseUrl() { return localCustomBaseUrl; } public void setCustomBaseUrl(String customBaseUrl) { this.localCustomBaseUrl = customBaseUrl; } private okhttp3.Call getCall(String lang, String countries, String predefinedSources, Boolean includeAdditionalInfo, Integer fromRank, Integer toRank, Object sourceName, String sourceUrl, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; // Determine Base Path to Use if (localCustomBaseUrl != null){ basePath = localCustomBaseUrl; } else if ( localBasePaths.length > 0 ) { basePath = localBasePaths[localHostIndex]; } else { basePath = null; } Object localVarPostBody = null; // create path and map variables String localVarPath = "/api/sources"; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); Map localVarHeaderParams = new HashMap(); Map localVarCookieParams = new HashMap(); Map localVarFormParams = new HashMap(); if (lang != null) { localVarQueryParams.addAll(localVarApiClient.parameterToPair("lang", lang)); } if (countries != null) { localVarQueryParams.addAll(localVarApiClient.parameterToPair("countries", countries)); } if (predefinedSources != null) { localVarQueryParams.addAll(localVarApiClient.parameterToPair("predefined_sources", predefinedSources)); } if (includeAdditionalInfo != null) { localVarQueryParams.addAll(localVarApiClient.parameterToPair("include_additional_info", includeAdditionalInfo)); } if (fromRank != null) { localVarQueryParams.addAll(localVarApiClient.parameterToPair("from_rank", fromRank)); } if (toRank != null) { localVarQueryParams.addAll(localVarApiClient.parameterToPair("to_rank", toRank)); } if (sourceName != null) { localVarQueryParams.addAll(localVarApiClient.parameterToPair("source_name", sourceName)); } if (sourceUrl != null) { localVarQueryParams.addAll(localVarApiClient.parameterToPair("source_url", sourceUrl)); } final String[] localVarAccepts = { "application/json" }; final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) { localVarHeaderParams.put("Accept", localVarAccept); } final String[] localVarContentTypes = { }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); if (localVarContentType != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } String[] localVarAuthNames = new String[] { "apiKey" }; return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getValidateBeforeCall(String lang, String countries, String predefinedSources, Boolean includeAdditionalInfo, Integer fromRank, Integer toRank, Object sourceName, String sourceUrl, final ApiCallback _callback) throws ApiException { return getCall(lang, countries, predefinedSources, includeAdditionalInfo, fromRank, toRank, sourceName, sourceUrl, _callback); } private ApiResponse getWithHttpInfo(String lang, String countries, String predefinedSources, Boolean includeAdditionalInfo, Integer fromRank, Integer toRank, Object sourceName, String sourceUrl) throws ApiException { okhttp3.Call localVarCall = getValidateBeforeCall(lang, countries, predefinedSources, includeAdditionalInfo, fromRank, toRank, sourceName, sourceUrl, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } private okhttp3.Call getAsync(String lang, String countries, String predefinedSources, Boolean includeAdditionalInfo, Integer fromRank, Integer toRank, Object sourceName, String sourceUrl, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = getValidateBeforeCall(lang, countries, predefinedSources, includeAdditionalInfo, fromRank, toRank, sourceName, sourceUrl, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } public class GetRequestBuilder { private String lang; private String countries; private String predefinedSources; private Boolean includeAdditionalInfo; private Integer fromRank; private Integer toRank; private Object sourceName; private String sourceUrl; private GetRequestBuilder() { } /** * Set lang * @param lang (optional) * @return GetRequestBuilder */ public GetRequestBuilder lang(String lang) { this.lang = lang; return this; } /** * Set countries * @param countries (optional) * @return GetRequestBuilder */ public GetRequestBuilder countries(String countries) { this.countries = countries; return this; } /** * Set predefinedSources * @param predefinedSources (optional) * @return GetRequestBuilder */ public GetRequestBuilder predefinedSources(String predefinedSources) { this.predefinedSources = predefinedSources; return this; } /** * Set includeAdditionalInfo * @param includeAdditionalInfo (optional) * @return GetRequestBuilder */ public GetRequestBuilder includeAdditionalInfo(Boolean includeAdditionalInfo) { this.includeAdditionalInfo = includeAdditionalInfo; return this; } /** * Set fromRank * @param fromRank (optional) * @return GetRequestBuilder */ public GetRequestBuilder fromRank(Integer fromRank) { this.fromRank = fromRank; return this; } /** * Set toRank * @param toRank (optional) * @return GetRequestBuilder */ public GetRequestBuilder toRank(Integer toRank) { this.toRank = toRank; return this; } /** * Set sourceName * @param sourceName (optional) * @return GetRequestBuilder */ public GetRequestBuilder sourceName(Object sourceName) { this.sourceName = sourceName; return this; } /** * Set sourceUrl * @param sourceUrl (optional) * @return GetRequestBuilder */ public GetRequestBuilder sourceUrl(String sourceUrl) { this.sourceUrl = sourceUrl; return this; } /** * Build call for get * @param _callback ApiCallback API callback * @return Call to execute * @throws ApiException If fail to serialize the request body object * @http.response.details
Status Code Description Response Headers
200 Successful Response -
*/ public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException { return getCall(lang, countries, predefinedSources, includeAdditionalInfo, fromRank, toRank, sourceName, sourceUrl, _callback); } /** * Execute get request * @return SourceResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details
Status Code Description Response Headers
200 Successful Response -
*/ public SourceResponse execute() throws ApiException { ApiResponse localVarResp = getWithHttpInfo(lang, countries, predefinedSources, includeAdditionalInfo, fromRank, toRank, sourceName, sourceUrl); return localVarResp.getResponseBody(); } /** * Execute get request with HTTP info returned * @return ApiResponse<SourceResponse> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details
Status Code Description Response Headers
200 Successful Response -
*/ public ApiResponse executeWithHttpInfo() throws ApiException { return getWithHttpInfo(lang, countries, predefinedSources, includeAdditionalInfo, fromRank, toRank, sourceName, sourceUrl); } /** * Execute get request (asynchronously) * @param _callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object * @http.response.details
Status Code Description Response Headers
200 Successful Response -
*/ public okhttp3.Call executeAsync(final ApiCallback _callback) throws ApiException { return getAsync(lang, countries, predefinedSources, includeAdditionalInfo, fromRank, toRank, sourceName, sourceUrl, _callback); } } /** * [Get] Search For Sources Request * This endpoint allows you to get the list of sources that are available in the database. You can filter the sources by language and country. The maximum number of sources displayed is set according to your plan. You can find the list of plans and their features here: https://newscatcherapi.com/news-api#news-api-pricing * @return GetRequestBuilder * @http.response.details
Status Code Description Response Headers
200 Successful Response -
*/ public GetRequestBuilder get() throws IllegalArgumentException { return new GetRequestBuilder(); } private okhttp3.Call postCall(SourcesRequest sourcesRequest, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; // Determine Base Path to Use if (localCustomBaseUrl != null){ basePath = localCustomBaseUrl; } else if ( localBasePaths.length > 0 ) { basePath = localBasePaths[localHostIndex]; } else { basePath = null; } Object localVarPostBody = sourcesRequest; // create path and map variables String localVarPath = "/api/sources"; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); Map localVarHeaderParams = new HashMap(); Map localVarCookieParams = new HashMap(); Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { "application/json" }; final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) { localVarHeaderParams.put("Accept", localVarAccept); } final String[] localVarContentTypes = { "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); if (localVarContentType != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } String[] localVarAuthNames = new String[] { "apiKey" }; return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call postValidateBeforeCall(SourcesRequest sourcesRequest, final ApiCallback _callback) throws ApiException { // verify the required parameter 'sourcesRequest' is set if (sourcesRequest == null) { throw new ApiException("Missing the required parameter 'sourcesRequest' when calling post(Async)"); } return postCall(sourcesRequest, _callback); } private ApiResponse postWithHttpInfo(SourcesRequest sourcesRequest) throws ApiException { okhttp3.Call localVarCall = postValidateBeforeCall(sourcesRequest, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } private okhttp3.Call postAsync(SourcesRequest sourcesRequest, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = postValidateBeforeCall(sourcesRequest, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } public class PostRequestBuilder { private String lang; private String countries; private String predefinedSources; private Boolean includeAdditionalInfo; private Integer fromRank; private Integer toRank; private Object sourceName; private String sourceUrl; private PostRequestBuilder() { } /** * Set lang * @param lang (optional) * @return PostRequestBuilder */ public PostRequestBuilder lang(String lang) { this.lang = lang; return this; } /** * Set countries * @param countries (optional) * @return PostRequestBuilder */ public PostRequestBuilder countries(String countries) { this.countries = countries; return this; } /** * Set predefinedSources * @param predefinedSources (optional) * @return PostRequestBuilder */ public PostRequestBuilder predefinedSources(String predefinedSources) { this.predefinedSources = predefinedSources; return this; } /** * Set includeAdditionalInfo * @param includeAdditionalInfo (optional) * @return PostRequestBuilder */ public PostRequestBuilder includeAdditionalInfo(Boolean includeAdditionalInfo) { this.includeAdditionalInfo = includeAdditionalInfo; return this; } /** * Set fromRank * @param fromRank (optional) * @return PostRequestBuilder */ public PostRequestBuilder fromRank(Integer fromRank) { this.fromRank = fromRank; return this; } /** * Set toRank * @param toRank (optional) * @return PostRequestBuilder */ public PostRequestBuilder toRank(Integer toRank) { this.toRank = toRank; return this; } /** * Set sourceName * @param sourceName (optional) * @return PostRequestBuilder */ public PostRequestBuilder sourceName(Object sourceName) { this.sourceName = sourceName; return this; } /** * Set sourceUrl * @param sourceUrl (optional) * @return PostRequestBuilder */ public PostRequestBuilder sourceUrl(String sourceUrl) { this.sourceUrl = sourceUrl; return this; } /** * Build call for post * @param _callback ApiCallback API callback * @return Call to execute * @throws ApiException If fail to serialize the request body object * @http.response.details
Status Code Description Response Headers
200 Successful Response -
*/ public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException { SourcesRequest sourcesRequest = buildBodyParams(); return postCall(sourcesRequest, _callback); } private SourcesRequest buildBodyParams() { SourcesRequest sourcesRequest = new SourcesRequest(); sourcesRequest.lang(this.lang); sourcesRequest.countries(this.countries); sourcesRequest.predefinedSources(this.predefinedSources); sourcesRequest.includeAdditionalInfo(this.includeAdditionalInfo); sourcesRequest.fromRank(this.fromRank); sourcesRequest.toRank(this.toRank); sourcesRequest.sourceName(this.sourceName); sourcesRequest.sourceUrl(this.sourceUrl); return sourcesRequest; } /** * Execute post request * @return SourceResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details
Status Code Description Response Headers
200 Successful Response -
*/ public SourceResponse execute() throws ApiException { SourcesRequest sourcesRequest = buildBodyParams(); ApiResponse localVarResp = postWithHttpInfo(sourcesRequest); return localVarResp.getResponseBody(); } /** * Execute post request with HTTP info returned * @return ApiResponse<SourceResponse> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details
Status Code Description Response Headers
200 Successful Response -
*/ public ApiResponse executeWithHttpInfo() throws ApiException { SourcesRequest sourcesRequest = buildBodyParams(); return postWithHttpInfo(sourcesRequest); } /** * Execute post request (asynchronously) * @param _callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object * @http.response.details
Status Code Description Response Headers
200 Successful Response -
*/ public okhttp3.Call executeAsync(final ApiCallback _callback) throws ApiException { SourcesRequest sourcesRequest = buildBodyParams(); return postAsync(sourcesRequest, _callback); } } /** * [Post] Search For Sources Request * This endpoint allows you to get the list of sources that are available in the database. You can filter the sources by language and country. The maximum number of sources displayed is set according to your plan. You can find the list of plans and their features here: https://newscatcherapi.com/news-api#news-api-pricing * @param sourcesRequest (required) * @return PostRequestBuilder * @http.response.details
Status Code Description Response Headers
200 Successful Response -
*/ public PostRequestBuilder post() throws IllegalArgumentException { return new PostRequestBuilder(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy