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

com.twitter.clientlib.api.BookmarksApi Maven / Gradle / Ivy

/*
Copyright 2020 Twitter, Inc.
SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
https://openapi-generator.tech
Do not edit the class manually.
*/


package com.twitter.clientlib.api;

import com.twitter.clientlib.ApiCallback;
import com.twitter.clientlib.ApiClient;
import com.twitter.clientlib.auth.*;
import com.twitter.clientlib.ApiException;
import com.twitter.clientlib.ApiResponse;
import com.twitter.clientlib.Configuration;
import com.twitter.clientlib.Pair;
import com.twitter.clientlib.ProgressRequestBody;
import com.twitter.clientlib.ProgressResponseBody;

import com.github.scribejava.core.model.OAuth2AccessToken;
import com.google.gson.reflect.TypeToken;

import java.io.IOException;


import com.twitter.clientlib.model.AddBookmarkRequest;
import com.twitter.clientlib.model.BookmarkMutationResponse;
import com.twitter.clientlib.model.Error;
import com.twitter.clientlib.model.GenericTweetsTimelineResponse;
import com.twitter.clientlib.model.Problem;
import java.util.Set;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Arrays;
import java.io.InputStream;
import javax.ws.rs.core.GenericType;

import org.apache.commons.lang3.StringUtils;

public class BookmarksApi extends ApiCommon {

    /**
     * Build call for getUsersIdBookmarks
     * @param id The ID of the user for whom to return results (required)
     * @param maxResults The maximum number of results (optional)
     * @param paginationToken This parameter is used to get the next 'page' of results. (optional)
     * @param expansions A comma separated list of fields to expand. (optional)
     * @param tweetFields A comma separated list of Tweet fields to display. (optional)
     * @param userFields A comma separated list of User fields to display. (optional)
     * @param mediaFields A comma separated list of Media fields to display. (optional)
     * @param placeFields A comma separated list of Place fields to display. (optional)
     * @param pollFields A comma separated list of Poll fields to display. (optional)
     * @param _callback Callback for upload/download progress
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @http.response.details
     
Status Code Description Response Headers
200 The request was successful -
0 The request has failed. -
*/ public okhttp3.Call getUsersIdBookmarksCall(String id, Integer maxResults, String paginationToken, Set expansions, Set tweetFields, Set userFields, Set mediaFields, Set placeFields, Set pollFields, final ApiCallback _callback) throws ApiException { Object localVarPostBody = null; // create path and map variables String localVarPath = "/2/users/{id}/bookmarks" .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); Map localVarHeaderParams = new HashMap(); Map localVarCookieParams = new HashMap(); Map localVarFormParams = new HashMap(); if (maxResults != null) { localVarQueryParams.addAll(localVarApiClient.parameterToPair("max_results", maxResults)); } if (paginationToken != null) { localVarQueryParams.addAll(localVarApiClient.parameterToPair("pagination_token", paginationToken)); } if (expansions != null) { localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "expansions", expansions)); } if (tweetFields != null) { localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "tweet.fields", tweetFields)); } if (userFields != null) { localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "user.fields", userFields)); } if (mediaFields != null) { localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "media.fields", mediaFields)); } if (placeFields != null) { localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "place.fields", placeFields)); } if (pollFields != null) { localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "poll.fields", pollFields)); } final String[] localVarAccepts = { "application/json", "application/problem+json" }; final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) { localVarHeaderParams.put("Accept", localVarAccept); } final String[] localVarContentTypes = { }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); if (localVarHeaderParams != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } String[] localVarAuthNames = new String[] { "OAuth2UserToken" }; return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, reduceAuthNames(localVarAuthNames), _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call getUsersIdBookmarksValidateBeforeCall(String id, Integer maxResults, String paginationToken, Set expansions, Set tweetFields, Set userFields, Set mediaFields, Set placeFields, Set pollFields, final ApiCallback _callback) throws ApiException { // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling getUsersIdBookmarks(Async)"); } okhttp3.Call localVarCall = getUsersIdBookmarksCall(id, maxResults, paginationToken, expansions, tweetFields, userFields, mediaFields, placeFields, pollFields, _callback); return localVarCall; } /** * Bookmarks by User * Returns Tweet objects that have been bookmarked by the requesting user * @param id The ID of the user for whom to return results (required) * @param maxResults The maximum number of results (optional) * @param paginationToken This parameter is used to get the next 'page' of results. (optional) * @param expansions A comma separated list of fields to expand. (optional) * @param tweetFields A comma separated list of Tweet fields to display. (optional) * @param userFields A comma separated list of User fields to display. (optional) * @param mediaFields A comma separated list of Media fields to display. (optional) * @param placeFields A comma separated list of Place fields to display. (optional) * @param pollFields A comma separated list of Poll fields to display. (optional) * @return GenericTweetsTimelineResponse * @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 The request was successful -
0 The request has failed. -
*/ public GenericTweetsTimelineResponse getUsersIdBookmarks(String id, Integer maxResults, String paginationToken, Set expansions, Set tweetFields, Set userFields, Set mediaFields, Set placeFields, Set pollFields) throws ApiException { ApiResponse localVarResp; try{ localVarResp = getUsersIdBookmarksWithHttpInfo(id, maxResults, paginationToken, expansions, tweetFields, userFields, mediaFields, placeFields, pollFields); } catch (ApiException e) { if (isOAUth2AutoRefreshToken() && e.getCode() == 401) { refreshToken(); localVarResp = getUsersIdBookmarksWithHttpInfo(id, maxResults, paginationToken, expansions, tweetFields, userFields, mediaFields, placeFields, pollFields); } else { throw e; } } return localVarResp != null ? localVarResp.getData() : null; } /** * Bookmarks by User * Returns Tweet objects that have been bookmarked by the requesting user * @param id The ID of the user for whom to return results (required) * @param maxResults The maximum number of results (optional) * @param paginationToken This parameter is used to get the next 'page' of results. (optional) * @param expansions A comma separated list of fields to expand. (optional) * @param tweetFields A comma separated list of Tweet fields to display. (optional) * @param userFields A comma separated list of User fields to display. (optional) * @param mediaFields A comma separated list of Media fields to display. (optional) * @param placeFields A comma separated list of Place fields to display. (optional) * @param pollFields A comma separated list of Poll fields to display. (optional) * @return ApiResponse<GenericTweetsTimelineResponse> * @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 The request was successful -
0 The request has failed. -
*/ public ApiResponse getUsersIdBookmarksWithHttpInfo(String id, Integer maxResults, String paginationToken, Set expansions, Set tweetFields, Set userFields, Set mediaFields, Set placeFields, Set pollFields) throws ApiException { okhttp3.Call localVarCall = getUsersIdBookmarksValidateBeforeCall(id, maxResults, paginationToken, expansions, tweetFields, userFields, mediaFields, placeFields, pollFields, null); try { Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } catch (ApiException e) { e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken(){}.getType())); e.setErrorObjectType(new GenericType(){}); throw e; } } /** * Bookmarks by User (asynchronously) * Returns Tweet objects that have been bookmarked by the requesting user * @param id The ID of the user for whom to return results (required) * @param maxResults The maximum number of results (optional) * @param paginationToken This parameter is used to get the next 'page' of results. (optional) * @param expansions A comma separated list of fields to expand. (optional) * @param tweetFields A comma separated list of Tweet fields to display. (optional) * @param userFields A comma separated list of User fields to display. (optional) * @param mediaFields A comma separated list of Media fields to display. (optional) * @param placeFields A comma separated list of Place fields to display. (optional) * @param pollFields A comma separated list of Poll fields to display. (optional) * @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 The request was successful -
0 The request has failed. -
*/ public okhttp3.Call getUsersIdBookmarksAsync(String id, Integer maxResults, String paginationToken, Set expansions, Set tweetFields, Set userFields, Set mediaFields, Set placeFields, Set pollFields, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = getUsersIdBookmarksValidateBeforeCall(id, maxResults, paginationToken, expansions, tweetFields, userFields, mediaFields, placeFields, pollFields, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } /** * Build call for postUsersIdBookmarks * @param addBookmarkRequest (required) * @param id The ID of the user for whom to add bookmarks (required) * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object * @http.response.details
Status Code Description Response Headers
200 The request was successful -
0 The request has failed. -
*/ public okhttp3.Call postUsersIdBookmarksCall(AddBookmarkRequest addBookmarkRequest, String id, final ApiCallback _callback) throws ApiException { Object localVarPostBody = addBookmarkRequest; // create path and map variables String localVarPath = "/2/users/{id}/bookmarks" .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); 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", "application/problem+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 (localVarHeaderParams != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } String[] localVarAuthNames = new String[] { "OAuth2UserToken" }; return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, reduceAuthNames(localVarAuthNames), _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call postUsersIdBookmarksValidateBeforeCall(AddBookmarkRequest addBookmarkRequest, String id, final ApiCallback _callback) throws ApiException { // verify the required parameter 'addBookmarkRequest' is set if (addBookmarkRequest == null) { throw new ApiException("Missing the required parameter 'addBookmarkRequest' when calling postUsersIdBookmarks(Async)"); } // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling postUsersIdBookmarks(Async)"); } okhttp3.Call localVarCall = postUsersIdBookmarksCall(addBookmarkRequest, id, _callback); return localVarCall; } /** * Add Tweet to Bookmarks * Adds a Tweet (ID in the body) to the requesting user's (in the path) bookmarks * @param addBookmarkRequest (required) * @param id The ID of the user for whom to add bookmarks (required) * @return BookmarkMutationResponse * @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 The request was successful -
0 The request has failed. -
*/ public BookmarkMutationResponse postUsersIdBookmarks(AddBookmarkRequest addBookmarkRequest, String id) throws ApiException { ApiResponse localVarResp; try{ localVarResp = postUsersIdBookmarksWithHttpInfo(addBookmarkRequest, id); } catch (ApiException e) { if (isOAUth2AutoRefreshToken() && e.getCode() == 401) { refreshToken(); localVarResp = postUsersIdBookmarksWithHttpInfo(addBookmarkRequest, id); } else { throw e; } } return localVarResp != null ? localVarResp.getData() : null; } /** * Add Tweet to Bookmarks * Adds a Tweet (ID in the body) to the requesting user's (in the path) bookmarks * @param addBookmarkRequest (required) * @param id The ID of the user for whom to add bookmarks (required) * @return ApiResponse<BookmarkMutationResponse> * @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 The request was successful -
0 The request has failed. -
*/ public ApiResponse postUsersIdBookmarksWithHttpInfo(AddBookmarkRequest addBookmarkRequest, String id) throws ApiException { okhttp3.Call localVarCall = postUsersIdBookmarksValidateBeforeCall(addBookmarkRequest, id, null); try { Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } catch (ApiException e) { e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken(){}.getType())); e.setErrorObjectType(new GenericType(){}); throw e; } } /** * Add Tweet to Bookmarks (asynchronously) * Adds a Tweet (ID in the body) to the requesting user's (in the path) bookmarks * @param addBookmarkRequest (required) * @param id The ID of the user for whom to add bookmarks (required) * @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 The request was successful -
0 The request has failed. -
*/ public okhttp3.Call postUsersIdBookmarksAsync(AddBookmarkRequest addBookmarkRequest, String id, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = postUsersIdBookmarksValidateBeforeCall(addBookmarkRequest, id, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } /** * Build call for usersIdBookmarksDelete * @param id The ID of the user whose bookmark is to be removed. (required) * @param tweetId The ID of the tweet that the user is removing from bookmarks (required) * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object * @http.response.details
Status Code Description Response Headers
200 The request was successful -
0 The request has failed. -
*/ public okhttp3.Call usersIdBookmarksDeleteCall(String id, String tweetId, final ApiCallback _callback) throws ApiException { Object localVarPostBody = null; // create path and map variables String localVarPath = "/2/users/{id}/bookmarks/{tweet_id}" .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())) .replaceAll("\\{" + "tweet_id" + "\\}", localVarApiClient.escapeString(tweetId.toString())); 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", "application/problem+json" }; final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) { localVarHeaderParams.put("Accept", localVarAccept); } final String[] localVarContentTypes = { }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); if (localVarHeaderParams != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } String[] localVarAuthNames = new String[] { "OAuth2UserToken" }; return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, reduceAuthNames(localVarAuthNames), _callback); } @SuppressWarnings("rawtypes") private okhttp3.Call usersIdBookmarksDeleteValidateBeforeCall(String id, String tweetId, final ApiCallback _callback) throws ApiException { // verify the required parameter 'id' is set if (id == null) { throw new ApiException("Missing the required parameter 'id' when calling usersIdBookmarksDelete(Async)"); } // verify the required parameter 'tweetId' is set if (tweetId == null) { throw new ApiException("Missing the required parameter 'tweetId' when calling usersIdBookmarksDelete(Async)"); } okhttp3.Call localVarCall = usersIdBookmarksDeleteCall(id, tweetId, _callback); return localVarCall; } /** * Remove a bookmarked Tweet * Removes a Tweet from the requesting user's bookmarked Tweets. * @param id The ID of the user whose bookmark is to be removed. (required) * @param tweetId The ID of the tweet that the user is removing from bookmarks (required) * @return BookmarkMutationResponse * @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 The request was successful -
0 The request has failed. -
*/ public BookmarkMutationResponse usersIdBookmarksDelete(String id, String tweetId) throws ApiException { ApiResponse localVarResp; try{ localVarResp = usersIdBookmarksDeleteWithHttpInfo(id, tweetId); } catch (ApiException e) { if (isOAUth2AutoRefreshToken() && e.getCode() == 401) { refreshToken(); localVarResp = usersIdBookmarksDeleteWithHttpInfo(id, tweetId); } else { throw e; } } return localVarResp != null ? localVarResp.getData() : null; } /** * Remove a bookmarked Tweet * Removes a Tweet from the requesting user's bookmarked Tweets. * @param id The ID of the user whose bookmark is to be removed. (required) * @param tweetId The ID of the tweet that the user is removing from bookmarks (required) * @return ApiResponse<BookmarkMutationResponse> * @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 The request was successful -
0 The request has failed. -
*/ public ApiResponse usersIdBookmarksDeleteWithHttpInfo(String id, String tweetId) throws ApiException { okhttp3.Call localVarCall = usersIdBookmarksDeleteValidateBeforeCall(id, tweetId, null); try { Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } catch (ApiException e) { e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken(){}.getType())); e.setErrorObjectType(new GenericType(){}); throw e; } } /** * Remove a bookmarked Tweet (asynchronously) * Removes a Tweet from the requesting user's bookmarked Tweets. * @param id The ID of the user whose bookmark is to be removed. (required) * @param tweetId The ID of the tweet that the user is removing from bookmarks (required) * @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 The request was successful -
0 The request has failed. -
*/ public okhttp3.Call usersIdBookmarksDeleteAsync(String id, String tweetId, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = usersIdBookmarksDeleteValidateBeforeCall(id, tweetId, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy