diff --git a/README.md b/README.md index 7b1b1d5..f1f0aac 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ You can find examples of using the SDK under the [examples/](examples/) director **Note: Only Twitter API V2 is supported** -- API version: 2.51 +- API version: 2.55 Twitter API v2 available endpoints @@ -61,7 +61,7 @@ Add this dependency to your project's POM: com.twitter twitter-api-java-sdk - 2.0.3 + 2.0.4 ``` @@ -76,7 +76,7 @@ mavenLocal() // Needed if the 'twitter-api-java-sdk' jar has been publishe } dependencies { -implementation "com.twitter:twitter-api-java-sdk:2.0.3" +implementation "com.twitter:twitter-api-java-sdk:2.0.4" } ``` @@ -90,7 +90,7 @@ mvn clean package Then manually install the following JARs: -* `target/twitter-api-java-sdk-2.0.3.jar` +* `target/twitter-api-java-sdk-2.0.4.jar` * `target/lib/*.jar` ## Twitter Credentials @@ -278,8 +278,15 @@ Class | Method | HTTP request | Description *ComplianceApi* | [**createBatchComplianceJob**](docs/ComplianceApi.md#createBatchComplianceJob) | **POST** /2/compliance/jobs | Create compliance job *ComplianceApi* | [**getBatchComplianceJob**](docs/ComplianceApi.md#getBatchComplianceJob) | **GET** /2/compliance/jobs/{id} | Get Compliance Job *ComplianceApi* | [**getTweetsComplianceStream**](docs/ComplianceApi.md#getTweetsComplianceStream) | **GET** /2/tweets/compliance/stream | Tweets Compliance stream +*ComplianceApi* | [**getTweetsLabelStream**](docs/ComplianceApi.md#getTweetsLabelStream) | **GET** /2/tweets/label/stream | Tweets Label stream *ComplianceApi* | [**getUsersComplianceStream**](docs/ComplianceApi.md#getUsersComplianceStream) | **GET** /2/users/compliance/stream | Users Compliance stream *ComplianceApi* | [**listBatchComplianceJobs**](docs/ComplianceApi.md#listBatchComplianceJobs) | **GET** /2/compliance/jobs | List Compliance Jobs +*DirectMessagesApi* | [**dmConversationByIdEventIdCreate**](docs/DirectMessagesApi.md#dmConversationByIdEventIdCreate) | **POST** /2/dm_conversations/{dm_conversation_id}/messages | Send a new message to a DM Conversation +*DirectMessagesApi* | [**dmConversationIdCreate**](docs/DirectMessagesApi.md#dmConversationIdCreate) | **POST** /2/dm_conversations | Create a new DM Conversation +*DirectMessagesApi* | [**dmConversationWithUserEventIdCreate**](docs/DirectMessagesApi.md#dmConversationWithUserEventIdCreate) | **POST** /2/dm_conversations/with/{participant_id}/messages | Send a new message to a user +*DirectMessagesApi* | [**getDmConversationsIdDmEvents**](docs/DirectMessagesApi.md#getDmConversationsIdDmEvents) | **GET** /2/dm_conversations/{id}/dm_events | Get DM Events for a DM Conversation +*DirectMessagesApi* | [**getDmConversationsWithParticipantIdDmEvents**](docs/DirectMessagesApi.md#getDmConversationsWithParticipantIdDmEvents) | **GET** /2/dm_conversations/with/{participant_id}/dm_events | Get DM Events for a DM Conversation +*DirectMessagesApi* | [**getDmEvents**](docs/DirectMessagesApi.md#getDmEvents) | **GET** /2/dm_events | Get recent DM Events *GeneralApi* | [**getOpenApiSpec**](docs/GeneralApi.md#getOpenApiSpec) | **GET** /2/openapi.json | Returns the OpenAPI Specification document. *ListsApi* | [**getUserListMemberships**](docs/ListsApi.md#getUserListMemberships) | **GET** /2/users/{id}/list_memberships | Get a User's List Memberships *ListsApi* | [**listAddMember**](docs/ListsApi.md#listAddMember) | **POST** /2/lists/{id}/members | Add a List member @@ -376,12 +383,21 @@ Class | Method | HTTP request | Description - [ContextAnnotation](docs/ContextAnnotation.md) - [ContextAnnotationDomainFields](docs/ContextAnnotationDomainFields.md) - [ContextAnnotationEntityFields](docs/ContextAnnotationEntityFields.md) + - [CreateAttachmentsMessageRequest](docs/CreateAttachmentsMessageRequest.md) - [CreateComplianceJobRequest](docs/CreateComplianceJobRequest.md) - [CreateComplianceJobResponse](docs/CreateComplianceJobResponse.md) + - [CreateDmConversationRequest](docs/CreateDmConversationRequest.md) + - [CreateDmEventResponse](docs/CreateDmEventResponse.md) + - [CreateDmEventResponseData](docs/CreateDmEventResponseData.md) + - [CreateMessageRequest](docs/CreateMessageRequest.md) + - [CreateTextMessageRequest](docs/CreateTextMessageRequest.md) - [DeleteRulesRequest](docs/DeleteRulesRequest.md) - [DeleteRulesRequestDelete](docs/DeleteRulesRequestDelete.md) - [DisallowedResourceProblem](docs/DisallowedResourceProblem.md) - [DisallowedResourceProblemAllOf](docs/DisallowedResourceProblemAllOf.md) + - [DmEvent](docs/DmEvent.md) + - [DmEventAttachments](docs/DmEventAttachments.md) + - [DmMediaAttachment](docs/DmMediaAttachment.md) - [DuplicateRuleProblem](docs/DuplicateRuleProblem.md) - [DuplicateRuleProblemAllOf](docs/DuplicateRuleProblemAllOf.md) - [EntityIndicesInclusiveExclusive](docs/EntityIndicesInclusiveExclusive.md) @@ -400,6 +416,9 @@ Class | Method | HTTP request | Description - [Get2ComplianceJobsIdResponse](docs/Get2ComplianceJobsIdResponse.md) - [Get2ComplianceJobsResponse](docs/Get2ComplianceJobsResponse.md) - [Get2ComplianceJobsResponseMeta](docs/Get2ComplianceJobsResponseMeta.md) + - [Get2DmConversationsIdDmEventsResponse](docs/Get2DmConversationsIdDmEventsResponse.md) + - [Get2DmConversationsWithParticipantIdDmEventsResponse](docs/Get2DmConversationsWithParticipantIdDmEventsResponse.md) + - [Get2DmEventsResponse](docs/Get2DmEventsResponse.md) - [Get2ListsIdFollowersResponse](docs/Get2ListsIdFollowersResponse.md) - [Get2ListsIdFollowersResponseMeta](docs/Get2ListsIdFollowersResponseMeta.md) - [Get2ListsIdMembersResponse](docs/Get2ListsIdMembersResponse.md) @@ -488,12 +507,8 @@ Class | Method | HTTP request | Description - [Poll](docs/Poll.md) - [PollOption](docs/PollOption.md) - [Problem](docs/Problem.md) - - [ProblemErrors](docs/ProblemErrors.md) - [ProblemOrError](docs/ProblemOrError.md) - [ReplySettings](docs/ReplySettings.md) - - [ReportUsersRequest](docs/ReportUsersRequest.md) - - [ReportUsersResponse](docs/ReportUsersResponse.md) - - [ReportUsersResponseData](docs/ReportUsersResponseData.md) - [ResourceNotFoundProblem](docs/ResourceNotFoundProblem.md) - [ResourceNotFoundProblemAllOf](docs/ResourceNotFoundProblemAllOf.md) - [ResourceUnauthorizedProblem](docs/ResourceUnauthorizedProblem.md) @@ -540,13 +555,20 @@ Class | Method | HTTP request | Description - [TweetHideRequest](docs/TweetHideRequest.md) - [TweetHideResponse](docs/TweetHideResponse.md) - [TweetHideResponseData](docs/TweetHideResponseData.md) + - [TweetLabelData](docs/TweetLabelData.md) + - [TweetLabelStreamResponse](docs/TweetLabelStreamResponse.md) + - [TweetLabelStreamResponseOneOf](docs/TweetLabelStreamResponseOneOf.md) - [TweetNonPublicMetrics](docs/TweetNonPublicMetrics.md) + - [TweetNotice](docs/TweetNotice.md) + - [TweetNoticeSchema](docs/TweetNoticeSchema.md) - [TweetOrganicMetrics](docs/TweetOrganicMetrics.md) - [TweetPromotedMetrics](docs/TweetPromotedMetrics.md) - [TweetPublicMetrics](docs/TweetPublicMetrics.md) - [TweetReferencedTweets](docs/TweetReferencedTweets.md) - [TweetTakedownComplianceSchema](docs/TweetTakedownComplianceSchema.md) - [TweetUndropComplianceSchema](docs/TweetUndropComplianceSchema.md) + - [TweetUnviewable](docs/TweetUnviewable.md) + - [TweetUnviewableSchema](docs/TweetUnviewableSchema.md) - [TweetWithheld](docs/TweetWithheld.md) - [TweetWithheldComplianceSchema](docs/TweetWithheldComplianceSchema.md) - [UnsupportedAuthenticationProblem](docs/UnsupportedAuthenticationProblem.md) diff --git a/docs/ComplianceApi.md b/docs/ComplianceApi.md index 0d2386a..75ee26c 100644 --- a/docs/ComplianceApi.md +++ b/docs/ComplianceApi.md @@ -7,6 +7,7 @@ All URIs are relative to *https://api.twitter.com* | [**createBatchComplianceJob**](ComplianceApi.md#createBatchComplianceJob) | **POST** /2/compliance/jobs | Create compliance job | | [**getBatchComplianceJob**](ComplianceApi.md#getBatchComplianceJob) | **GET** /2/compliance/jobs/{id} | Get Compliance Job | | [**getTweetsComplianceStream**](ComplianceApi.md#getTweetsComplianceStream) | **GET** /2/tweets/compliance/stream | Tweets Compliance stream | +| [**getTweetsLabelStream**](ComplianceApi.md#getTweetsLabelStream) | **GET** /2/tweets/label/stream | Tweets Label stream | | [**getUsersComplianceStream**](ComplianceApi.md#getUsersComplianceStream) | **GET** /2/users/compliance/stream | Users Compliance stream | | [**listBatchComplianceJobs**](ComplianceApi.md#listBatchComplianceJobs) | **GET** /2/compliance/jobs | List Compliance Jobs | @@ -289,6 +290,117 @@ public class Example { | **200** | The request has succeeded. | - | | **0** | The request has failed. | - | + +# **getTweetsLabelStream** +> TweetLabelStreamResponse getTweetsLabelStream().backfillMinutes(backfillMinutes).startTime(startTime).endTime(endTime).execute(); + +Tweets Label stream + +Streams 100% of labeling events applied to Tweets + +### Example +```java +// Import classes: +import com.twitter.clientlib.ApiClient; +import com.twitter.clientlib.ApiException; +import com.twitter.clientlib.Configuration; +import com.twitter.clientlib.auth.*; +import com.twitter.clientlib.model.*; +import com.twitter.clientlib.TwitterCredentialsOAuth2; +import com.twitter.clientlib.TwitterCredentialsBearer; +import com.twitter.clientlib.api.TwitterApi; + +import com.twitter.clientlib.api.ComplianceApi; +import java.io.InputStream; +import com.google.common.reflect.TypeToken; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.lang.reflect.Type; +import java.util.List; +import java.util.Set; +import java.util.Arrays; +import java.util.HashSet; +import java.time.OffsetDateTime; + +public class Example { + public static void main(String[] args) { + // Set the credentials based on the API's "security" tag values. + // Check the API definition in https://api.twitter.com/2/openapi.json + // When multiple options exist, the SDK supports only "OAuth2UserToken" or "BearerToken" + + // Uncomment and set the credentials configuration + + // Configure HTTP bearer authorization: + // TwitterCredentialsBearer credentials = new TwitterCredentialsBearer(System.getenv("TWITTER_BEARER_TOKEN")); + TwitterApi apiInstance = new TwitterApi(credentials); + + // Set the params values + Integer backfillMinutes = 56; // Integer | The number of minutes of backfill requested. + OffsetDateTime startTime = OffsetDateTime.parse("2021-02-01T18:40:40.000Z"); // OffsetDateTime | YYYY-MM-DDTHH:mm:ssZ. The earliest UTC timestamp from which the Tweet labels will be provided. + OffsetDateTime endTime = OffsetDateTime.parse("2021-02-01T18:40:40.000Z"); // OffsetDateTime | YYYY-MM-DDTHH:mm:ssZ. The latest UTC timestamp from which the Tweet labels will be provided. + try { + InputStream result = apiInstance.compliance().getTweetsLabelStream() + .backfillMinutes(backfillMinutes) + .startTime(startTime) + .endTime(endTime) + .execute(); + try{ + JSON json = new JSON(); + Type localVarReturnType = new TypeToken(){}.getType(); + BufferedReader reader = new BufferedReader(new InputStreamReader(result)); + String line = reader.readLine(); + while (line != null) { + if(line.isEmpty()) { + System.out.println("==> Empty line"); + line = reader.readLine(); + continue; + } + Object jsonObject = json.getGson().fromJson(line, localVarReturnType); + System.out.println(jsonObject != null ? jsonObject.toString() : "Null object"); + line = reader.readLine(); + } + }catch (Exception e) { + e.printStackTrace(); + System.out.println(e); + } + } catch (ApiException e) { + System.err.println("Exception when calling ComplianceApi#getTweetsLabelStream"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **backfillMinutes** | **Integer**| The number of minutes of backfill requested. | [optional] | +| **startTime** | **OffsetDateTime**| YYYY-MM-DDTHH:mm:ssZ. The earliest UTC timestamp from which the Tweet labels will be provided. | [optional] | +| **endTime** | **OffsetDateTime**| YYYY-MM-DDTHH:mm:ssZ. The latest UTC timestamp from which the Tweet labels will be provided. | [optional] | + +### Return type + +[**TweetLabelStreamResponse**](TweetLabelStreamResponse.md) + +### Authorization + +[BearerToken](../README.md#BearerToken) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/problem+json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | The request has succeeded. | - | +| **0** | The request has failed. | - | + # **getUsersComplianceStream** > UserComplianceStreamResponse getUsersComplianceStream(partition).backfillMinutes(backfillMinutes).startTime(startTime).endTime(endTime).execute(); diff --git a/docs/CreateAttachmentsMessageRequest.md b/docs/CreateAttachmentsMessageRequest.md new file mode 100644 index 0000000..7cb2625 --- /dev/null +++ b/docs/CreateAttachmentsMessageRequest.md @@ -0,0 +1,14 @@ + + +# CreateAttachmentsMessageRequest + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**attachments** | [**List<DmMediaAttachment>**](DmMediaAttachment.md) | Attachments to a DM Event. | | +|**text** | **String** | Text of the message. | [optional] | + + + diff --git a/docs/CreateDmConversationRequest.md b/docs/CreateDmConversationRequest.md new file mode 100644 index 0000000..0f124bd --- /dev/null +++ b/docs/CreateDmConversationRequest.md @@ -0,0 +1,23 @@ + + +# CreateDmConversationRequest + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**conversationType** | [**ConversationTypeEnum**](#ConversationTypeEnum) | The conversation type that is being created. | | +|**message** | [**CreateMessageRequest**](CreateMessageRequest.md) | | | +|**participantIds** | **List<String>** | Participants for the DM Conversation. | | + + + +## Enum: ConversationTypeEnum + +| Name | Value | +|---- | -----| +| GROUP | "Group" | + + + diff --git a/docs/CreateDmEventResponse.md b/docs/CreateDmEventResponse.md new file mode 100644 index 0000000..91dbbc7 --- /dev/null +++ b/docs/CreateDmEventResponse.md @@ -0,0 +1,14 @@ + + +# CreateDmEventResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**data** | [**CreateDmEventResponseData**](CreateDmEventResponseData.md) | | [optional] | +|**errors** | [**List<Problem>**](Problem.md) | | [optional] | + + + diff --git a/docs/CreateDmEventResponseData.md b/docs/CreateDmEventResponseData.md new file mode 100644 index 0000000..5a24a27 --- /dev/null +++ b/docs/CreateDmEventResponseData.md @@ -0,0 +1,14 @@ + + +# CreateDmEventResponseData + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**dmConversationId** | **String** | Unique identifier of a DM conversation. This can either be a numeric string, or a pair of numeric strings separated by a '-' character in the case of one-on-one DM Conversations. | | +|**dmEventId** | **String** | Unique identifier of a DM Event. | | + + + diff --git a/docs/CreateMessageRequest.md b/docs/CreateMessageRequest.md new file mode 100644 index 0000000..6954e13 --- /dev/null +++ b/docs/CreateMessageRequest.md @@ -0,0 +1,14 @@ + + +# CreateMessageRequest + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**attachments** | [**List<DmMediaAttachment>**](DmMediaAttachment.md) | Attachments to a DM Event. | | +|**text** | **String** | Text of the message. | | + + + diff --git a/docs/CreateTextMessageRequest.md b/docs/CreateTextMessageRequest.md new file mode 100644 index 0000000..853a2e0 --- /dev/null +++ b/docs/CreateTextMessageRequest.md @@ -0,0 +1,14 @@ + + +# CreateTextMessageRequest + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**attachments** | [**List<DmMediaAttachment>**](DmMediaAttachment.md) | Attachments to a DM Event. | [optional] | +|**text** | **String** | Text of the message. | | + + + diff --git a/docs/DirectMessagesApi.md b/docs/DirectMessagesApi.md new file mode 100644 index 0000000..632394e --- /dev/null +++ b/docs/DirectMessagesApi.md @@ -0,0 +1,595 @@ +# DirectMessagesApi + +All URIs are relative to *https://api.twitter.com* + +| Method | HTTP request | Description | +|------------- | ------------- | -------------| +| [**dmConversationByIdEventIdCreate**](DirectMessagesApi.md#dmConversationByIdEventIdCreate) | **POST** /2/dm_conversations/{dm_conversation_id}/messages | Send a new message to a DM Conversation | +| [**dmConversationIdCreate**](DirectMessagesApi.md#dmConversationIdCreate) | **POST** /2/dm_conversations | Create a new DM Conversation | +| [**dmConversationWithUserEventIdCreate**](DirectMessagesApi.md#dmConversationWithUserEventIdCreate) | **POST** /2/dm_conversations/with/{participant_id}/messages | Send a new message to a user | +| [**getDmConversationsIdDmEvents**](DirectMessagesApi.md#getDmConversationsIdDmEvents) | **GET** /2/dm_conversations/{id}/dm_events | Get DM Events for a DM Conversation | +| [**getDmConversationsWithParticipantIdDmEvents**](DirectMessagesApi.md#getDmConversationsWithParticipantIdDmEvents) | **GET** /2/dm_conversations/with/{participant_id}/dm_events | Get DM Events for a DM Conversation | +| [**getDmEvents**](DirectMessagesApi.md#getDmEvents) | **GET** /2/dm_events | Get recent DM Events | + + + +# **dmConversationByIdEventIdCreate** +> CreateDmEventResponse dmConversationByIdEventIdCreate(dmConversationId).createMessageRequest(createMessageRequest).execute(); + +Send a new message to a DM Conversation + +Creates a new message for a DM Conversation specified by DM Conversation ID + +### Example +```java +// Import classes: +import com.twitter.clientlib.ApiClient; +import com.twitter.clientlib.ApiException; +import com.twitter.clientlib.Configuration; +import com.twitter.clientlib.auth.*; +import com.twitter.clientlib.model.*; +import com.twitter.clientlib.TwitterCredentialsOAuth2; +import com.twitter.clientlib.TwitterCredentialsBearer; +import com.twitter.clientlib.api.TwitterApi; + +import com.twitter.clientlib.api.DirectMessagesApi; +import java.util.List; +import java.util.Set; +import java.util.Arrays; +import java.util.HashSet; +import java.time.OffsetDateTime; + +public class Example { + public static void main(String[] args) { + // Set the credentials based on the API's "security" tag values. + // Check the API definition in https://api.twitter.com/2/openapi.json + // When multiple options exist, the SDK supports only "OAuth2UserToken" or "BearerToken" + + // Uncomment and set the credentials configuration + + // Configure OAuth2 access token for authorization: + // TwitterCredentialsOAuth2 credentials = new TwitterCredentialsOAuth2(System.getenv("TWITTER_OAUTH2_CLIENT_ID"), + // System.getenv("TWITTER_OAUTH2_CLIENT_SECRET"), + // System.getenv("TWITTER_OAUTH2_ACCESS_TOKEN"), + // System.getenv("TWITTER_OAUTH2_REFRESH_TOKEN")); + TwitterApi apiInstance = new TwitterApi(credentials); + + // Set the params values + CreateMessageRequest createMessageRequest = new CreateMessageRequest(); // CreateMessageRequest | + String dmConversationId = "dmConversationId_example"; // String | The DM Conversation ID. + try { + CreateDmEventResponse result = apiInstance.directMessages().dmConversationByIdEventIdCreate(dmConversationId) + .createMessageRequest(createMessageRequest) + .execute(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DirectMessagesApi#dmConversationByIdEventIdCreate"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **createMessageRequest** | [**CreateMessageRequest**](CreateMessageRequest.md)| | [optional] | +| **dmConversationId** | **String**| The DM Conversation ID. | | + +### Return type + +[**CreateDmEventResponse**](CreateDmEventResponse.md) + +### Authorization + +[OAuth2UserToken](../README.md#OAuth2UserToken), [UserToken](../README.md#UserToken) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json, application/problem+json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **201** | The request has succeeded. | - | +| **0** | The request has failed. | - | + + +# **dmConversationIdCreate** +> CreateDmEventResponse dmConversationIdCreate().createDmConversationRequest(createDmConversationRequest).execute(); + +Create a new DM Conversation + +Creates a new DM Conversation. + +### Example +```java +// Import classes: +import com.twitter.clientlib.ApiClient; +import com.twitter.clientlib.ApiException; +import com.twitter.clientlib.Configuration; +import com.twitter.clientlib.auth.*; +import com.twitter.clientlib.model.*; +import com.twitter.clientlib.TwitterCredentialsOAuth2; +import com.twitter.clientlib.TwitterCredentialsBearer; +import com.twitter.clientlib.api.TwitterApi; + +import com.twitter.clientlib.api.DirectMessagesApi; +import java.util.List; +import java.util.Set; +import java.util.Arrays; +import java.util.HashSet; +import java.time.OffsetDateTime; + +public class Example { + public static void main(String[] args) { + // Set the credentials based on the API's "security" tag values. + // Check the API definition in https://api.twitter.com/2/openapi.json + // When multiple options exist, the SDK supports only "OAuth2UserToken" or "BearerToken" + + // Uncomment and set the credentials configuration + + // Configure OAuth2 access token for authorization: + // TwitterCredentialsOAuth2 credentials = new TwitterCredentialsOAuth2(System.getenv("TWITTER_OAUTH2_CLIENT_ID"), + // System.getenv("TWITTER_OAUTH2_CLIENT_SECRET"), + // System.getenv("TWITTER_OAUTH2_ACCESS_TOKEN"), + // System.getenv("TWITTER_OAUTH2_REFRESH_TOKEN")); + TwitterApi apiInstance = new TwitterApi(credentials); + + // Set the params values + CreateDmConversationRequest createDmConversationRequest = new CreateDmConversationRequest(); // CreateDmConversationRequest | + try { + CreateDmEventResponse result = apiInstance.directMessages().dmConversationIdCreate() + .createDmConversationRequest(createDmConversationRequest) + .execute(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DirectMessagesApi#dmConversationIdCreate"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **createDmConversationRequest** | [**CreateDmConversationRequest**](CreateDmConversationRequest.md)| | [optional] | + +### Return type + +[**CreateDmEventResponse**](CreateDmEventResponse.md) + +### Authorization + +[OAuth2UserToken](../README.md#OAuth2UserToken), [UserToken](../README.md#UserToken) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json, application/problem+json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **201** | The request has succeeded. | - | +| **0** | The request has failed. | - | + + +# **dmConversationWithUserEventIdCreate** +> CreateDmEventResponse dmConversationWithUserEventIdCreate(participantId).createMessageRequest(createMessageRequest).execute(); + +Send a new message to a user + +Creates a new message for a DM Conversation with a participant user by ID + +### Example +```java +// Import classes: +import com.twitter.clientlib.ApiClient; +import com.twitter.clientlib.ApiException; +import com.twitter.clientlib.Configuration; +import com.twitter.clientlib.auth.*; +import com.twitter.clientlib.model.*; +import com.twitter.clientlib.TwitterCredentialsOAuth2; +import com.twitter.clientlib.TwitterCredentialsBearer; +import com.twitter.clientlib.api.TwitterApi; + +import com.twitter.clientlib.api.DirectMessagesApi; +import java.util.List; +import java.util.Set; +import java.util.Arrays; +import java.util.HashSet; +import java.time.OffsetDateTime; + +public class Example { + public static void main(String[] args) { + // Set the credentials based on the API's "security" tag values. + // Check the API definition in https://api.twitter.com/2/openapi.json + // When multiple options exist, the SDK supports only "OAuth2UserToken" or "BearerToken" + + // Uncomment and set the credentials configuration + + // Configure OAuth2 access token for authorization: + // TwitterCredentialsOAuth2 credentials = new TwitterCredentialsOAuth2(System.getenv("TWITTER_OAUTH2_CLIENT_ID"), + // System.getenv("TWITTER_OAUTH2_CLIENT_SECRET"), + // System.getenv("TWITTER_OAUTH2_ACCESS_TOKEN"), + // System.getenv("TWITTER_OAUTH2_REFRESH_TOKEN")); + TwitterApi apiInstance = new TwitterApi(credentials); + + // Set the params values + CreateMessageRequest createMessageRequest = new CreateMessageRequest(); // CreateMessageRequest | + String participantId = "participantId_example"; // String | The ID of the recipient user that will receive the DM. + try { + CreateDmEventResponse result = apiInstance.directMessages().dmConversationWithUserEventIdCreate(participantId) + .createMessageRequest(createMessageRequest) + .execute(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DirectMessagesApi#dmConversationWithUserEventIdCreate"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **createMessageRequest** | [**CreateMessageRequest**](CreateMessageRequest.md)| | [optional] | +| **participantId** | **String**| The ID of the recipient user that will receive the DM. | | + +### Return type + +[**CreateDmEventResponse**](CreateDmEventResponse.md) + +### Authorization + +[OAuth2UserToken](../README.md#OAuth2UserToken), [UserToken](../README.md#UserToken) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json, application/problem+json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **201** | The request has succeeded. | - | +| **0** | The request has failed. | - | + + +# **getDmConversationsIdDmEvents** +> Get2DmConversationsIdDmEventsResponse getDmConversationsIdDmEvents(id).maxResults(maxResults).paginationToken(paginationToken).eventTypes(eventTypes).dmEventFields(dmEventFields).expansions(expansions).mediaFields(mediaFields).userFields(userFields).tweetFields(tweetFields).execute(); + +Get DM Events for a DM Conversation + +Returns DM Events for a DM Conversation + +### Example +```java +// Import classes: +import com.twitter.clientlib.ApiClient; +import com.twitter.clientlib.ApiException; +import com.twitter.clientlib.Configuration; +import com.twitter.clientlib.auth.*; +import com.twitter.clientlib.model.*; +import com.twitter.clientlib.TwitterCredentialsOAuth2; +import com.twitter.clientlib.TwitterCredentialsBearer; +import com.twitter.clientlib.api.TwitterApi; + +import com.twitter.clientlib.api.DirectMessagesApi; +import java.util.List; +import java.util.Set; +import java.util.Arrays; +import java.util.HashSet; +import java.time.OffsetDateTime; + +public class Example { + public static void main(String[] args) { + // Set the credentials based on the API's "security" tag values. + // Check the API definition in https://api.twitter.com/2/openapi.json + // When multiple options exist, the SDK supports only "OAuth2UserToken" or "BearerToken" + + // Uncomment and set the credentials configuration + + // Configure OAuth2 access token for authorization: + // TwitterCredentialsOAuth2 credentials = new TwitterCredentialsOAuth2(System.getenv("TWITTER_OAUTH2_CLIENT_ID"), + // System.getenv("TWITTER_OAUTH2_CLIENT_SECRET"), + // System.getenv("TWITTER_OAUTH2_ACCESS_TOKEN"), + // System.getenv("TWITTER_OAUTH2_REFRESH_TOKEN")); + TwitterApi apiInstance = new TwitterApi(credentials); + + // Set the params values + String id = "id_example"; // String | The DM Conversation ID. + Integer maxResults = 100; // Integer | The maximum number of results. + String paginationToken = "paginationToken_example"; // String | This parameter is used to get a specified 'page' of results. + Set eventTypes = new HashSet<>(Arrays.asList()); // Set | The set of event_types to include in the results. + Set dmEventFields = new HashSet<>(Arrays.asList()); // Set | A comma separated list of DmEvent fields to display. + Set expansions = new HashSet<>(Arrays.asList()); // Set | A comma separated list of fields to expand. + Set mediaFields = new HashSet<>(Arrays.asList()); // Set | A comma separated list of Media fields to display. + Set userFields = new HashSet<>(Arrays.asList()); // Set | A comma separated list of User fields to display. + Set tweetFields = new HashSet<>(Arrays.asList()); // Set | A comma separated list of Tweet fields to display. + try { + Get2DmConversationsIdDmEventsResponse result = apiInstance.directMessages().getDmConversationsIdDmEvents(id) + .maxResults(maxResults) + .paginationToken(paginationToken) + .eventTypes(eventTypes) + .dmEventFields(dmEventFields) + .expansions(expansions) + .mediaFields(mediaFields) + .userFields(userFields) + .tweetFields(tweetFields) + .execute(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DirectMessagesApi#getDmConversationsIdDmEvents"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **id** | **String**| The DM Conversation ID. | | +| **maxResults** | **Integer**| The maximum number of results. | [optional] [default to 100] | +| **paginationToken** | **String**| This parameter is used to get a specified 'page' of results. | [optional] | +| **eventTypes** | [**Set<String>**](String.md)| The set of event_types to include in the results. | [optional] [enum: MessageCreate, ParticipantsJoin, ParticipantsLeave] | +| **dmEventFields** | [**Set<String>**](String.md)| A comma separated list of DmEvent fields to display. | [optional] [enum: attachments, created_at, dm_conversation_id, event_type, id, participant_ids, referenced_tweets, sender_id, text] | +| **expansions** | [**Set<String>**](String.md)| A comma separated list of fields to expand. | [optional] [enum: attachments.media_keys, participant_ids, referenced_tweets.id, sender_id] | +| **mediaFields** | [**Set<String>**](String.md)| A comma separated list of Media fields to display. | [optional] [enum: alt_text, duration_ms, height, media_key, non_public_metrics, organic_metrics, preview_image_url, promoted_metrics, public_metrics, type, url, variants, width] | +| **userFields** | [**Set<String>**](String.md)| A comma separated list of User fields to display. | [optional] [enum: created_at, description, entities, id, location, name, pinned_tweet_id, profile_image_url, protected, public_metrics, url, username, verified, withheld] | +| **tweetFields** | [**Set<String>**](String.md)| A comma separated list of Tweet fields to display. | [optional] [enum: attachments, author_id, context_annotations, conversation_id, created_at, edit_controls, edit_history_tweet_ids, entities, geo, id, in_reply_to_user_id, lang, non_public_metrics, organic_metrics, possibly_sensitive, promoted_metrics, public_metrics, referenced_tweets, reply_settings, source, text, withheld] | + +### Return type + +[**Get2DmConversationsIdDmEventsResponse**](Get2DmConversationsIdDmEventsResponse.md) + +### Authorization + +[OAuth2UserToken](../README.md#OAuth2UserToken), [UserToken](../README.md#UserToken) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/problem+json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | The request has succeeded. | - | +| **0** | The request has failed. | - | + + +# **getDmConversationsWithParticipantIdDmEvents** +> Get2DmConversationsWithParticipantIdDmEventsResponse getDmConversationsWithParticipantIdDmEvents(participantId).maxResults(maxResults).paginationToken(paginationToken).eventTypes(eventTypes).dmEventFields(dmEventFields).expansions(expansions).mediaFields(mediaFields).userFields(userFields).tweetFields(tweetFields).execute(); + +Get DM Events for a DM Conversation + +Returns DM Events for a DM Conversation + +### Example +```java +// Import classes: +import com.twitter.clientlib.ApiClient; +import com.twitter.clientlib.ApiException; +import com.twitter.clientlib.Configuration; +import com.twitter.clientlib.auth.*; +import com.twitter.clientlib.model.*; +import com.twitter.clientlib.TwitterCredentialsOAuth2; +import com.twitter.clientlib.TwitterCredentialsBearer; +import com.twitter.clientlib.api.TwitterApi; + +import com.twitter.clientlib.api.DirectMessagesApi; +import java.util.List; +import java.util.Set; +import java.util.Arrays; +import java.util.HashSet; +import java.time.OffsetDateTime; + +public class Example { + public static void main(String[] args) { + // Set the credentials based on the API's "security" tag values. + // Check the API definition in https://api.twitter.com/2/openapi.json + // When multiple options exist, the SDK supports only "OAuth2UserToken" or "BearerToken" + + // Uncomment and set the credentials configuration + + // Configure OAuth2 access token for authorization: + // TwitterCredentialsOAuth2 credentials = new TwitterCredentialsOAuth2(System.getenv("TWITTER_OAUTH2_CLIENT_ID"), + // System.getenv("TWITTER_OAUTH2_CLIENT_SECRET"), + // System.getenv("TWITTER_OAUTH2_ACCESS_TOKEN"), + // System.getenv("TWITTER_OAUTH2_REFRESH_TOKEN")); + TwitterApi apiInstance = new TwitterApi(credentials); + + // Set the params values + String participantId = "participantId_example"; // String | The ID of the participant user for the One to One DM conversation. + Integer maxResults = 100; // Integer | The maximum number of results. + String paginationToken = "paginationToken_example"; // String | This parameter is used to get a specified 'page' of results. + Set eventTypes = new HashSet<>(Arrays.asList()); // Set | The set of event_types to include in the results. + Set dmEventFields = new HashSet<>(Arrays.asList()); // Set | A comma separated list of DmEvent fields to display. + Set expansions = new HashSet<>(Arrays.asList()); // Set | A comma separated list of fields to expand. + Set mediaFields = new HashSet<>(Arrays.asList()); // Set | A comma separated list of Media fields to display. + Set userFields = new HashSet<>(Arrays.asList()); // Set | A comma separated list of User fields to display. + Set tweetFields = new HashSet<>(Arrays.asList()); // Set | A comma separated list of Tweet fields to display. + try { + Get2DmConversationsWithParticipantIdDmEventsResponse result = apiInstance.directMessages().getDmConversationsWithParticipantIdDmEvents(participantId) + .maxResults(maxResults) + .paginationToken(paginationToken) + .eventTypes(eventTypes) + .dmEventFields(dmEventFields) + .expansions(expansions) + .mediaFields(mediaFields) + .userFields(userFields) + .tweetFields(tweetFields) + .execute(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DirectMessagesApi#getDmConversationsWithParticipantIdDmEvents"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **participantId** | **String**| The ID of the participant user for the One to One DM conversation. | | +| **maxResults** | **Integer**| The maximum number of results. | [optional] [default to 100] | +| **paginationToken** | **String**| This parameter is used to get a specified 'page' of results. | [optional] | +| **eventTypes** | [**Set<String>**](String.md)| The set of event_types to include in the results. | [optional] [enum: MessageCreate, ParticipantsJoin, ParticipantsLeave] | +| **dmEventFields** | [**Set<String>**](String.md)| A comma separated list of DmEvent fields to display. | [optional] [enum: attachments, created_at, dm_conversation_id, event_type, id, participant_ids, referenced_tweets, sender_id, text] | +| **expansions** | [**Set<String>**](String.md)| A comma separated list of fields to expand. | [optional] [enum: attachments.media_keys, participant_ids, referenced_tweets.id, sender_id] | +| **mediaFields** | [**Set<String>**](String.md)| A comma separated list of Media fields to display. | [optional] [enum: alt_text, duration_ms, height, media_key, non_public_metrics, organic_metrics, preview_image_url, promoted_metrics, public_metrics, type, url, variants, width] | +| **userFields** | [**Set<String>**](String.md)| A comma separated list of User fields to display. | [optional] [enum: created_at, description, entities, id, location, name, pinned_tweet_id, profile_image_url, protected, public_metrics, url, username, verified, withheld] | +| **tweetFields** | [**Set<String>**](String.md)| A comma separated list of Tweet fields to display. | [optional] [enum: attachments, author_id, context_annotations, conversation_id, created_at, edit_controls, edit_history_tweet_ids, entities, geo, id, in_reply_to_user_id, lang, non_public_metrics, organic_metrics, possibly_sensitive, promoted_metrics, public_metrics, referenced_tweets, reply_settings, source, text, withheld] | + +### Return type + +[**Get2DmConversationsWithParticipantIdDmEventsResponse**](Get2DmConversationsWithParticipantIdDmEventsResponse.md) + +### Authorization + +[OAuth2UserToken](../README.md#OAuth2UserToken), [UserToken](../README.md#UserToken) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/problem+json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | The request has succeeded. | - | +| **0** | The request has failed. | - | + + +# **getDmEvents** +> Get2DmEventsResponse getDmEvents().maxResults(maxResults).paginationToken(paginationToken).eventTypes(eventTypes).dmEventFields(dmEventFields).expansions(expansions).mediaFields(mediaFields).userFields(userFields).tweetFields(tweetFields).execute(); + +Get recent DM Events + +Returns recent DM Events across DM conversations + +### Example +```java +// Import classes: +import com.twitter.clientlib.ApiClient; +import com.twitter.clientlib.ApiException; +import com.twitter.clientlib.Configuration; +import com.twitter.clientlib.auth.*; +import com.twitter.clientlib.model.*; +import com.twitter.clientlib.TwitterCredentialsOAuth2; +import com.twitter.clientlib.TwitterCredentialsBearer; +import com.twitter.clientlib.api.TwitterApi; + +import com.twitter.clientlib.api.DirectMessagesApi; +import java.util.List; +import java.util.Set; +import java.util.Arrays; +import java.util.HashSet; +import java.time.OffsetDateTime; + +public class Example { + public static void main(String[] args) { + // Set the credentials based on the API's "security" tag values. + // Check the API definition in https://api.twitter.com/2/openapi.json + // When multiple options exist, the SDK supports only "OAuth2UserToken" or "BearerToken" + + // Uncomment and set the credentials configuration + + // Configure OAuth2 access token for authorization: + // TwitterCredentialsOAuth2 credentials = new TwitterCredentialsOAuth2(System.getenv("TWITTER_OAUTH2_CLIENT_ID"), + // System.getenv("TWITTER_OAUTH2_CLIENT_SECRET"), + // System.getenv("TWITTER_OAUTH2_ACCESS_TOKEN"), + // System.getenv("TWITTER_OAUTH2_REFRESH_TOKEN")); + TwitterApi apiInstance = new TwitterApi(credentials); + + // Set the params values + Integer maxResults = 100; // Integer | The maximum number of results. + String paginationToken = "paginationToken_example"; // String | This parameter is used to get a specified 'page' of results. + Set eventTypes = new HashSet<>(Arrays.asList()); // Set | The set of event_types to include in the results. + Set dmEventFields = new HashSet<>(Arrays.asList()); // Set | A comma separated list of DmEvent fields to display. + Set expansions = new HashSet<>(Arrays.asList()); // Set | A comma separated list of fields to expand. + Set mediaFields = new HashSet<>(Arrays.asList()); // Set | A comma separated list of Media fields to display. + Set userFields = new HashSet<>(Arrays.asList()); // Set | A comma separated list of User fields to display. + Set tweetFields = new HashSet<>(Arrays.asList()); // Set | A comma separated list of Tweet fields to display. + try { + Get2DmEventsResponse result = apiInstance.directMessages().getDmEvents() + .maxResults(maxResults) + .paginationToken(paginationToken) + .eventTypes(eventTypes) + .dmEventFields(dmEventFields) + .expansions(expansions) + .mediaFields(mediaFields) + .userFields(userFields) + .tweetFields(tweetFields) + .execute(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DirectMessagesApi#getDmEvents"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **maxResults** | **Integer**| The maximum number of results. | [optional] [default to 100] | +| **paginationToken** | **String**| This parameter is used to get a specified 'page' of results. | [optional] | +| **eventTypes** | [**Set<String>**](String.md)| The set of event_types to include in the results. | [optional] [enum: MessageCreate, ParticipantsJoin, ParticipantsLeave] | +| **dmEventFields** | [**Set<String>**](String.md)| A comma separated list of DmEvent fields to display. | [optional] [enum: attachments, created_at, dm_conversation_id, event_type, id, participant_ids, referenced_tweets, sender_id, text] | +| **expansions** | [**Set<String>**](String.md)| A comma separated list of fields to expand. | [optional] [enum: attachments.media_keys, participant_ids, referenced_tweets.id, sender_id] | +| **mediaFields** | [**Set<String>**](String.md)| A comma separated list of Media fields to display. | [optional] [enum: alt_text, duration_ms, height, media_key, non_public_metrics, organic_metrics, preview_image_url, promoted_metrics, public_metrics, type, url, variants, width] | +| **userFields** | [**Set<String>**](String.md)| A comma separated list of User fields to display. | [optional] [enum: created_at, description, entities, id, location, name, pinned_tweet_id, profile_image_url, protected, public_metrics, url, username, verified, withheld] | +| **tweetFields** | [**Set<String>**](String.md)| A comma separated list of Tweet fields to display. | [optional] [enum: attachments, author_id, context_annotations, conversation_id, created_at, edit_controls, edit_history_tweet_ids, entities, geo, id, in_reply_to_user_id, lang, non_public_metrics, organic_metrics, possibly_sensitive, promoted_metrics, public_metrics, referenced_tweets, reply_settings, source, text, withheld] | + +### Return type + +[**Get2DmEventsResponse**](Get2DmEventsResponse.md) + +### Authorization + +[OAuth2UserToken](../README.md#OAuth2UserToken), [UserToken](../README.md#UserToken) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/problem+json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | The request has succeeded. | - | +| **0** | The request has failed. | - | + diff --git a/docs/DmEvent.md b/docs/DmEvent.md new file mode 100644 index 0000000..62d5603 --- /dev/null +++ b/docs/DmEvent.md @@ -0,0 +1,21 @@ + + +# DmEvent + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**attachments** | [**DmEventAttachments**](DmEventAttachments.md) | | [optional] | +|**createdAt** | **OffsetDateTime** | | [optional] | +|**dmConversationId** | **String** | Unique identifier of a DM conversation. This can either be a numeric string, or a pair of numeric strings separated by a '-' character in the case of one-on-one DM Conversations. | [optional] | +|**eventType** | **String** | | | +|**id** | **String** | Unique identifier of a DM Event. | | +|**participantIds** | **List<String>** | A list of participants for a ParticipantsJoin or ParticipantsLeave event_type. | [optional] | +|**referencedTweets** | [**List<TweetEditComplianceObjectSchemaTweet>**](TweetEditComplianceObjectSchemaTweet.md) | A list of Tweets this DM refers to. | [optional] | +|**senderId** | **String** | Unique identifier of this User. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers. | [optional] | +|**text** | **String** | | [optional] | + + + diff --git a/docs/DmEventAttachments.md b/docs/DmEventAttachments.md new file mode 100644 index 0000000..ba18f81 --- /dev/null +++ b/docs/DmEventAttachments.md @@ -0,0 +1,15 @@ + + +# DmEventAttachments + +Specifies the type of attachments (if any) present in this DM. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**cardIds** | **List<String>** | A list of card IDs (if cards are attached). | [optional] | +|**mediaKeys** | **List<String>** | A list of Media Keys for each one of the media attachments (if media are attached). | [optional] | + + + diff --git a/docs/ReportUsersRequest.md b/docs/DmMediaAttachment.md similarity index 53% rename from docs/ReportUsersRequest.md rename to docs/DmMediaAttachment.md index 71ac60e..bbe0bcb 100644 --- a/docs/ReportUsersRequest.md +++ b/docs/DmMediaAttachment.md @@ -1,14 +1,13 @@ -# ReportUsersRequest +# DmMediaAttachment ## Properties | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**description** | **String** | | | -|**userIds** | **List<String>** | | | +|**mediaId** | **String** | The unique identifier of this Media. | | diff --git a/docs/Get2DmConversationsIdDmEventsResponse.md b/docs/Get2DmConversationsIdDmEventsResponse.md new file mode 100644 index 0000000..e3cb021 --- /dev/null +++ b/docs/Get2DmConversationsIdDmEventsResponse.md @@ -0,0 +1,16 @@ + + +# Get2DmConversationsIdDmEventsResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**data** | [**List<DmEvent>**](DmEvent.md) | | [optional] | +|**errors** | [**List<Problem>**](Problem.md) | | [optional] | +|**includes** | [**Expansions**](Expansions.md) | | [optional] | +|**meta** | [**Get2ListsIdFollowersResponseMeta**](Get2ListsIdFollowersResponseMeta.md) | | [optional] | + + + diff --git a/docs/Get2DmConversationsWithParticipantIdDmEventsResponse.md b/docs/Get2DmConversationsWithParticipantIdDmEventsResponse.md new file mode 100644 index 0000000..ad586b6 --- /dev/null +++ b/docs/Get2DmConversationsWithParticipantIdDmEventsResponse.md @@ -0,0 +1,16 @@ + + +# Get2DmConversationsWithParticipantIdDmEventsResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**data** | [**List<DmEvent>**](DmEvent.md) | | [optional] | +|**errors** | [**List<Problem>**](Problem.md) | | [optional] | +|**includes** | [**Expansions**](Expansions.md) | | [optional] | +|**meta** | [**Get2ListsIdFollowersResponseMeta**](Get2ListsIdFollowersResponseMeta.md) | | [optional] | + + + diff --git a/docs/Get2DmEventsResponse.md b/docs/Get2DmEventsResponse.md new file mode 100644 index 0000000..d3e3588 --- /dev/null +++ b/docs/Get2DmEventsResponse.md @@ -0,0 +1,16 @@ + + +# Get2DmEventsResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**data** | [**List<DmEvent>**](DmEvent.md) | | [optional] | +|**errors** | [**List<Problem>**](Problem.md) | | [optional] | +|**includes** | [**Expansions**](Expansions.md) | | [optional] | +|**meta** | [**Get2ListsIdFollowersResponseMeta**](Get2ListsIdFollowersResponseMeta.md) | | [optional] | + + + diff --git a/docs/TweetCreateRequest.md b/docs/TweetCreateRequest.md index 17d2a27..02b3df7 100644 --- a/docs/TweetCreateRequest.md +++ b/docs/TweetCreateRequest.md @@ -7,10 +7,12 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| +|**cardUri** | **String** | Card Uri Parameter. This is mutually exclusive from Quote Tweet Id, Poll, Media, and Direct Message Deep Link. | [optional] | |**directMessageDeepLink** | **String** | Link to take the conversation from the public timeline to a private Direct Message. | [optional] | |**forSuperFollowersOnly** | **Boolean** | Exclusive Tweet for super followers. | [optional] | |**geo** | [**TweetCreateRequestGeo**](TweetCreateRequestGeo.md) | | [optional] | |**media** | [**TweetCreateRequestMedia**](TweetCreateRequestMedia.md) | | [optional] | +|**nullcast** | **Boolean** | Nullcasted (promoted-only) Tweets do not appear in the public timeline and are not served to followers. | [optional] | |**poll** | [**TweetCreateRequestPoll**](TweetCreateRequestPoll.md) | | [optional] | |**quoteTweetId** | **String** | Unique identifier of this Tweet. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers. | [optional] | |**reply** | [**TweetCreateRequestReply**](TweetCreateRequestReply.md) | | [optional] | diff --git a/docs/TweetCreateRequestMedia.md b/docs/TweetCreateRequestMedia.md index d86c293..a0f4b80 100644 --- a/docs/TweetCreateRequestMedia.md +++ b/docs/TweetCreateRequestMedia.md @@ -2,7 +2,7 @@ # TweetCreateRequestMedia -Media information being attached to created Tweet. This is mutually exclusive from Quote Tweet Id and Poll. +Media information being attached to created Tweet. This is mutually exclusive from Quote Tweet Id, Poll, and Card URI. ## Properties diff --git a/docs/TweetCreateRequestPoll.md b/docs/TweetCreateRequestPoll.md index 918f9f9..bf6712c 100644 --- a/docs/TweetCreateRequestPoll.md +++ b/docs/TweetCreateRequestPoll.md @@ -2,7 +2,7 @@ # TweetCreateRequestPoll -Poll options for a Tweet with a poll. This is mutually exclusive from Media and Quote Tweet Id. +Poll options for a Tweet with a poll. This is mutually exclusive from Media, Quote Tweet Id, and Card URI. ## Properties diff --git a/docs/TweetLabelData.md b/docs/TweetLabelData.md new file mode 100644 index 0000000..e14a5a8 --- /dev/null +++ b/docs/TweetLabelData.md @@ -0,0 +1,15 @@ + + +# TweetLabelData + +Tweet label data. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**publicTweetNotice** | [**TweetNotice**](TweetNotice.md) | | | +|**publicTweetUnviewable** | [**TweetUnviewable**](TweetUnviewable.md) | | | + + + diff --git a/docs/ProblemErrors.md b/docs/TweetLabelStreamResponse.md similarity index 61% rename from docs/ProblemErrors.md rename to docs/TweetLabelStreamResponse.md index a8ac09c..3e5ad91 100644 --- a/docs/ProblemErrors.md +++ b/docs/TweetLabelStreamResponse.md @@ -1,12 +1,14 @@ -# ProblemErrors +# TweetLabelStreamResponse +Tweet label stream events. ## Properties | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| +|**data** | [**TweetLabelData**](TweetLabelData.md) | | | |**errors** | [**List<Problem>**](Problem.md) | | | diff --git a/docs/ReportUsersResponse.md b/docs/TweetLabelStreamResponseOneOf.md similarity index 52% rename from docs/ReportUsersResponse.md rename to docs/TweetLabelStreamResponseOneOf.md index 33d681d..62d3e21 100644 --- a/docs/ReportUsersResponse.md +++ b/docs/TweetLabelStreamResponseOneOf.md @@ -1,13 +1,14 @@ -# ReportUsersResponse +# TweetLabelStreamResponseOneOf +Tweet Label event. ## Properties | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | [**ReportUsersResponseData**](ReportUsersResponseData.md) | | [optional] | +|**data** | [**TweetLabelData**](TweetLabelData.md) | | | diff --git a/docs/TweetNotice.md b/docs/TweetNotice.md new file mode 100644 index 0000000..d203368 --- /dev/null +++ b/docs/TweetNotice.md @@ -0,0 +1,19 @@ + + +# TweetNotice + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**application** | **String** | If the label is being applied or removed. Possible values are ‘apply’ or ‘remove’. | | +|**details** | **String** | Information shown on the Tweet label | [optional] | +|**eventAt** | **OffsetDateTime** | Event time. | | +|**eventType** | **String** | The type of label on the Tweet | | +|**extendedDetailsUrl** | **String** | Link to more information about this kind of label | [optional] | +|**labelTitle** | **String** | Title/header of the Tweet label | [optional] | +|**tweet** | [**TweetComplianceSchemaTweet**](TweetComplianceSchemaTweet.md) | | | + + + diff --git a/docs/ReportUsersResponseData.md b/docs/TweetNoticeSchema.md similarity index 58% rename from docs/ReportUsersResponseData.md rename to docs/TweetNoticeSchema.md index 4b0acd7..52a9c1c 100644 --- a/docs/ReportUsersResponseData.md +++ b/docs/TweetNoticeSchema.md @@ -1,13 +1,13 @@ -# ReportUsersResponseData +# TweetNoticeSchema ## Properties | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**id** | **Integer** | | [optional] | +|**publicTweetNotice** | [**TweetNotice**](TweetNotice.md) | | | diff --git a/docs/TweetUnviewable.md b/docs/TweetUnviewable.md new file mode 100644 index 0000000..e920f41 --- /dev/null +++ b/docs/TweetUnviewable.md @@ -0,0 +1,15 @@ + + +# TweetUnviewable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**application** | **String** | If the label is being applied or removed. Possible values are ‘apply’ or ‘remove’. | | +|**eventAt** | **OffsetDateTime** | Event time. | | +|**tweet** | [**TweetComplianceSchemaTweet**](TweetComplianceSchemaTweet.md) | | | + + + diff --git a/docs/TweetUnviewableSchema.md b/docs/TweetUnviewableSchema.md new file mode 100644 index 0000000..69ca710 --- /dev/null +++ b/docs/TweetUnviewableSchema.md @@ -0,0 +1,13 @@ + + +# TweetUnviewableSchema + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**publicTweetUnviewable** | [**TweetUnviewable**](TweetUnviewable.md) | | | + + + diff --git a/examples/pom.xml b/examples/pom.xml index c954b60..9db5fc8 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -16,7 +16,7 @@ com.twitter twitter-api-java-sdk - 2.0.3 + 2.0.4 compile diff --git a/pom.xml b/pom.xml index 348f7f3..c39bd86 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ twitter-api-java-sdk jar twitter-api-java-sdk - 2.0.3 + 2.0.4 https://github.com/twitterdev/twitter-api-java-sdk Twitter API v2 available endpoints diff --git a/src/main/java/com/twitter/clientlib/ApiClient.java b/src/main/java/com/twitter/clientlib/ApiClient.java index 0a8f083..01b4dd4 100644 --- a/src/main/java/com/twitter/clientlib/ApiClient.java +++ b/src/main/java/com/twitter/clientlib/ApiClient.java @@ -225,7 +225,7 @@ private void init() { json = new JSON(); // Set default User-Agent. - setUserAgent("twitter-api-java-sdk/2.0.3"); + setUserAgent("twitter-api-java-sdk/2.0.4"); authentications = new HashMap(); } diff --git a/src/main/java/com/twitter/clientlib/JSON.java b/src/main/java/com/twitter/clientlib/JSON.java index 05234e9..84ce44f 100644 --- a/src/main/java/com/twitter/clientlib/JSON.java +++ b/src/main/java/com/twitter/clientlib/JSON.java @@ -707,12 +707,21 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ContextAnnotation.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ContextAnnotationDomainFields.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ContextAnnotationEntityFields.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.CreateAttachmentsMessageRequest.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.CreateComplianceJobRequest.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.CreateComplianceJobResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.CreateDmConversationRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.CreateDmEventResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.CreateDmEventResponseData.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.CreateMessageRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.CreateTextMessageRequest.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.DeleteRulesRequest.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.DeleteRulesRequestDelete.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.DisallowedResourceProblem.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.DisallowedResourceProblemAllOf.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.DmEvent.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.DmEventAttachments.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.DmMediaAttachment.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.DuplicateRuleProblem.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.DuplicateRuleProblemAllOf.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.EntityIndicesInclusiveExclusive.CustomTypeAdapterFactory()); @@ -731,6 +740,9 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2ComplianceJobsIdResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2ComplianceJobsResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2ComplianceJobsResponseMeta.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2DmConversationsIdDmEventsResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2DmConversationsWithParticipantIdDmEventsResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2DmEventsResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2ListsIdFollowersResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2ListsIdFollowersResponseMeta.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2ListsIdMembersResponse.CustomTypeAdapterFactory()); @@ -816,11 +828,7 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Point.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Poll.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.PollOption.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ProblemErrors.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ProblemOrError.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ReportUsersRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ReportUsersResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ReportUsersResponseData.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ResourceNotFoundProblem.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ResourceNotFoundProblemAllOf.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ResourceUnauthorizedProblem.CustomTypeAdapterFactory()); @@ -867,13 +875,20 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetHideRequest.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetHideResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetHideResponseData.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetLabelData.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetLabelStreamResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetLabelStreamResponseOneOf.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetNonPublicMetrics.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetNotice.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetNoticeSchema.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetOrganicMetrics.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetPromotedMetrics.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetPublicMetrics.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetReferencedTweets.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetTakedownComplianceSchema.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetUndropComplianceSchema.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetUnviewable.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetUnviewableSchema.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetWithheld.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetWithheldComplianceSchema.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.UnsupportedAuthenticationProblem.CustomTypeAdapterFactory()); diff --git a/src/main/java/com/twitter/clientlib/api/ComplianceApi.java b/src/main/java/com/twitter/clientlib/api/ComplianceApi.java index f199ab0..dabb88a 100644 --- a/src/main/java/com/twitter/clientlib/api/ComplianceApi.java +++ b/src/main/java/com/twitter/clientlib/api/ComplianceApi.java @@ -48,6 +48,7 @@ import com.twitter.clientlib.model.Problem; import java.util.Set; import com.twitter.clientlib.model.TweetComplianceStreamResponse; +import com.twitter.clientlib.model.TweetLabelStreamResponse; import com.twitter.clientlib.model.UserComplianceStreamResponse; import java.lang.reflect.Type; @@ -652,6 +653,214 @@ public okhttp3.Call executeAsync(final ApiCallback localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (backfillMinutes != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("backfill_minutes", backfillMinutes)); + } + + if (startTime != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("start_time", startTime)); + } + + if (endTime != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("end_time", endTime)); + } + + 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 (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "BearerToken" }; + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, reduceAuthNames(localVarAuthNames), _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getTweetsLabelStreamValidateBeforeCall(Integer backfillMinutes, OffsetDateTime startTime, OffsetDateTime endTime, final ApiCallback _callback) throws ApiException { + + + okhttp3.Call localVarCall = getTweetsLabelStreamCall(backfillMinutes, startTime, endTime, _callback); + return localVarCall; + + } + + + private InputStream getTweetsLabelStreamWithHttpInfo(Integer backfillMinutes, OffsetDateTime startTime, OffsetDateTime endTime) throws ApiException { + okhttp3.Call localVarCall = getTweetsLabelStreamValidateBeforeCall(backfillMinutes, startTime, endTime, null); + try { + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.executeStream(localVarCall, localVarReturnType); + } catch (ApiException e) { + e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken(){}.getType())); + throw e; + } + } + + private okhttp3.Call getTweetsLabelStreamAsync(Integer backfillMinutes, OffsetDateTime startTime, OffsetDateTime endTime, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getTweetsLabelStreamValidateBeforeCall(backfillMinutes, startTime, endTime, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + public class APIgetTweetsLabelStreamRequest { + private Integer backfillMinutes; + private OffsetDateTime startTime; + private OffsetDateTime endTime; + + + + private APIgetTweetsLabelStreamRequest() { + } + + /** + * Set backfillMinutes + * @param backfillMinutes The number of minutes of backfill requested. (optional) + * @return APIgetTweetsLabelStreamRequest + */ + public APIgetTweetsLabelStreamRequest backfillMinutes(Integer backfillMinutes) { + this.backfillMinutes = backfillMinutes; + return this; + } + + /** + * Set startTime + * @param startTime YYYY-MM-DDTHH:mm:ssZ. The earliest UTC timestamp from which the Tweet labels will be provided. (optional) + * @return APIgetTweetsLabelStreamRequest + */ + public APIgetTweetsLabelStreamRequest startTime(OffsetDateTime startTime) { + this.startTime = startTime; + return this; + } + + /** + * Set endTime + * @param endTime YYYY-MM-DDTHH:mm:ssZ. The latest UTC timestamp from which the Tweet labels will be provided. (optional) + * @return APIgetTweetsLabelStreamRequest + */ + public APIgetTweetsLabelStreamRequest endTime(OffsetDateTime endTime) { + this.endTime = endTime; + return this; + } + + /** + * Build call for getTweetsLabelStream + * @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 The request has succeeded. -
0 The request has failed. -
+ */ + public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException { + return getTweetsLabelStreamCall(backfillMinutes, startTime, endTime, _callback); + } + + /** + * Execute getTweetsLabelStream request + * @return TweetLabelStreamResponse + * @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 has succeeded. -
0 The request has failed. -
+ */ + public InputStream execute() throws ApiException { + return getTweetsLabelStreamWithHttpInfo(backfillMinutes, startTime, endTime); + } + + /** + * Calls the API using a retry mechanism to handle rate limits errors. + * + */ + public InputStream execute(Integer retries) throws ApiException { + InputStream localVarResp; + try{ + localVarResp = execute(); + } + catch (ApiException e) { + if(handleRateLimit(e, retries)) { + return execute(retries - 1); + } else { + throw e; + } + } + return localVarResp; + } + /** + * Execute getTweetsLabelStream request with HTTP info returned + * @return ApiResponse<TweetLabelStreamResponse> + * @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 has succeeded. -
0 The request has failed. -
+ */ + + public InputStream executeWithHttpInfo() throws ApiException { + return getTweetsLabelStreamWithHttpInfo(backfillMinutes, startTime, endTime); + } + /** + * Execute getTweetsLabelStream 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 The request has succeeded. -
0 The request has failed. -
+ */ + public okhttp3.Call executeAsync(final ApiCallback _callback) throws ApiException { + return getTweetsLabelStreamAsync(backfillMinutes, startTime, endTime, _callback); + } + } + + /** + * Tweets Label stream + * Streams 100% of labeling events applied to Tweets + * @return APIgetTweetsLabelStreamRequest + * @http.response.details + + + + +
Status Code Description Response Headers
200 The request has succeeded. -
0 The request has failed. -
+ */ + public APIgetTweetsLabelStreamRequest getTweetsLabelStream() { + return new APIgetTweetsLabelStreamRequest(); + } private okhttp3.Call getUsersComplianceStreamCall(Integer backfillMinutes, Integer partition, OffsetDateTime startTime, OffsetDateTime endTime, final ApiCallback _callback) throws ApiException { Object localVarPostBody = null; diff --git a/src/main/java/com/twitter/clientlib/api/DirectMessagesApi.java b/src/main/java/com/twitter/clientlib/api/DirectMessagesApi.java new file mode 100644 index 0000000..dbfc4ef --- /dev/null +++ b/src/main/java/com/twitter/clientlib/api/DirectMessagesApi.java @@ -0,0 +1,1523 @@ +/* +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 java.util.HashSet; + + +import com.twitter.clientlib.model.CreateDmConversationRequest; +import com.twitter.clientlib.model.CreateDmEventResponse; +import com.twitter.clientlib.model.CreateMessageRequest; +import com.twitter.clientlib.model.Error; +import com.twitter.clientlib.model.Get2DmConversationsIdDmEventsResponse; +import com.twitter.clientlib.model.Get2DmConversationsWithParticipantIdDmEventsResponse; +import com.twitter.clientlib.model.Get2DmEventsResponse; +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 DirectMessagesApi extends ApiCommon { + + private okhttp3.Call dmConversationByIdEventIdCreateCall(CreateMessageRequest createMessageRequest, String dmConversationId, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = createMessageRequest; + + // create path and map variables + String localVarPath = "/2/dm_conversations/{dm_conversation_id}/messages" + .replaceAll("\\{" + "dm_conversation_id" + "\\}", localVarApiClient.escapeString(dmConversationId.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 (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "OAuth2UserToken", "UserToken" }; + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, reduceAuthNames(localVarAuthNames), _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call dmConversationByIdEventIdCreateValidateBeforeCall(CreateMessageRequest createMessageRequest, String dmConversationId, final ApiCallback _callback) throws ApiException { + + // verify the required parameter 'dmConversationId' is set + if (dmConversationId == null) { + throw new ApiException("Missing the required parameter 'dmConversationId' when calling dmConversationByIdEventIdCreate(Async)"); + } + + + okhttp3.Call localVarCall = dmConversationByIdEventIdCreateCall(createMessageRequest, dmConversationId, _callback); + return localVarCall; + + } + + + private ApiResponse dmConversationByIdEventIdCreateWithHttpInfo(CreateMessageRequest createMessageRequest, String dmConversationId) throws ApiException { + okhttp3.Call localVarCall = dmConversationByIdEventIdCreateValidateBeforeCall(createMessageRequest, dmConversationId, 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())); + throw e; + } + } + + private okhttp3.Call dmConversationByIdEventIdCreateAsync(CreateMessageRequest createMessageRequest, String dmConversationId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = dmConversationByIdEventIdCreateValidateBeforeCall(createMessageRequest, dmConversationId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + public class APIdmConversationByIdEventIdCreateRequest { + private final String dmConversationId; + private CreateMessageRequest createMessageRequest; + + + + private APIdmConversationByIdEventIdCreateRequest(String dmConversationId) { + this.dmConversationId = dmConversationId; + } + + /** + * Set createMessageRequest + * @param createMessageRequest (optional) + * @return APIdmConversationByIdEventIdCreateRequest + */ + public APIdmConversationByIdEventIdCreateRequest createMessageRequest(CreateMessageRequest createMessageRequest) { + this.createMessageRequest = createMessageRequest; + return this; + } + + /** + * Build call for dmConversationByIdEventIdCreate + * @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
201 The request has succeeded. -
0 The request has failed. -
+ */ + public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException { + return dmConversationByIdEventIdCreateCall(createMessageRequest, dmConversationId, _callback); + } + + /** + * Execute dmConversationByIdEventIdCreate request + * @return CreateDmEventResponse + * @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
201 The request has succeeded. -
0 The request has failed. -
+ */ + public CreateDmEventResponse execute() throws ApiException { + + ApiResponse localVarResp = dmConversationByIdEventIdCreateWithHttpInfo(createMessageRequest, dmConversationId); + return localVarResp.getData(); + } + /** + * Calls the API using a retry mechanism to handle rate limits errors. + * + */ + public CreateDmEventResponse execute(Integer retries) throws ApiException { + CreateDmEventResponse localVarResp; + try{ + localVarResp = execute(); + } catch (ApiException e) { + if(handleRateLimit(e, retries)) { + return execute(retries - 1); + } else { + throw e; + } + } + return localVarResp; + } + /** + * Execute dmConversationByIdEventIdCreate request with HTTP info returned + * @return ApiResponse<CreateDmEventResponse> + * @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
201 The request has succeeded. -
0 The request has failed. -
+ */ + + public ApiResponse executeWithHttpInfo() throws ApiException { + return dmConversationByIdEventIdCreateWithHttpInfo(createMessageRequest, dmConversationId); + } + /** + * Execute dmConversationByIdEventIdCreate 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
201 The request has succeeded. -
0 The request has failed. -
+ */ + public okhttp3.Call executeAsync(final ApiCallback _callback) throws ApiException { + return dmConversationByIdEventIdCreateAsync(createMessageRequest, dmConversationId, _callback); + } + } + + /** + * Send a new message to a DM Conversation + * Creates a new message for a DM Conversation specified by DM Conversation ID + * @param dmConversationId The DM Conversation ID. (required) + * @return APIdmConversationByIdEventIdCreateRequest + * @http.response.details + + + + +
Status Code Description Response Headers
201 The request has succeeded. -
0 The request has failed. -
+ */ + public APIdmConversationByIdEventIdCreateRequest dmConversationByIdEventIdCreate(String dmConversationId) { + return new APIdmConversationByIdEventIdCreateRequest(dmConversationId); + } + private okhttp3.Call dmConversationIdCreateCall(CreateDmConversationRequest createDmConversationRequest, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = createDmConversationRequest; + + // create path and map variables + String localVarPath = "/2/dm_conversations"; + + 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 (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "OAuth2UserToken", "UserToken" }; + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, reduceAuthNames(localVarAuthNames), _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call dmConversationIdCreateValidateBeforeCall(CreateDmConversationRequest createDmConversationRequest, final ApiCallback _callback) throws ApiException { + + + okhttp3.Call localVarCall = dmConversationIdCreateCall(createDmConversationRequest, _callback); + return localVarCall; + + } + + + private ApiResponse dmConversationIdCreateWithHttpInfo(CreateDmConversationRequest createDmConversationRequest) throws ApiException { + okhttp3.Call localVarCall = dmConversationIdCreateValidateBeforeCall(createDmConversationRequest, 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())); + throw e; + } + } + + private okhttp3.Call dmConversationIdCreateAsync(CreateDmConversationRequest createDmConversationRequest, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = dmConversationIdCreateValidateBeforeCall(createDmConversationRequest, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + public class APIdmConversationIdCreateRequest { + private CreateDmConversationRequest createDmConversationRequest; + + + + private APIdmConversationIdCreateRequest() { + } + + /** + * Set createDmConversationRequest + * @param createDmConversationRequest (optional) + * @return APIdmConversationIdCreateRequest + */ + public APIdmConversationIdCreateRequest createDmConversationRequest(CreateDmConversationRequest createDmConversationRequest) { + this.createDmConversationRequest = createDmConversationRequest; + return this; + } + + /** + * Build call for dmConversationIdCreate + * @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
201 The request has succeeded. -
0 The request has failed. -
+ */ + public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException { + return dmConversationIdCreateCall(createDmConversationRequest, _callback); + } + + /** + * Execute dmConversationIdCreate request + * @return CreateDmEventResponse + * @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
201 The request has succeeded. -
0 The request has failed. -
+ */ + public CreateDmEventResponse execute() throws ApiException { + + ApiResponse localVarResp = dmConversationIdCreateWithHttpInfo(createDmConversationRequest); + return localVarResp.getData(); + } + /** + * Calls the API using a retry mechanism to handle rate limits errors. + * + */ + public CreateDmEventResponse execute(Integer retries) throws ApiException { + CreateDmEventResponse localVarResp; + try{ + localVarResp = execute(); + } catch (ApiException e) { + if(handleRateLimit(e, retries)) { + return execute(retries - 1); + } else { + throw e; + } + } + return localVarResp; + } + /** + * Execute dmConversationIdCreate request with HTTP info returned + * @return ApiResponse<CreateDmEventResponse> + * @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
201 The request has succeeded. -
0 The request has failed. -
+ */ + + public ApiResponse executeWithHttpInfo() throws ApiException { + return dmConversationIdCreateWithHttpInfo(createDmConversationRequest); + } + /** + * Execute dmConversationIdCreate 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
201 The request has succeeded. -
0 The request has failed. -
+ */ + public okhttp3.Call executeAsync(final ApiCallback _callback) throws ApiException { + return dmConversationIdCreateAsync(createDmConversationRequest, _callback); + } + } + + /** + * Create a new DM Conversation + * Creates a new DM Conversation. + * @return APIdmConversationIdCreateRequest + * @http.response.details + + + + +
Status Code Description Response Headers
201 The request has succeeded. -
0 The request has failed. -
+ */ + public APIdmConversationIdCreateRequest dmConversationIdCreate() { + return new APIdmConversationIdCreateRequest(); + } + private okhttp3.Call dmConversationWithUserEventIdCreateCall(CreateMessageRequest createMessageRequest, String participantId, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = createMessageRequest; + + // create path and map variables + String localVarPath = "/2/dm_conversations/with/{participant_id}/messages" + .replaceAll("\\{" + "participant_id" + "\\}", localVarApiClient.escapeString(participantId.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 (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "OAuth2UserToken", "UserToken" }; + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, reduceAuthNames(localVarAuthNames), _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call dmConversationWithUserEventIdCreateValidateBeforeCall(CreateMessageRequest createMessageRequest, String participantId, final ApiCallback _callback) throws ApiException { + + // verify the required parameter 'participantId' is set + if (participantId == null) { + throw new ApiException("Missing the required parameter 'participantId' when calling dmConversationWithUserEventIdCreate(Async)"); + } + + + okhttp3.Call localVarCall = dmConversationWithUserEventIdCreateCall(createMessageRequest, participantId, _callback); + return localVarCall; + + } + + + private ApiResponse dmConversationWithUserEventIdCreateWithHttpInfo(CreateMessageRequest createMessageRequest, String participantId) throws ApiException { + okhttp3.Call localVarCall = dmConversationWithUserEventIdCreateValidateBeforeCall(createMessageRequest, participantId, 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())); + throw e; + } + } + + private okhttp3.Call dmConversationWithUserEventIdCreateAsync(CreateMessageRequest createMessageRequest, String participantId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = dmConversationWithUserEventIdCreateValidateBeforeCall(createMessageRequest, participantId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + public class APIdmConversationWithUserEventIdCreateRequest { + private final String participantId; + private CreateMessageRequest createMessageRequest; + + + + private APIdmConversationWithUserEventIdCreateRequest(String participantId) { + this.participantId = participantId; + } + + /** + * Set createMessageRequest + * @param createMessageRequest (optional) + * @return APIdmConversationWithUserEventIdCreateRequest + */ + public APIdmConversationWithUserEventIdCreateRequest createMessageRequest(CreateMessageRequest createMessageRequest) { + this.createMessageRequest = createMessageRequest; + return this; + } + + /** + * Build call for dmConversationWithUserEventIdCreate + * @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
201 The request has succeeded. -
0 The request has failed. -
+ */ + public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException { + return dmConversationWithUserEventIdCreateCall(createMessageRequest, participantId, _callback); + } + + /** + * Execute dmConversationWithUserEventIdCreate request + * @return CreateDmEventResponse + * @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
201 The request has succeeded. -
0 The request has failed. -
+ */ + public CreateDmEventResponse execute() throws ApiException { + + ApiResponse localVarResp = dmConversationWithUserEventIdCreateWithHttpInfo(createMessageRequest, participantId); + return localVarResp.getData(); + } + /** + * Calls the API using a retry mechanism to handle rate limits errors. + * + */ + public CreateDmEventResponse execute(Integer retries) throws ApiException { + CreateDmEventResponse localVarResp; + try{ + localVarResp = execute(); + } catch (ApiException e) { + if(handleRateLimit(e, retries)) { + return execute(retries - 1); + } else { + throw e; + } + } + return localVarResp; + } + /** + * Execute dmConversationWithUserEventIdCreate request with HTTP info returned + * @return ApiResponse<CreateDmEventResponse> + * @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
201 The request has succeeded. -
0 The request has failed. -
+ */ + + public ApiResponse executeWithHttpInfo() throws ApiException { + return dmConversationWithUserEventIdCreateWithHttpInfo(createMessageRequest, participantId); + } + /** + * Execute dmConversationWithUserEventIdCreate 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
201 The request has succeeded. -
0 The request has failed. -
+ */ + public okhttp3.Call executeAsync(final ApiCallback _callback) throws ApiException { + return dmConversationWithUserEventIdCreateAsync(createMessageRequest, participantId, _callback); + } + } + + /** + * Send a new message to a user + * Creates a new message for a DM Conversation with a participant user by ID + * @param participantId The ID of the recipient user that will receive the DM. (required) + * @return APIdmConversationWithUserEventIdCreateRequest + * @http.response.details + + + + +
Status Code Description Response Headers
201 The request has succeeded. -
0 The request has failed. -
+ */ + public APIdmConversationWithUserEventIdCreateRequest dmConversationWithUserEventIdCreate(String participantId) { + return new APIdmConversationWithUserEventIdCreateRequest(participantId); + } + private okhttp3.Call getDmConversationsIdDmEventsCall(String id, Integer maxResults, String paginationToken, Set eventTypes, Set dmEventFields, Set expansions, Set mediaFields, Set userFields, Set tweetFields, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/2/dm_conversations/{id}/dm_events" + .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 (eventTypes != null) { + localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "event_types", eventTypes)); + } + + if (dmEventFields != null) { + localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "dm_event.fields", dmEventFields)); + } + + if (expansions != null) { + localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "expansions", expansions)); + } + + if (mediaFields != null) { + localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "media.fields", mediaFields)); + } + + if (userFields != null) { + localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "user.fields", userFields)); + } + + if (tweetFields != null) { + localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "tweet.fields", tweetFields)); + } + + 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 (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "OAuth2UserToken", "UserToken" }; + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, reduceAuthNames(localVarAuthNames), _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getDmConversationsIdDmEventsValidateBeforeCall(String id, Integer maxResults, String paginationToken, Set eventTypes, Set dmEventFields, Set expansions, Set mediaFields, Set userFields, Set tweetFields, 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 getDmConversationsIdDmEvents(Async)"); + } + + + okhttp3.Call localVarCall = getDmConversationsIdDmEventsCall(id, maxResults, paginationToken, eventTypes, dmEventFields, expansions, mediaFields, userFields, tweetFields, _callback); + return localVarCall; + + } + + + private ApiResponse getDmConversationsIdDmEventsWithHttpInfo(String id, Integer maxResults, String paginationToken, Set eventTypes, Set dmEventFields, Set expansions, Set mediaFields, Set userFields, Set tweetFields) throws ApiException { + okhttp3.Call localVarCall = getDmConversationsIdDmEventsValidateBeforeCall(id, maxResults, paginationToken, eventTypes, dmEventFields, expansions, mediaFields, userFields, tweetFields, 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())); + throw e; + } + } + + private okhttp3.Call getDmConversationsIdDmEventsAsync(String id, Integer maxResults, String paginationToken, Set eventTypes, Set dmEventFields, Set expansions, Set mediaFields, Set userFields, Set tweetFields, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getDmConversationsIdDmEventsValidateBeforeCall(id, maxResults, paginationToken, eventTypes, dmEventFields, expansions, mediaFields, userFields, tweetFields, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + public class APIgetDmConversationsIdDmEventsRequest { + private final String id; + private Integer maxResults; + private String paginationToken; + private Set eventTypes; + private Set dmEventFields; + private Set expansions; + private Set mediaFields; + private Set userFields; + private Set tweetFields; + private final Set eventTypesAll = new HashSet<>(Arrays.asList("MessageCreate", "ParticipantsJoin", "ParticipantsLeave")); + private final Set dmEventFieldsAll = new HashSet<>(Arrays.asList("attachments", "created_at", "dm_conversation_id", "event_type", "id", "participant_ids", "referenced_tweets", "sender_id", "text")); + private final Set expansionsAll = new HashSet<>(Arrays.asList("attachments.media_keys", "participant_ids", "referenced_tweets.id", "sender_id")); + private final Set mediaFieldsAll = new HashSet<>(Arrays.asList("alt_text", "duration_ms", "height", "media_key", "non_public_metrics", "organic_metrics", "preview_image_url", "promoted_metrics", "public_metrics", "type", "url", "variants", "width")); + private final Set userFieldsAll = new HashSet<>(Arrays.asList("created_at", "description", "entities", "id", "location", "name", "pinned_tweet_id", "profile_image_url", "protected", "public_metrics", "url", "username", "verified", "withheld")); + private final Set tweetFieldsAll = new HashSet<>(Arrays.asList("attachments", "author_id", "context_annotations", "conversation_id", "created_at", "edit_controls", "edit_history_tweet_ids", "entities", "geo", "id", "in_reply_to_user_id", "lang", "non_public_metrics", "organic_metrics", "possibly_sensitive", "promoted_metrics", "public_metrics", "referenced_tweets", "reply_settings", "source", "text", "withheld")); + + private boolean isExclude = false; + + public APIgetDmConversationsIdDmEventsRequest excludeInputFields() { + isExclude = true; + return this; + } + + private APIgetDmConversationsIdDmEventsRequest(String id) { + this.id = id; + } + + /** + * Set maxResults + * @param maxResults The maximum number of results. (optional, default to 100) + * @return APIgetDmConversationsIdDmEventsRequest + */ + public APIgetDmConversationsIdDmEventsRequest maxResults(Integer maxResults) { + this.maxResults = maxResults; + return this; + } + + /** + * Set paginationToken + * @param paginationToken This parameter is used to get a specified 'page' of results. (optional) + * @return APIgetDmConversationsIdDmEventsRequest + */ + public APIgetDmConversationsIdDmEventsRequest paginationToken(String paginationToken) { + this.paginationToken = paginationToken; + return this; + } + + /** + * Set eventTypes + * @param eventTypes The set of event_types to include in the results. (optional) + * @return APIgetDmConversationsIdDmEventsRequest + */ + public APIgetDmConversationsIdDmEventsRequest eventTypes(Set eventTypes) { + this.eventTypes = eventTypes; + return this; + } + + /** + * Set dmEventFields + * @param dmEventFields A comma separated list of DmEvent fields to display. (optional) + * @return APIgetDmConversationsIdDmEventsRequest + */ + public APIgetDmConversationsIdDmEventsRequest dmEventFields(Set dmEventFields) { + this.dmEventFields = dmEventFields; + return this; + } + + /** + * Set expansions + * @param expansions A comma separated list of fields to expand. (optional) + * @return APIgetDmConversationsIdDmEventsRequest + */ + public APIgetDmConversationsIdDmEventsRequest expansions(Set expansions) { + this.expansions = expansions; + return this; + } + + /** + * Set mediaFields + * @param mediaFields A comma separated list of Media fields to display. (optional) + * @return APIgetDmConversationsIdDmEventsRequest + */ + public APIgetDmConversationsIdDmEventsRequest mediaFields(Set mediaFields) { + this.mediaFields = mediaFields; + return this; + } + + /** + * Set userFields + * @param userFields A comma separated list of User fields to display. (optional) + * @return APIgetDmConversationsIdDmEventsRequest + */ + public APIgetDmConversationsIdDmEventsRequest userFields(Set userFields) { + this.userFields = userFields; + return this; + } + + /** + * Set tweetFields + * @param tweetFields A comma separated list of Tweet fields to display. (optional) + * @return APIgetDmConversationsIdDmEventsRequest + */ + public APIgetDmConversationsIdDmEventsRequest tweetFields(Set tweetFields) { + this.tweetFields = tweetFields; + return this; + } + + /** + * Build call for getDmConversationsIdDmEvents + * @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 The request has succeeded. -
0 The request has failed. -
+ */ + public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException { + return getDmConversationsIdDmEventsCall(id, maxResults, paginationToken, eventTypes, dmEventFields, expansions, mediaFields, userFields, tweetFields, _callback); + } + + /** + * Execute getDmConversationsIdDmEvents request + * @return Get2DmConversationsIdDmEventsResponse + * @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 has succeeded. -
0 The request has failed. -
+ */ + public Get2DmConversationsIdDmEventsResponse execute() throws ApiException { + eventTypes = getFields("eventTypes", isExclude, eventTypes, eventTypesAll); + dmEventFields = getFields("dmEventFields", isExclude, dmEventFields, dmEventFieldsAll); + expansions = getFields("expansions", isExclude, expansions, expansionsAll); + mediaFields = getFields("mediaFields", isExclude, mediaFields, mediaFieldsAll); + userFields = getFields("userFields", isExclude, userFields, userFieldsAll); + tweetFields = getFields("tweetFields", isExclude, tweetFields, tweetFieldsAll); + + ApiResponse localVarResp = getDmConversationsIdDmEventsWithHttpInfo(id, maxResults, paginationToken, eventTypes, dmEventFields, expansions, mediaFields, userFields, tweetFields); + return localVarResp.getData(); + } + /** + * Calls the API using a retry mechanism to handle rate limits errors. + * + */ + public Get2DmConversationsIdDmEventsResponse execute(Integer retries) throws ApiException { + Get2DmConversationsIdDmEventsResponse localVarResp; + try{ + localVarResp = execute(); + } catch (ApiException e) { + if(handleRateLimit(e, retries)) { + return execute(retries - 1); + } else { + throw e; + } + } + return localVarResp; + } + /** + * Execute getDmConversationsIdDmEvents request with HTTP info returned + * @return ApiResponse<Get2DmConversationsIdDmEventsResponse> + * @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 has succeeded. -
0 The request has failed. -
+ */ + + public ApiResponse executeWithHttpInfo() throws ApiException { + return getDmConversationsIdDmEventsWithHttpInfo(id, maxResults, paginationToken, eventTypes, dmEventFields, expansions, mediaFields, userFields, tweetFields); + } + /** + * Execute getDmConversationsIdDmEvents 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 The request has succeeded. -
0 The request has failed. -
+ */ + public okhttp3.Call executeAsync(final ApiCallback _callback) throws ApiException { + return getDmConversationsIdDmEventsAsync(id, maxResults, paginationToken, eventTypes, dmEventFields, expansions, mediaFields, userFields, tweetFields, _callback); + } + } + + /** + * Get DM Events for a DM Conversation + * Returns DM Events for a DM Conversation + * @param id The DM Conversation ID. (required) + * @return APIgetDmConversationsIdDmEventsRequest + * @http.response.details + + + + +
Status Code Description Response Headers
200 The request has succeeded. -
0 The request has failed. -
+ */ + public APIgetDmConversationsIdDmEventsRequest getDmConversationsIdDmEvents(String id) { + return new APIgetDmConversationsIdDmEventsRequest(id); + } + private okhttp3.Call getDmConversationsWithParticipantIdDmEventsCall(String participantId, Integer maxResults, String paginationToken, Set eventTypes, Set dmEventFields, Set expansions, Set mediaFields, Set userFields, Set tweetFields, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/2/dm_conversations/with/{participant_id}/dm_events" + .replaceAll("\\{" + "participant_id" + "\\}", localVarApiClient.escapeString(participantId.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 (eventTypes != null) { + localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "event_types", eventTypes)); + } + + if (dmEventFields != null) { + localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "dm_event.fields", dmEventFields)); + } + + if (expansions != null) { + localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "expansions", expansions)); + } + + if (mediaFields != null) { + localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "media.fields", mediaFields)); + } + + if (userFields != null) { + localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "user.fields", userFields)); + } + + if (tweetFields != null) { + localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "tweet.fields", tweetFields)); + } + + 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 (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "OAuth2UserToken", "UserToken" }; + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, reduceAuthNames(localVarAuthNames), _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getDmConversationsWithParticipantIdDmEventsValidateBeforeCall(String participantId, Integer maxResults, String paginationToken, Set eventTypes, Set dmEventFields, Set expansions, Set mediaFields, Set userFields, Set tweetFields, final ApiCallback _callback) throws ApiException { + + // verify the required parameter 'participantId' is set + if (participantId == null) { + throw new ApiException("Missing the required parameter 'participantId' when calling getDmConversationsWithParticipantIdDmEvents(Async)"); + } + + + okhttp3.Call localVarCall = getDmConversationsWithParticipantIdDmEventsCall(participantId, maxResults, paginationToken, eventTypes, dmEventFields, expansions, mediaFields, userFields, tweetFields, _callback); + return localVarCall; + + } + + + private ApiResponse getDmConversationsWithParticipantIdDmEventsWithHttpInfo(String participantId, Integer maxResults, String paginationToken, Set eventTypes, Set dmEventFields, Set expansions, Set mediaFields, Set userFields, Set tweetFields) throws ApiException { + okhttp3.Call localVarCall = getDmConversationsWithParticipantIdDmEventsValidateBeforeCall(participantId, maxResults, paginationToken, eventTypes, dmEventFields, expansions, mediaFields, userFields, tweetFields, 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())); + throw e; + } + } + + private okhttp3.Call getDmConversationsWithParticipantIdDmEventsAsync(String participantId, Integer maxResults, String paginationToken, Set eventTypes, Set dmEventFields, Set expansions, Set mediaFields, Set userFields, Set tweetFields, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getDmConversationsWithParticipantIdDmEventsValidateBeforeCall(participantId, maxResults, paginationToken, eventTypes, dmEventFields, expansions, mediaFields, userFields, tweetFields, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + public class APIgetDmConversationsWithParticipantIdDmEventsRequest { + private final String participantId; + private Integer maxResults; + private String paginationToken; + private Set eventTypes; + private Set dmEventFields; + private Set expansions; + private Set mediaFields; + private Set userFields; + private Set tweetFields; + private final Set eventTypesAll = new HashSet<>(Arrays.asList("MessageCreate", "ParticipantsJoin", "ParticipantsLeave")); + private final Set dmEventFieldsAll = new HashSet<>(Arrays.asList("attachments", "created_at", "dm_conversation_id", "event_type", "id", "participant_ids", "referenced_tweets", "sender_id", "text")); + private final Set expansionsAll = new HashSet<>(Arrays.asList("attachments.media_keys", "participant_ids", "referenced_tweets.id", "sender_id")); + private final Set mediaFieldsAll = new HashSet<>(Arrays.asList("alt_text", "duration_ms", "height", "media_key", "non_public_metrics", "organic_metrics", "preview_image_url", "promoted_metrics", "public_metrics", "type", "url", "variants", "width")); + private final Set userFieldsAll = new HashSet<>(Arrays.asList("created_at", "description", "entities", "id", "location", "name", "pinned_tweet_id", "profile_image_url", "protected", "public_metrics", "url", "username", "verified", "withheld")); + private final Set tweetFieldsAll = new HashSet<>(Arrays.asList("attachments", "author_id", "context_annotations", "conversation_id", "created_at", "edit_controls", "edit_history_tweet_ids", "entities", "geo", "id", "in_reply_to_user_id", "lang", "non_public_metrics", "organic_metrics", "possibly_sensitive", "promoted_metrics", "public_metrics", "referenced_tweets", "reply_settings", "source", "text", "withheld")); + + private boolean isExclude = false; + + public APIgetDmConversationsWithParticipantIdDmEventsRequest excludeInputFields() { + isExclude = true; + return this; + } + + private APIgetDmConversationsWithParticipantIdDmEventsRequest(String participantId) { + this.participantId = participantId; + } + + /** + * Set maxResults + * @param maxResults The maximum number of results. (optional, default to 100) + * @return APIgetDmConversationsWithParticipantIdDmEventsRequest + */ + public APIgetDmConversationsWithParticipantIdDmEventsRequest maxResults(Integer maxResults) { + this.maxResults = maxResults; + return this; + } + + /** + * Set paginationToken + * @param paginationToken This parameter is used to get a specified 'page' of results. (optional) + * @return APIgetDmConversationsWithParticipantIdDmEventsRequest + */ + public APIgetDmConversationsWithParticipantIdDmEventsRequest paginationToken(String paginationToken) { + this.paginationToken = paginationToken; + return this; + } + + /** + * Set eventTypes + * @param eventTypes The set of event_types to include in the results. (optional) + * @return APIgetDmConversationsWithParticipantIdDmEventsRequest + */ + public APIgetDmConversationsWithParticipantIdDmEventsRequest eventTypes(Set eventTypes) { + this.eventTypes = eventTypes; + return this; + } + + /** + * Set dmEventFields + * @param dmEventFields A comma separated list of DmEvent fields to display. (optional) + * @return APIgetDmConversationsWithParticipantIdDmEventsRequest + */ + public APIgetDmConversationsWithParticipantIdDmEventsRequest dmEventFields(Set dmEventFields) { + this.dmEventFields = dmEventFields; + return this; + } + + /** + * Set expansions + * @param expansions A comma separated list of fields to expand. (optional) + * @return APIgetDmConversationsWithParticipantIdDmEventsRequest + */ + public APIgetDmConversationsWithParticipantIdDmEventsRequest expansions(Set expansions) { + this.expansions = expansions; + return this; + } + + /** + * Set mediaFields + * @param mediaFields A comma separated list of Media fields to display. (optional) + * @return APIgetDmConversationsWithParticipantIdDmEventsRequest + */ + public APIgetDmConversationsWithParticipantIdDmEventsRequest mediaFields(Set mediaFields) { + this.mediaFields = mediaFields; + return this; + } + + /** + * Set userFields + * @param userFields A comma separated list of User fields to display. (optional) + * @return APIgetDmConversationsWithParticipantIdDmEventsRequest + */ + public APIgetDmConversationsWithParticipantIdDmEventsRequest userFields(Set userFields) { + this.userFields = userFields; + return this; + } + + /** + * Set tweetFields + * @param tweetFields A comma separated list of Tweet fields to display. (optional) + * @return APIgetDmConversationsWithParticipantIdDmEventsRequest + */ + public APIgetDmConversationsWithParticipantIdDmEventsRequest tweetFields(Set tweetFields) { + this.tweetFields = tweetFields; + return this; + } + + /** + * Build call for getDmConversationsWithParticipantIdDmEvents + * @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 The request has succeeded. -
0 The request has failed. -
+ */ + public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException { + return getDmConversationsWithParticipantIdDmEventsCall(participantId, maxResults, paginationToken, eventTypes, dmEventFields, expansions, mediaFields, userFields, tweetFields, _callback); + } + + /** + * Execute getDmConversationsWithParticipantIdDmEvents request + * @return Get2DmConversationsWithParticipantIdDmEventsResponse + * @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 has succeeded. -
0 The request has failed. -
+ */ + public Get2DmConversationsWithParticipantIdDmEventsResponse execute() throws ApiException { + eventTypes = getFields("eventTypes", isExclude, eventTypes, eventTypesAll); + dmEventFields = getFields("dmEventFields", isExclude, dmEventFields, dmEventFieldsAll); + expansions = getFields("expansions", isExclude, expansions, expansionsAll); + mediaFields = getFields("mediaFields", isExclude, mediaFields, mediaFieldsAll); + userFields = getFields("userFields", isExclude, userFields, userFieldsAll); + tweetFields = getFields("tweetFields", isExclude, tweetFields, tweetFieldsAll); + + ApiResponse localVarResp = getDmConversationsWithParticipantIdDmEventsWithHttpInfo(participantId, maxResults, paginationToken, eventTypes, dmEventFields, expansions, mediaFields, userFields, tweetFields); + return localVarResp.getData(); + } + /** + * Calls the API using a retry mechanism to handle rate limits errors. + * + */ + public Get2DmConversationsWithParticipantIdDmEventsResponse execute(Integer retries) throws ApiException { + Get2DmConversationsWithParticipantIdDmEventsResponse localVarResp; + try{ + localVarResp = execute(); + } catch (ApiException e) { + if(handleRateLimit(e, retries)) { + return execute(retries - 1); + } else { + throw e; + } + } + return localVarResp; + } + /** + * Execute getDmConversationsWithParticipantIdDmEvents request with HTTP info returned + * @return ApiResponse<Get2DmConversationsWithParticipantIdDmEventsResponse> + * @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 has succeeded. -
0 The request has failed. -
+ */ + + public ApiResponse executeWithHttpInfo() throws ApiException { + return getDmConversationsWithParticipantIdDmEventsWithHttpInfo(participantId, maxResults, paginationToken, eventTypes, dmEventFields, expansions, mediaFields, userFields, tweetFields); + } + /** + * Execute getDmConversationsWithParticipantIdDmEvents 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 The request has succeeded. -
0 The request has failed. -
+ */ + public okhttp3.Call executeAsync(final ApiCallback _callback) throws ApiException { + return getDmConversationsWithParticipantIdDmEventsAsync(participantId, maxResults, paginationToken, eventTypes, dmEventFields, expansions, mediaFields, userFields, tweetFields, _callback); + } + } + + /** + * Get DM Events for a DM Conversation + * Returns DM Events for a DM Conversation + * @param participantId The ID of the participant user for the One to One DM conversation. (required) + * @return APIgetDmConversationsWithParticipantIdDmEventsRequest + * @http.response.details + + + + +
Status Code Description Response Headers
200 The request has succeeded. -
0 The request has failed. -
+ */ + public APIgetDmConversationsWithParticipantIdDmEventsRequest getDmConversationsWithParticipantIdDmEvents(String participantId) { + return new APIgetDmConversationsWithParticipantIdDmEventsRequest(participantId); + } + private okhttp3.Call getDmEventsCall(Integer maxResults, String paginationToken, Set eventTypes, Set dmEventFields, Set expansions, Set mediaFields, Set userFields, Set tweetFields, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/2/dm_events"; + + 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 (eventTypes != null) { + localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "event_types", eventTypes)); + } + + if (dmEventFields != null) { + localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "dm_event.fields", dmEventFields)); + } + + if (expansions != null) { + localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "expansions", expansions)); + } + + if (mediaFields != null) { + localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "media.fields", mediaFields)); + } + + if (userFields != null) { + localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "user.fields", userFields)); + } + + if (tweetFields != null) { + localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "tweet.fields", tweetFields)); + } + + 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 (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "OAuth2UserToken", "UserToken" }; + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, reduceAuthNames(localVarAuthNames), _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getDmEventsValidateBeforeCall(Integer maxResults, String paginationToken, Set eventTypes, Set dmEventFields, Set expansions, Set mediaFields, Set userFields, Set tweetFields, final ApiCallback _callback) throws ApiException { + + + okhttp3.Call localVarCall = getDmEventsCall(maxResults, paginationToken, eventTypes, dmEventFields, expansions, mediaFields, userFields, tweetFields, _callback); + return localVarCall; + + } + + + private ApiResponse getDmEventsWithHttpInfo(Integer maxResults, String paginationToken, Set eventTypes, Set dmEventFields, Set expansions, Set mediaFields, Set userFields, Set tweetFields) throws ApiException { + okhttp3.Call localVarCall = getDmEventsValidateBeforeCall(maxResults, paginationToken, eventTypes, dmEventFields, expansions, mediaFields, userFields, tweetFields, 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())); + throw e; + } + } + + private okhttp3.Call getDmEventsAsync(Integer maxResults, String paginationToken, Set eventTypes, Set dmEventFields, Set expansions, Set mediaFields, Set userFields, Set tweetFields, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getDmEventsValidateBeforeCall(maxResults, paginationToken, eventTypes, dmEventFields, expansions, mediaFields, userFields, tweetFields, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + public class APIgetDmEventsRequest { + private Integer maxResults; + private String paginationToken; + private Set eventTypes; + private Set dmEventFields; + private Set expansions; + private Set mediaFields; + private Set userFields; + private Set tweetFields; + private final Set eventTypesAll = new HashSet<>(Arrays.asList("MessageCreate", "ParticipantsJoin", "ParticipantsLeave")); + private final Set dmEventFieldsAll = new HashSet<>(Arrays.asList("attachments", "created_at", "dm_conversation_id", "event_type", "id", "participant_ids", "referenced_tweets", "sender_id", "text")); + private final Set expansionsAll = new HashSet<>(Arrays.asList("attachments.media_keys", "participant_ids", "referenced_tweets.id", "sender_id")); + private final Set mediaFieldsAll = new HashSet<>(Arrays.asList("alt_text", "duration_ms", "height", "media_key", "non_public_metrics", "organic_metrics", "preview_image_url", "promoted_metrics", "public_metrics", "type", "url", "variants", "width")); + private final Set userFieldsAll = new HashSet<>(Arrays.asList("created_at", "description", "entities", "id", "location", "name", "pinned_tweet_id", "profile_image_url", "protected", "public_metrics", "url", "username", "verified", "withheld")); + private final Set tweetFieldsAll = new HashSet<>(Arrays.asList("attachments", "author_id", "context_annotations", "conversation_id", "created_at", "edit_controls", "edit_history_tweet_ids", "entities", "geo", "id", "in_reply_to_user_id", "lang", "non_public_metrics", "organic_metrics", "possibly_sensitive", "promoted_metrics", "public_metrics", "referenced_tweets", "reply_settings", "source", "text", "withheld")); + + private boolean isExclude = false; + + public APIgetDmEventsRequest excludeInputFields() { + isExclude = true; + return this; + } + + private APIgetDmEventsRequest() { + } + + /** + * Set maxResults + * @param maxResults The maximum number of results. (optional, default to 100) + * @return APIgetDmEventsRequest + */ + public APIgetDmEventsRequest maxResults(Integer maxResults) { + this.maxResults = maxResults; + return this; + } + + /** + * Set paginationToken + * @param paginationToken This parameter is used to get a specified 'page' of results. (optional) + * @return APIgetDmEventsRequest + */ + public APIgetDmEventsRequest paginationToken(String paginationToken) { + this.paginationToken = paginationToken; + return this; + } + + /** + * Set eventTypes + * @param eventTypes The set of event_types to include in the results. (optional) + * @return APIgetDmEventsRequest + */ + public APIgetDmEventsRequest eventTypes(Set eventTypes) { + this.eventTypes = eventTypes; + return this; + } + + /** + * Set dmEventFields + * @param dmEventFields A comma separated list of DmEvent fields to display. (optional) + * @return APIgetDmEventsRequest + */ + public APIgetDmEventsRequest dmEventFields(Set dmEventFields) { + this.dmEventFields = dmEventFields; + return this; + } + + /** + * Set expansions + * @param expansions A comma separated list of fields to expand. (optional) + * @return APIgetDmEventsRequest + */ + public APIgetDmEventsRequest expansions(Set expansions) { + this.expansions = expansions; + return this; + } + + /** + * Set mediaFields + * @param mediaFields A comma separated list of Media fields to display. (optional) + * @return APIgetDmEventsRequest + */ + public APIgetDmEventsRequest mediaFields(Set mediaFields) { + this.mediaFields = mediaFields; + return this; + } + + /** + * Set userFields + * @param userFields A comma separated list of User fields to display. (optional) + * @return APIgetDmEventsRequest + */ + public APIgetDmEventsRequest userFields(Set userFields) { + this.userFields = userFields; + return this; + } + + /** + * Set tweetFields + * @param tweetFields A comma separated list of Tweet fields to display. (optional) + * @return APIgetDmEventsRequest + */ + public APIgetDmEventsRequest tweetFields(Set tweetFields) { + this.tweetFields = tweetFields; + return this; + } + + /** + * Build call for getDmEvents + * @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 The request has succeeded. -
0 The request has failed. -
+ */ + public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException { + return getDmEventsCall(maxResults, paginationToken, eventTypes, dmEventFields, expansions, mediaFields, userFields, tweetFields, _callback); + } + + /** + * Execute getDmEvents request + * @return Get2DmEventsResponse + * @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 has succeeded. -
0 The request has failed. -
+ */ + public Get2DmEventsResponse execute() throws ApiException { + eventTypes = getFields("eventTypes", isExclude, eventTypes, eventTypesAll); + dmEventFields = getFields("dmEventFields", isExclude, dmEventFields, dmEventFieldsAll); + expansions = getFields("expansions", isExclude, expansions, expansionsAll); + mediaFields = getFields("mediaFields", isExclude, mediaFields, mediaFieldsAll); + userFields = getFields("userFields", isExclude, userFields, userFieldsAll); + tweetFields = getFields("tweetFields", isExclude, tweetFields, tweetFieldsAll); + + ApiResponse localVarResp = getDmEventsWithHttpInfo(maxResults, paginationToken, eventTypes, dmEventFields, expansions, mediaFields, userFields, tweetFields); + return localVarResp.getData(); + } + /** + * Calls the API using a retry mechanism to handle rate limits errors. + * + */ + public Get2DmEventsResponse execute(Integer retries) throws ApiException { + Get2DmEventsResponse localVarResp; + try{ + localVarResp = execute(); + } catch (ApiException e) { + if(handleRateLimit(e, retries)) { + return execute(retries - 1); + } else { + throw e; + } + } + return localVarResp; + } + /** + * Execute getDmEvents request with HTTP info returned + * @return ApiResponse<Get2DmEventsResponse> + * @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 has succeeded. -
0 The request has failed. -
+ */ + + public ApiResponse executeWithHttpInfo() throws ApiException { + return getDmEventsWithHttpInfo(maxResults, paginationToken, eventTypes, dmEventFields, expansions, mediaFields, userFields, tweetFields); + } + /** + * Execute getDmEvents 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 The request has succeeded. -
0 The request has failed. -
+ */ + public okhttp3.Call executeAsync(final ApiCallback _callback) throws ApiException { + return getDmEventsAsync(maxResults, paginationToken, eventTypes, dmEventFields, expansions, mediaFields, userFields, tweetFields, _callback); + } + } + + /** + * Get recent DM Events + * Returns recent DM Events across DM conversations + * @return APIgetDmEventsRequest + * @http.response.details + + + + +
Status Code Description Response Headers
200 The request has succeeded. -
0 The request has failed. -
+ */ + public APIgetDmEventsRequest getDmEvents() { + return new APIgetDmEventsRequest(); + } +} diff --git a/src/main/java/com/twitter/clientlib/api/TwitterApi.java b/src/main/java/com/twitter/clientlib/api/TwitterApi.java index a20b38f..9a3d9ac 100644 --- a/src/main/java/com/twitter/clientlib/api/TwitterApi.java +++ b/src/main/java/com/twitter/clientlib/api/TwitterApi.java @@ -37,6 +37,7 @@ public class TwitterApi { private final BookmarksApi bookmarks = new BookmarksApi(); private final ComplianceApi compliance = new ComplianceApi(); + private final DirectMessagesApi directMessages = new DirectMessagesApi(); private final GeneralApi general = new GeneralApi(); private final ListsApi lists = new ListsApi(); private final SpacesApi spaces = new SpacesApi(); @@ -77,13 +78,14 @@ private void init() { } private void initApis() { - bookmarks.setClient(localVarApiClient); - compliance.setClient(localVarApiClient); - general.setClient(localVarApiClient); - lists.setClient(localVarApiClient); - spaces.setClient(localVarApiClient); - tweets.setClient(localVarApiClient); - users.setClient(localVarApiClient); + bookmarks.setClient(localVarApiClient); + compliance.setClient(localVarApiClient); + directMessages.setClient(localVarApiClient); + general.setClient(localVarApiClient); + lists.setClient(localVarApiClient); + spaces.setClient(localVarApiClient); + tweets.setClient(localVarApiClient); + users.setClient(localVarApiClient); } public BookmarksApi bookmarks() { @@ -92,6 +94,9 @@ public BookmarksApi bookmarks() { public ComplianceApi compliance() { return compliance; } + public DirectMessagesApi directMessages() { + return directMessages; + } public GeneralApi general() { return general; } diff --git a/src/main/java/com/twitter/clientlib/model/CreateAttachmentsMessageRequest.java b/src/main/java/com/twitter/clientlib/model/CreateAttachmentsMessageRequest.java new file mode 100644 index 0000000..3b6b8bf --- /dev/null +++ b/src/main/java/com/twitter/clientlib/model/CreateAttachmentsMessageRequest.java @@ -0,0 +1,269 @@ +/* +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.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.twitter.clientlib.model.DmMediaAttachment; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.twitter.clientlib.JSON; + +/** + * CreateAttachmentsMessageRequest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class CreateAttachmentsMessageRequest { + public static final String SERIALIZED_NAME_ATTACHMENTS = "attachments"; + @SerializedName(SERIALIZED_NAME_ATTACHMENTS) + private List attachments = new ArrayList<>(); + + public static final String SERIALIZED_NAME_TEXT = "text"; + @SerializedName(SERIALIZED_NAME_TEXT) + private String text; + + public CreateAttachmentsMessageRequest() { + } + + public CreateAttachmentsMessageRequest attachments(List attachments) { + + this.attachments = attachments; + return this; + } + + public CreateAttachmentsMessageRequest addAttachmentsItem(DmMediaAttachment attachmentsItem) { + this.attachments.add(attachmentsItem); + return this; + } + + /** + * Attachments to a DM Event. + * @return attachments + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "Attachments to a DM Event.") + + public List getAttachments() { + return attachments; + } + + + public void setAttachments(List attachments) { + this.attachments = attachments; + } + + + public CreateAttachmentsMessageRequest text(String text) { + + this.text = text; + return this; + } + + /** + * Text of the message. + * @return text + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Text of the message.") + + public String getText() { + return text; + } + + + public void setText(String text) { + this.text = text; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateAttachmentsMessageRequest createAttachmentsMessageRequest = (CreateAttachmentsMessageRequest) o; + return Objects.equals(this.attachments, createAttachmentsMessageRequest.attachments) && + Objects.equals(this.text, createAttachmentsMessageRequest.text); + } + + @Override + public int hashCode() { + return Objects.hash(attachments, text); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateAttachmentsMessageRequest {\n"); + sb.append(" attachments: ").append(toIndentedString(attachments)).append("\n"); + sb.append(" text: ").append(toIndentedString(text)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("attachments"); + openapiFields.add("text"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("attachments"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateAttachmentsMessageRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // if (jsonObj == null) { + // if (CreateAttachmentsMessageRequest.openapiRequiredFields.isEmpty()) { + // return; + // } else { // has required fields + // throw new IllegalArgumentException(String.format("The required field(s) %s in CreateAttachmentsMessageRequest is not found in the empty JSON string", CreateAttachmentsMessageRequest.openapiRequiredFields.toString())); + // } + // } + + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateAttachmentsMessageRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + JsonArray jsonArrayattachments = jsonObj.getAsJsonArray("attachments"); + if (jsonArrayattachments != null) { + // ensure the json data is an array + if (!jsonObj.get("attachments").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `attachments` to be an array in the JSON string but got `%s`", jsonObj.get("attachments").toString())); + } + + // validate the optional field `attachments` (array) + for (int i = 0; i < jsonArrayattachments.size(); i++) { + DmMediaAttachment.validateJsonObject(jsonArrayattachments.get(i).getAsJsonObject()); + }; + } + if (jsonObj.get("text") != null && !jsonObj.get("text").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `text` to be a primitive type in the JSON string but got `%s`", jsonObj.get("text").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateAttachmentsMessageRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateAttachmentsMessageRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateAttachmentsMessageRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateAttachmentsMessageRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateAttachmentsMessageRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateAttachmentsMessageRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateAttachmentsMessageRequest + * @throws IOException if the JSON string is invalid with respect to CreateAttachmentsMessageRequest + */ + public static CreateAttachmentsMessageRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateAttachmentsMessageRequest.class); + } + + /** + * Convert an instance of CreateAttachmentsMessageRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/twitter/clientlib/model/CreateDmConversationRequest.java b/src/main/java/com/twitter/clientlib/model/CreateDmConversationRequest.java new file mode 100644 index 0000000..b75e30b --- /dev/null +++ b/src/main/java/com/twitter/clientlib/model/CreateDmConversationRequest.java @@ -0,0 +1,342 @@ +/* +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.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.twitter.clientlib.model.CreateMessageRequest; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.twitter.clientlib.JSON; + +/** + * CreateDmConversationRequest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class CreateDmConversationRequest { + /** + * The conversation type that is being created. + */ + @JsonAdapter(ConversationTypeEnum.Adapter.class) + public enum ConversationTypeEnum { + GROUP("Group"); + + private String value; + + ConversationTypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static ConversationTypeEnum fromValue(String value) { + for (ConversationTypeEnum b : ConversationTypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final ConversationTypeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public ConversationTypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return ConversationTypeEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_CONVERSATION_TYPE = "conversation_type"; + @SerializedName(SERIALIZED_NAME_CONVERSATION_TYPE) + private ConversationTypeEnum conversationType; + + public static final String SERIALIZED_NAME_MESSAGE = "message"; + @SerializedName(SERIALIZED_NAME_MESSAGE) + private CreateMessageRequest message; + + public static final String SERIALIZED_NAME_PARTICIPANT_IDS = "participant_ids"; + @SerializedName(SERIALIZED_NAME_PARTICIPANT_IDS) + private List participantIds = new ArrayList<>(); + + public CreateDmConversationRequest() { + } + + public CreateDmConversationRequest conversationType(ConversationTypeEnum conversationType) { + + this.conversationType = conversationType; + return this; + } + + /** + * The conversation type that is being created. + * @return conversationType + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "The conversation type that is being created.") + + public ConversationTypeEnum getConversationType() { + return conversationType; + } + + + public void setConversationType(ConversationTypeEnum conversationType) { + this.conversationType = conversationType; + } + + + public CreateDmConversationRequest message(CreateMessageRequest message) { + + this.message = message; + return this; + } + + /** + * Get message + * @return message + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + + public CreateMessageRequest getMessage() { + return message; + } + + + public void setMessage(CreateMessageRequest message) { + this.message = message; + } + + + public CreateDmConversationRequest participantIds(List participantIds) { + + this.participantIds = participantIds; + return this; + } + + public CreateDmConversationRequest addParticipantIdsItem(String participantIdsItem) { + this.participantIds.add(participantIdsItem); + return this; + } + + /** + * Participants for the DM Conversation. + * @return participantIds + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "Participants for the DM Conversation.") + + public List getParticipantIds() { + return participantIds; + } + + + public void setParticipantIds(List participantIds) { + this.participantIds = participantIds; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateDmConversationRequest createDmConversationRequest = (CreateDmConversationRequest) o; + return Objects.equals(this.conversationType, createDmConversationRequest.conversationType) && + Objects.equals(this.message, createDmConversationRequest.message) && + Objects.equals(this.participantIds, createDmConversationRequest.participantIds); + } + + @Override + public int hashCode() { + return Objects.hash(conversationType, message, participantIds); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateDmConversationRequest {\n"); + sb.append(" conversationType: ").append(toIndentedString(conversationType)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" participantIds: ").append(toIndentedString(participantIds)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("conversation_type"); + openapiFields.add("message"); + openapiFields.add("participant_ids"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("conversation_type"); + openapiRequiredFields.add("message"); + openapiRequiredFields.add("participant_ids"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateDmConversationRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // if (jsonObj == null) { + // if (CreateDmConversationRequest.openapiRequiredFields.isEmpty()) { + // return; + // } else { // has required fields + // throw new IllegalArgumentException(String.format("The required field(s) %s in CreateDmConversationRequest is not found in the empty JSON string", CreateDmConversationRequest.openapiRequiredFields.toString())); + // } + // } + + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateDmConversationRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (jsonObj.get("conversation_type") != null && !jsonObj.get("conversation_type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `conversation_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("conversation_type").toString())); + } + // validate the optional field `message` + if (jsonObj.getAsJsonObject("message") != null) { + CreateMessageRequest.validateJsonObject(jsonObj.getAsJsonObject("message")); + } + // ensure the json data is an array + if (jsonObj.get("participant_ids") != null && !jsonObj.get("participant_ids").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `participant_ids` to be an array in the JSON string but got `%s`", jsonObj.get("participant_ids").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateDmConversationRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateDmConversationRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateDmConversationRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateDmConversationRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateDmConversationRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateDmConversationRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateDmConversationRequest + * @throws IOException if the JSON string is invalid with respect to CreateDmConversationRequest + */ + public static CreateDmConversationRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateDmConversationRequest.class); + } + + /** + * Convert an instance of CreateDmConversationRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/twitter/clientlib/model/ProblemErrors.java b/src/main/java/com/twitter/clientlib/model/CreateDmEventResponse.java similarity index 67% rename from src/main/java/com/twitter/clientlib/model/ProblemErrors.java rename to src/main/java/com/twitter/clientlib/model/CreateDmEventResponse.java index a420fd0..86bd7b0 100644 --- a/src/main/java/com/twitter/clientlib/model/ProblemErrors.java +++ b/src/main/java/com/twitter/clientlib/model/CreateDmEventResponse.java @@ -29,6 +29,7 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import com.twitter.clientlib.model.CreateDmEventResponseData; import com.twitter.clientlib.model.Problem; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -57,24 +58,54 @@ import com.twitter.clientlib.JSON; /** - * ProblemErrors + * CreateDmEventResponse */ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") -public class ProblemErrors { +public class CreateDmEventResponse { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private CreateDmEventResponseData data; + public static final String SERIALIZED_NAME_ERRORS = "errors"; @SerializedName(SERIALIZED_NAME_ERRORS) - private List errors = new ArrayList<>(); + private List errors = null; - public ProblemErrors() { + public CreateDmEventResponse() { } - public ProblemErrors errors(List errors) { + public CreateDmEventResponse data(CreateDmEventResponseData data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public CreateDmEventResponseData getData() { + return data; + } + + + public void setData(CreateDmEventResponseData data) { + this.data = data; + } + + + public CreateDmEventResponse errors(List errors) { this.errors = errors; return this; } - public ProblemErrors addErrorsItem(Problem errorsItem) { + public CreateDmEventResponse addErrorsItem(Problem errorsItem) { + if (this.errors == null) { + this.errors = new ArrayList<>(); + } this.errors.add(errorsItem); return this; } @@ -83,8 +114,8 @@ public ProblemErrors addErrorsItem(Problem errorsItem) { * Get errors * @return errors **/ - @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") + @javax.annotation.Nullable + @ApiModelProperty(value = "") public List getErrors() { return errors; @@ -105,19 +136,21 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - ProblemErrors problemErrors = (ProblemErrors) o; - return Objects.equals(this.errors, problemErrors.errors); + CreateDmEventResponse createDmEventResponse = (CreateDmEventResponse) o; + return Objects.equals(this.data, createDmEventResponse.data) && + Objects.equals(this.errors, createDmEventResponse.errors); } @Override public int hashCode() { - return Objects.hash(errors); + return Objects.hash(data, errors); } @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class ProblemErrors {\n"); + sb.append("class CreateDmEventResponse {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append("}"); return sb.toString(); @@ -141,34 +174,31 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) openapiFields = new HashSet(); + openapiFields.add("data"); openapiFields.add("errors"); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(); - openapiRequiredFields.add("errors"); } /** * Validates the JSON Object and throws an exception if issues found * * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to ProblemErrors + * @throws IOException if the JSON Object is invalid with respect to CreateDmEventResponse */ public static void validateJsonObject(JsonObject jsonObj) throws IOException { // if (jsonObj == null) { - // if (ProblemErrors.openapiRequiredFields.isEmpty()) { + // if (CreateDmEventResponse.openapiRequiredFields.isEmpty()) { // return; // } else { // has required fields - // throw new IllegalArgumentException(String.format("The required field(s) %s in ProblemErrors is not found in the empty JSON string", ProblemErrors.openapiRequiredFields.toString())); + // throw new IllegalArgumentException(String.format("The required field(s) %s in CreateDmEventResponse is not found in the empty JSON string", CreateDmEventResponse.openapiRequiredFields.toString())); // } // } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : ProblemErrors.openapiRequiredFields) { - if (jsonObj.get(requiredField) == null) { - throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); - } + // validate the optional field `data` + if (jsonObj.getAsJsonObject("data") != null) { + CreateDmEventResponseData.validateJsonObject(jsonObj.getAsJsonObject("data")); } JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { @@ -188,22 +218,22 @@ public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!ProblemErrors.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'ProblemErrors' and its subtypes + if (!CreateDmEventResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateDmEventResponse' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(ProblemErrors.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateDmEventResponse.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, ProblemErrors value) throws IOException { + public void write(JsonWriter out, CreateDmEventResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); elementAdapter.write(out, obj); } @Override - public ProblemErrors read(JsonReader in) throws IOException { + public CreateDmEventResponse read(JsonReader in) throws IOException { JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); validateJsonObject(jsonObj); return thisAdapter.fromJsonTree(jsonObj); @@ -214,18 +244,18 @@ public ProblemErrors read(JsonReader in) throws IOException { } /** - * Create an instance of ProblemErrors given an JSON string + * Create an instance of CreateDmEventResponse given an JSON string * * @param jsonString JSON string - * @return An instance of ProblemErrors - * @throws IOException if the JSON string is invalid with respect to ProblemErrors + * @return An instance of CreateDmEventResponse + * @throws IOException if the JSON string is invalid with respect to CreateDmEventResponse */ - public static ProblemErrors fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, ProblemErrors.class); + public static CreateDmEventResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateDmEventResponse.class); } /** - * Convert an instance of ProblemErrors to an JSON string + * Convert an instance of CreateDmEventResponse to an JSON string * * @return JSON string */ diff --git a/src/main/java/com/twitter/clientlib/model/CreateDmEventResponseData.java b/src/main/java/com/twitter/clientlib/model/CreateDmEventResponseData.java new file mode 100644 index 0000000..9eaa34d --- /dev/null +++ b/src/main/java/com/twitter/clientlib/model/CreateDmEventResponseData.java @@ -0,0 +1,253 @@ +/* +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.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.twitter.clientlib.JSON; + +/** + * CreateDmEventResponseData + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class CreateDmEventResponseData { + public static final String SERIALIZED_NAME_DM_CONVERSATION_ID = "dm_conversation_id"; + @SerializedName(SERIALIZED_NAME_DM_CONVERSATION_ID) + private String dmConversationId; + + public static final String SERIALIZED_NAME_DM_EVENT_ID = "dm_event_id"; + @SerializedName(SERIALIZED_NAME_DM_EVENT_ID) + private String dmEventId; + + public CreateDmEventResponseData() { + } + + public CreateDmEventResponseData dmConversationId(String dmConversationId) { + + this.dmConversationId = dmConversationId; + return this; + } + + /** + * Unique identifier of a DM conversation. This can either be a numeric string, or a pair of numeric strings separated by a '-' character in the case of one-on-one DM Conversations. + * @return dmConversationId + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "123123123-456456456", required = true, value = "Unique identifier of a DM conversation. This can either be a numeric string, or a pair of numeric strings separated by a '-' character in the case of one-on-one DM Conversations.") + + public String getDmConversationId() { + return dmConversationId; + } + + + public void setDmConversationId(String dmConversationId) { + this.dmConversationId = dmConversationId; + } + + + public CreateDmEventResponseData dmEventId(String dmEventId) { + + this.dmEventId = dmEventId; + return this; + } + + /** + * Unique identifier of a DM Event. + * @return dmEventId + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "1146654567674912769", required = true, value = "Unique identifier of a DM Event.") + + public String getDmEventId() { + return dmEventId; + } + + + public void setDmEventId(String dmEventId) { + this.dmEventId = dmEventId; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateDmEventResponseData createDmEventResponseData = (CreateDmEventResponseData) o; + return Objects.equals(this.dmConversationId, createDmEventResponseData.dmConversationId) && + Objects.equals(this.dmEventId, createDmEventResponseData.dmEventId); + } + + @Override + public int hashCode() { + return Objects.hash(dmConversationId, dmEventId); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateDmEventResponseData {\n"); + sb.append(" dmConversationId: ").append(toIndentedString(dmConversationId)).append("\n"); + sb.append(" dmEventId: ").append(toIndentedString(dmEventId)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("dm_conversation_id"); + openapiFields.add("dm_event_id"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("dm_conversation_id"); + openapiRequiredFields.add("dm_event_id"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateDmEventResponseData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // if (jsonObj == null) { + // if (CreateDmEventResponseData.openapiRequiredFields.isEmpty()) { + // return; + // } else { // has required fields + // throw new IllegalArgumentException(String.format("The required field(s) %s in CreateDmEventResponseData is not found in the empty JSON string", CreateDmEventResponseData.openapiRequiredFields.toString())); + // } + // } + + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateDmEventResponseData.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (jsonObj.get("dm_conversation_id") != null && !jsonObj.get("dm_conversation_id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `dm_conversation_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("dm_conversation_id").toString())); + } + if (jsonObj.get("dm_event_id") != null && !jsonObj.get("dm_event_id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `dm_event_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("dm_event_id").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateDmEventResponseData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateDmEventResponseData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateDmEventResponseData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateDmEventResponseData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateDmEventResponseData read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateDmEventResponseData given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateDmEventResponseData + * @throws IOException if the JSON string is invalid with respect to CreateDmEventResponseData + */ + public static CreateDmEventResponseData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateDmEventResponseData.class); + } + + /** + * Convert an instance of CreateDmEventResponseData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/twitter/clientlib/model/CreateMessageRequest.java b/src/main/java/com/twitter/clientlib/model/CreateMessageRequest.java new file mode 100644 index 0000000..2b69b8a --- /dev/null +++ b/src/main/java/com/twitter/clientlib/model/CreateMessageRequest.java @@ -0,0 +1,288 @@ +/* +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.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.twitter.clientlib.model.CreateAttachmentsMessageRequest; +import com.twitter.clientlib.model.CreateTextMessageRequest; +import com.twitter.clientlib.model.DmMediaAttachment; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import javax.ws.rs.core.GenericType; + +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.JsonPrimitive; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; + +import com.twitter.clientlib.JSON; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class CreateMessageRequest extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(CreateMessageRequest.class.getName()); + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateMessageRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateMessageRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter adapterCreateAttachmentsMessageRequest = gson.getDelegateAdapter(this, TypeToken.get(CreateAttachmentsMessageRequest.class)); + final TypeAdapter adapterCreateTextMessageRequest = gson.getDelegateAdapter(this, TypeToken.get(CreateTextMessageRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateMessageRequest value) throws IOException { + if (value == null || value.getActualInstance() == null) { + elementAdapter.write(out, null); + return; + } + + // check if the actual instance is of the type `CreateAttachmentsMessageRequest` + if (value.getActualInstance() instanceof CreateAttachmentsMessageRequest) { + JsonObject obj = adapterCreateAttachmentsMessageRequest.toJsonTree((CreateAttachmentsMessageRequest)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + // check if the actual instance is of the type `CreateTextMessageRequest` + if (value.getActualInstance() instanceof CreateTextMessageRequest) { + JsonObject obj = adapterCreateTextMessageRequest.toJsonTree((CreateTextMessageRequest)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + throw new IOException("Failed to serialize as the type doesn't match anyOf schemas: CreateAttachmentsMessageRequest, CreateTextMessageRequest"); + } + + @Override + public CreateMessageRequest read(JsonReader in) throws IOException { + Object deserialized = null; + JsonObject jsonObject = elementAdapter.read(in).getAsJsonObject(); + + // deserialize CreateAttachmentsMessageRequest + try { + // validate the JSON object to see if any exception is thrown + CreateAttachmentsMessageRequest.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'CreateAttachmentsMessageRequest'"); + CreateMessageRequest ret = new CreateMessageRequest(); + ret.setActualInstance(adapterCreateAttachmentsMessageRequest.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'CreateAttachmentsMessageRequest'", e); + } + + // deserialize CreateTextMessageRequest + try { + // validate the JSON object to see if any exception is thrown + CreateTextMessageRequest.validateJsonObject(jsonObject); + log.log(Level.FINER, "Input data matches schema 'CreateTextMessageRequest'"); + CreateMessageRequest ret = new CreateMessageRequest(); + ret.setActualInstance(adapterCreateTextMessageRequest.fromJsonTree(jsonObject)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'CreateTextMessageRequest'", e); + } + + + throw new IOException(String.format("Failed deserialization for CreateMessageRequest: no class matched. JSON: %s", jsonObject.toString())); + } + }.nullSafe(); + } + } + + // store a list of schema names defined in anyOf + public static final Map schemas = new HashMap(); + + public CreateMessageRequest() { + super("anyOf", Boolean.FALSE); + } + + public CreateMessageRequest(CreateAttachmentsMessageRequest o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + public CreateMessageRequest(CreateTextMessageRequest o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("CreateAttachmentsMessageRequest", new GenericType() { + }); + schemas.put("CreateTextMessageRequest", new GenericType() { + }); + } + + @Override + public Map getSchemas() { + return CreateMessageRequest.schemas; + } + + /** + * Set the instance that matches the anyOf child schema, check + * the instance parameter is valid against the anyOf child schemas: + * CreateAttachmentsMessageRequest, CreateTextMessageRequest + * + * It could be an instance of the 'anyOf' schemas. + * The anyOf child schemas may themselves be a composed schema (allOf, anyOf, anyOf). + */ + @Override + public void setActualInstance(Object instance) { + if (instance instanceof CreateAttachmentsMessageRequest) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof CreateTextMessageRequest) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be CreateAttachmentsMessageRequest, CreateTextMessageRequest"); + } + + /** + * Get the actual instance, which can be the following: + * CreateAttachmentsMessageRequest, CreateTextMessageRequest + * + * @return The actual instance (CreateAttachmentsMessageRequest, CreateTextMessageRequest) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `CreateAttachmentsMessageRequest`. If the actual instance is not `CreateAttachmentsMessageRequest`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `CreateAttachmentsMessageRequest` + * @throws ClassCastException if the instance is not `CreateAttachmentsMessageRequest` + */ + public CreateAttachmentsMessageRequest getCreateAttachmentsMessageRequest() throws ClassCastException { + return (CreateAttachmentsMessageRequest)super.getActualInstance(); + } + + /** + * Get the actual instance of `CreateTextMessageRequest`. If the actual instance is not `CreateTextMessageRequest`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `CreateTextMessageRequest` + * @throws ClassCastException if the instance is not `CreateTextMessageRequest` + */ + public CreateTextMessageRequest getCreateTextMessageRequest() throws ClassCastException { + return (CreateTextMessageRequest)super.getActualInstance(); + } + + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateMessageRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // validate anyOf schemas one by one + int validCount = 0; + // validate the json string with CreateAttachmentsMessageRequest + try { + CreateAttachmentsMessageRequest.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + // validate the json string with CreateTextMessageRequest + try { + CreateTextMessageRequest.validateJsonObject(jsonObj); + return; // return earlier as at least one schema is valid with respect to the Json object + //validCount++; + } catch (Exception e) { + // continue to the next one + } + if (validCount == 0) { + throw new IOException(String.format("The JSON string is invalid for CreateMessageRequest with anyOf schemas: CreateAttachmentsMessageRequest, CreateTextMessageRequest. JSON: %s", jsonObj.toString())); + } + } + + /** + * Create an instance of CreateMessageRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateMessageRequest + * @throws IOException if the JSON string is invalid with respect to CreateMessageRequest + */ + public static CreateMessageRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateMessageRequest.class); + } + + /** + * Convert an instance of CreateMessageRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/twitter/clientlib/model/CreateTextMessageRequest.java b/src/main/java/com/twitter/clientlib/model/CreateTextMessageRequest.java new file mode 100644 index 0000000..36f65cb --- /dev/null +++ b/src/main/java/com/twitter/clientlib/model/CreateTextMessageRequest.java @@ -0,0 +1,272 @@ +/* +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.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.twitter.clientlib.model.DmMediaAttachment; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.twitter.clientlib.JSON; + +/** + * CreateTextMessageRequest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class CreateTextMessageRequest { + public static final String SERIALIZED_NAME_ATTACHMENTS = "attachments"; + @SerializedName(SERIALIZED_NAME_ATTACHMENTS) + private List attachments = null; + + public static final String SERIALIZED_NAME_TEXT = "text"; + @SerializedName(SERIALIZED_NAME_TEXT) + private String text; + + public CreateTextMessageRequest() { + } + + public CreateTextMessageRequest attachments(List attachments) { + + this.attachments = attachments; + return this; + } + + public CreateTextMessageRequest addAttachmentsItem(DmMediaAttachment attachmentsItem) { + if (this.attachments == null) { + this.attachments = new ArrayList<>(); + } + this.attachments.add(attachmentsItem); + return this; + } + + /** + * Attachments to a DM Event. + * @return attachments + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Attachments to a DM Event.") + + public List getAttachments() { + return attachments; + } + + + public void setAttachments(List attachments) { + this.attachments = attachments; + } + + + public CreateTextMessageRequest text(String text) { + + this.text = text; + return this; + } + + /** + * Text of the message. + * @return text + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "Text of the message.") + + public String getText() { + return text; + } + + + public void setText(String text) { + this.text = text; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateTextMessageRequest createTextMessageRequest = (CreateTextMessageRequest) o; + return Objects.equals(this.attachments, createTextMessageRequest.attachments) && + Objects.equals(this.text, createTextMessageRequest.text); + } + + @Override + public int hashCode() { + return Objects.hash(attachments, text); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateTextMessageRequest {\n"); + sb.append(" attachments: ").append(toIndentedString(attachments)).append("\n"); + sb.append(" text: ").append(toIndentedString(text)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("attachments"); + openapiFields.add("text"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("text"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreateTextMessageRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // if (jsonObj == null) { + // if (CreateTextMessageRequest.openapiRequiredFields.isEmpty()) { + // return; + // } else { // has required fields + // throw new IllegalArgumentException(String.format("The required field(s) %s in CreateTextMessageRequest is not found in the empty JSON string", CreateTextMessageRequest.openapiRequiredFields.toString())); + // } + // } + + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateTextMessageRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + JsonArray jsonArrayattachments = jsonObj.getAsJsonArray("attachments"); + if (jsonArrayattachments != null) { + // ensure the json data is an array + if (!jsonObj.get("attachments").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `attachments` to be an array in the JSON string but got `%s`", jsonObj.get("attachments").toString())); + } + + // validate the optional field `attachments` (array) + for (int i = 0; i < jsonArrayattachments.size(); i++) { + DmMediaAttachment.validateJsonObject(jsonArrayattachments.get(i).getAsJsonObject()); + }; + } + if (jsonObj.get("text") != null && !jsonObj.get("text").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `text` to be a primitive type in the JSON string but got `%s`", jsonObj.get("text").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateTextMessageRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateTextMessageRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateTextMessageRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateTextMessageRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateTextMessageRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateTextMessageRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateTextMessageRequest + * @throws IOException if the JSON string is invalid with respect to CreateTextMessageRequest + */ + public static CreateTextMessageRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateTextMessageRequest.class); + } + + /** + * Convert an instance of CreateTextMessageRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/twitter/clientlib/model/DmEvent.java b/src/main/java/com/twitter/clientlib/model/DmEvent.java new file mode 100644 index 0000000..55eaa75 --- /dev/null +++ b/src/main/java/com/twitter/clientlib/model/DmEvent.java @@ -0,0 +1,513 @@ +/* +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.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.twitter.clientlib.model.DmEventAttachments; +import com.twitter.clientlib.model.TweetEditComplianceObjectSchemaTweet; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.twitter.clientlib.JSON; + +/** + * DmEvent + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class DmEvent { + public static final String SERIALIZED_NAME_ATTACHMENTS = "attachments"; + @SerializedName(SERIALIZED_NAME_ATTACHMENTS) + private DmEventAttachments attachments; + + public static final String SERIALIZED_NAME_CREATED_AT = "created_at"; + @SerializedName(SERIALIZED_NAME_CREATED_AT) + private OffsetDateTime createdAt; + + public static final String SERIALIZED_NAME_DM_CONVERSATION_ID = "dm_conversation_id"; + @SerializedName(SERIALIZED_NAME_DM_CONVERSATION_ID) + private String dmConversationId; + + public static final String SERIALIZED_NAME_EVENT_TYPE = "event_type"; + @SerializedName(SERIALIZED_NAME_EVENT_TYPE) + private String eventType; + + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_PARTICIPANT_IDS = "participant_ids"; + @SerializedName(SERIALIZED_NAME_PARTICIPANT_IDS) + private List participantIds = null; + + public static final String SERIALIZED_NAME_REFERENCED_TWEETS = "referenced_tweets"; + @SerializedName(SERIALIZED_NAME_REFERENCED_TWEETS) + private List referencedTweets = null; + + public static final String SERIALIZED_NAME_SENDER_ID = "sender_id"; + @SerializedName(SERIALIZED_NAME_SENDER_ID) + private String senderId; + + public static final String SERIALIZED_NAME_TEXT = "text"; + @SerializedName(SERIALIZED_NAME_TEXT) + private String text; + + public DmEvent() { + } + + public DmEvent attachments(DmEventAttachments attachments) { + + this.attachments = attachments; + return this; + } + + /** + * Get attachments + * @return attachments + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public DmEventAttachments getAttachments() { + return attachments; + } + + + public void setAttachments(DmEventAttachments attachments) { + this.attachments = attachments; + } + + + public DmEvent createdAt(OffsetDateTime createdAt) { + + this.createdAt = createdAt; + return this; + } + + /** + * Get createdAt + * @return createdAt + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + + public void setCreatedAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + } + + + public DmEvent dmConversationId(String dmConversationId) { + + this.dmConversationId = dmConversationId; + return this; + } + + /** + * Unique identifier of a DM conversation. This can either be a numeric string, or a pair of numeric strings separated by a '-' character in the case of one-on-one DM Conversations. + * @return dmConversationId + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "123123123-456456456", value = "Unique identifier of a DM conversation. This can either be a numeric string, or a pair of numeric strings separated by a '-' character in the case of one-on-one DM Conversations.") + + public String getDmConversationId() { + return dmConversationId; + } + + + public void setDmConversationId(String dmConversationId) { + this.dmConversationId = dmConversationId; + } + + + public DmEvent eventType(String eventType) { + + this.eventType = eventType; + return this; + } + + /** + * Get eventType + * @return eventType + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "MessageCreate", required = true, value = "") + + public String getEventType() { + return eventType; + } + + + public void setEventType(String eventType) { + this.eventType = eventType; + } + + + public DmEvent id(String id) { + + this.id = id; + return this; + } + + /** + * Unique identifier of a DM Event. + * @return id + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "1146654567674912769", required = true, value = "Unique identifier of a DM Event.") + + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + public DmEvent participantIds(List participantIds) { + + this.participantIds = participantIds; + return this; + } + + public DmEvent addParticipantIdsItem(String participantIdsItem) { + if (this.participantIds == null) { + this.participantIds = new ArrayList<>(); + } + this.participantIds.add(participantIdsItem); + return this; + } + + /** + * A list of participants for a ParticipantsJoin or ParticipantsLeave event_type. + * @return participantIds + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "A list of participants for a ParticipantsJoin or ParticipantsLeave event_type.") + + public List getParticipantIds() { + return participantIds; + } + + + public void setParticipantIds(List participantIds) { + this.participantIds = participantIds; + } + + + public DmEvent referencedTweets(List referencedTweets) { + + this.referencedTweets = referencedTweets; + return this; + } + + public DmEvent addReferencedTweetsItem(TweetEditComplianceObjectSchemaTweet referencedTweetsItem) { + if (this.referencedTweets == null) { + this.referencedTweets = new ArrayList<>(); + } + this.referencedTweets.add(referencedTweetsItem); + return this; + } + + /** + * A list of Tweets this DM refers to. + * @return referencedTweets + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "A list of Tweets this DM refers to.") + + public List getReferencedTweets() { + return referencedTweets; + } + + + public void setReferencedTweets(List referencedTweets) { + this.referencedTweets = referencedTweets; + } + + + public DmEvent senderId(String senderId) { + + this.senderId = senderId; + return this; + } + + /** + * Unique identifier of this User. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers. + * @return senderId + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "2244994945", value = "Unique identifier of this User. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers.") + + public String getSenderId() { + return senderId; + } + + + public void setSenderId(String senderId) { + this.senderId = senderId; + } + + + public DmEvent text(String text) { + + this.text = text; + return this; + } + + /** + * Get text + * @return text + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getText() { + return text; + } + + + public void setText(String text) { + this.text = text; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DmEvent dmEvent = (DmEvent) o; + return Objects.equals(this.attachments, dmEvent.attachments) && + Objects.equals(this.createdAt, dmEvent.createdAt) && + Objects.equals(this.dmConversationId, dmEvent.dmConversationId) && + Objects.equals(this.eventType, dmEvent.eventType) && + Objects.equals(this.id, dmEvent.id) && + Objects.equals(this.participantIds, dmEvent.participantIds) && + Objects.equals(this.referencedTweets, dmEvent.referencedTweets) && + Objects.equals(this.senderId, dmEvent.senderId) && + Objects.equals(this.text, dmEvent.text); + } + + @Override + public int hashCode() { + return Objects.hash(attachments, createdAt, dmConversationId, eventType, id, participantIds, referencedTweets, senderId, text); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DmEvent {\n"); + sb.append(" attachments: ").append(toIndentedString(attachments)).append("\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" dmConversationId: ").append(toIndentedString(dmConversationId)).append("\n"); + sb.append(" eventType: ").append(toIndentedString(eventType)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" participantIds: ").append(toIndentedString(participantIds)).append("\n"); + sb.append(" referencedTweets: ").append(toIndentedString(referencedTweets)).append("\n"); + sb.append(" senderId: ").append(toIndentedString(senderId)).append("\n"); + sb.append(" text: ").append(toIndentedString(text)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("attachments"); + openapiFields.add("created_at"); + openapiFields.add("dm_conversation_id"); + openapiFields.add("event_type"); + openapiFields.add("id"); + openapiFields.add("participant_ids"); + openapiFields.add("referenced_tweets"); + openapiFields.add("sender_id"); + openapiFields.add("text"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("event_type"); + openapiRequiredFields.add("id"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to DmEvent + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // if (jsonObj == null) { + // if (DmEvent.openapiRequiredFields.isEmpty()) { + // return; + // } else { // has required fields + // throw new IllegalArgumentException(String.format("The required field(s) %s in DmEvent is not found in the empty JSON string", DmEvent.openapiRequiredFields.toString())); + // } + // } + + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : DmEvent.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the optional field `attachments` + if (jsonObj.getAsJsonObject("attachments") != null) { + DmEventAttachments.validateJsonObject(jsonObj.getAsJsonObject("attachments")); + } + if (jsonObj.get("dm_conversation_id") != null && !jsonObj.get("dm_conversation_id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `dm_conversation_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("dm_conversation_id").toString())); + } + if (jsonObj.get("event_type") != null && !jsonObj.get("event_type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `event_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event_type").toString())); + } + if (jsonObj.get("id") != null && !jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + // ensure the json data is an array + if (jsonObj.get("participant_ids") != null && !jsonObj.get("participant_ids").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `participant_ids` to be an array in the JSON string but got `%s`", jsonObj.get("participant_ids").toString())); + } + JsonArray jsonArrayreferencedTweets = jsonObj.getAsJsonArray("referenced_tweets"); + if (jsonArrayreferencedTweets != null) { + // ensure the json data is an array + if (!jsonObj.get("referenced_tweets").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `referenced_tweets` to be an array in the JSON string but got `%s`", jsonObj.get("referenced_tweets").toString())); + } + + // validate the optional field `referenced_tweets` (array) + for (int i = 0; i < jsonArrayreferencedTweets.size(); i++) { + TweetEditComplianceObjectSchemaTweet.validateJsonObject(jsonArrayreferencedTweets.get(i).getAsJsonObject()); + }; + } + if (jsonObj.get("sender_id") != null && !jsonObj.get("sender_id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `sender_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sender_id").toString())); + } + if (jsonObj.get("text") != null && !jsonObj.get("text").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `text` to be a primitive type in the JSON string but got `%s`", jsonObj.get("text").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!DmEvent.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'DmEvent' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(DmEvent.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, DmEvent value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public DmEvent read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of DmEvent given an JSON string + * + * @param jsonString JSON string + * @return An instance of DmEvent + * @throws IOException if the JSON string is invalid with respect to DmEvent + */ + public static DmEvent fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, DmEvent.class); + } + + /** + * Convert an instance of DmEvent to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/twitter/clientlib/model/DmEventAttachments.java b/src/main/java/com/twitter/clientlib/model/DmEventAttachments.java new file mode 100644 index 0000000..5dc6200 --- /dev/null +++ b/src/main/java/com/twitter/clientlib/model/DmEventAttachments.java @@ -0,0 +1,265 @@ +/* +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.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.twitter.clientlib.JSON; + +/** + * Specifies the type of attachments (if any) present in this DM. + */ +@ApiModel(description = "Specifies the type of attachments (if any) present in this DM.") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class DmEventAttachments { + public static final String SERIALIZED_NAME_CARD_IDS = "card_ids"; + @SerializedName(SERIALIZED_NAME_CARD_IDS) + private List cardIds = null; + + public static final String SERIALIZED_NAME_MEDIA_KEYS = "media_keys"; + @SerializedName(SERIALIZED_NAME_MEDIA_KEYS) + private List mediaKeys = null; + + public DmEventAttachments() { + } + + public DmEventAttachments cardIds(List cardIds) { + + this.cardIds = cardIds; + return this; + } + + public DmEventAttachments addCardIdsItem(String cardIdsItem) { + if (this.cardIds == null) { + this.cardIds = new ArrayList<>(); + } + this.cardIds.add(cardIdsItem); + return this; + } + + /** + * A list of card IDs (if cards are attached). + * @return cardIds + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "A list of card IDs (if cards are attached).") + + public List getCardIds() { + return cardIds; + } + + + public void setCardIds(List cardIds) { + this.cardIds = cardIds; + } + + + public DmEventAttachments mediaKeys(List mediaKeys) { + + this.mediaKeys = mediaKeys; + return this; + } + + public DmEventAttachments addMediaKeysItem(String mediaKeysItem) { + if (this.mediaKeys == null) { + this.mediaKeys = new ArrayList<>(); + } + this.mediaKeys.add(mediaKeysItem); + return this; + } + + /** + * A list of Media Keys for each one of the media attachments (if media are attached). + * @return mediaKeys + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "A list of Media Keys for each one of the media attachments (if media are attached).") + + public List getMediaKeys() { + return mediaKeys; + } + + + public void setMediaKeys(List mediaKeys) { + this.mediaKeys = mediaKeys; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DmEventAttachments dmEventAttachments = (DmEventAttachments) o; + return Objects.equals(this.cardIds, dmEventAttachments.cardIds) && + Objects.equals(this.mediaKeys, dmEventAttachments.mediaKeys); + } + + @Override + public int hashCode() { + return Objects.hash(cardIds, mediaKeys); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DmEventAttachments {\n"); + sb.append(" cardIds: ").append(toIndentedString(cardIds)).append("\n"); + sb.append(" mediaKeys: ").append(toIndentedString(mediaKeys)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("card_ids"); + openapiFields.add("media_keys"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to DmEventAttachments + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // if (jsonObj == null) { + // if (DmEventAttachments.openapiRequiredFields.isEmpty()) { + // return; + // } else { // has required fields + // throw new IllegalArgumentException(String.format("The required field(s) %s in DmEventAttachments is not found in the empty JSON string", DmEventAttachments.openapiRequiredFields.toString())); + // } + // } + + // ensure the json data is an array + if (jsonObj.get("card_ids") != null && !jsonObj.get("card_ids").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `card_ids` to be an array in the JSON string but got `%s`", jsonObj.get("card_ids").toString())); + } + // ensure the json data is an array + if (jsonObj.get("media_keys") != null && !jsonObj.get("media_keys").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `media_keys` to be an array in the JSON string but got `%s`", jsonObj.get("media_keys").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!DmEventAttachments.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'DmEventAttachments' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(DmEventAttachments.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, DmEventAttachments value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public DmEventAttachments read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of DmEventAttachments given an JSON string + * + * @param jsonString JSON string + * @return An instance of DmEventAttachments + * @throws IOException if the JSON string is invalid with respect to DmEventAttachments + */ + public static DmEventAttachments fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, DmEventAttachments.class); + } + + /** + * Convert an instance of DmEventAttachments to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/twitter/clientlib/model/ReportUsersResponseData.java b/src/main/java/com/twitter/clientlib/model/DmMediaAttachment.java similarity index 61% rename from src/main/java/com/twitter/clientlib/model/ReportUsersResponseData.java rename to src/main/java/com/twitter/clientlib/model/DmMediaAttachment.java index e36cd5d..2cb6361 100644 --- a/src/main/java/com/twitter/clientlib/model/ReportUsersResponseData.java +++ b/src/main/java/com/twitter/clientlib/model/DmMediaAttachment.java @@ -54,37 +54,37 @@ import com.twitter.clientlib.JSON; /** - * ReportUsersResponseData + * DmMediaAttachment */ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") -public class ReportUsersResponseData { - public static final String SERIALIZED_NAME_ID = "id"; - @SerializedName(SERIALIZED_NAME_ID) - private Integer id; +public class DmMediaAttachment { + public static final String SERIALIZED_NAME_MEDIA_ID = "media_id"; + @SerializedName(SERIALIZED_NAME_MEDIA_ID) + private String mediaId; - public ReportUsersResponseData() { + public DmMediaAttachment() { } - public ReportUsersResponseData id(Integer id) { + public DmMediaAttachment mediaId(String mediaId) { - this.id = id; + this.mediaId = mediaId; return this; } /** - * Get id - * @return id + * The unique identifier of this Media. + * @return mediaId **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @javax.annotation.Nonnull + @ApiModelProperty(example = "1146654567674912769", required = true, value = "The unique identifier of this Media.") - public Integer getId() { - return id; + public String getMediaId() { + return mediaId; } - public void setId(Integer id) { - this.id = id; + public void setMediaId(String mediaId) { + this.mediaId = mediaId; } @@ -97,20 +97,20 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - ReportUsersResponseData reportUsersResponseData = (ReportUsersResponseData) o; - return Objects.equals(this.id, reportUsersResponseData.id); + DmMediaAttachment dmMediaAttachment = (DmMediaAttachment) o; + return Objects.equals(this.mediaId, dmMediaAttachment.mediaId); } @Override public int hashCode() { - return Objects.hash(id); + return Objects.hash(mediaId); } @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class ReportUsersResponseData {\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append("class DmMediaAttachment {\n"); + sb.append(" mediaId: ").append(toIndentedString(mediaId)).append("\n"); sb.append("}"); return sb.toString(); } @@ -133,49 +133,60 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) openapiFields = new HashSet(); - openapiFields.add("id"); + openapiFields.add("media_id"); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("media_id"); } /** * Validates the JSON Object and throws an exception if issues found * * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to ReportUsersResponseData + * @throws IOException if the JSON Object is invalid with respect to DmMediaAttachment */ public static void validateJsonObject(JsonObject jsonObj) throws IOException { // if (jsonObj == null) { - // if (ReportUsersResponseData.openapiRequiredFields.isEmpty()) { + // if (DmMediaAttachment.openapiRequiredFields.isEmpty()) { // return; // } else { // has required fields - // throw new IllegalArgumentException(String.format("The required field(s) %s in ReportUsersResponseData is not found in the empty JSON string", ReportUsersResponseData.openapiRequiredFields.toString())); + // throw new IllegalArgumentException(String.format("The required field(s) %s in DmMediaAttachment is not found in the empty JSON string", DmMediaAttachment.openapiRequiredFields.toString())); // } // } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : DmMediaAttachment.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (jsonObj.get("media_id") != null && !jsonObj.get("media_id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `media_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("media_id").toString())); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!ReportUsersResponseData.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'ReportUsersResponseData' and its subtypes + if (!DmMediaAttachment.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'DmMediaAttachment' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(ReportUsersResponseData.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(DmMediaAttachment.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, ReportUsersResponseData value) throws IOException { + public void write(JsonWriter out, DmMediaAttachment value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); elementAdapter.write(out, obj); } @Override - public ReportUsersResponseData read(JsonReader in) throws IOException { + public DmMediaAttachment read(JsonReader in) throws IOException { JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); validateJsonObject(jsonObj); return thisAdapter.fromJsonTree(jsonObj); @@ -186,18 +197,18 @@ public ReportUsersResponseData read(JsonReader in) throws IOException { } /** - * Create an instance of ReportUsersResponseData given an JSON string + * Create an instance of DmMediaAttachment given an JSON string * * @param jsonString JSON string - * @return An instance of ReportUsersResponseData - * @throws IOException if the JSON string is invalid with respect to ReportUsersResponseData + * @return An instance of DmMediaAttachment + * @throws IOException if the JSON string is invalid with respect to DmMediaAttachment */ - public static ReportUsersResponseData fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, ReportUsersResponseData.class); + public static DmMediaAttachment fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, DmMediaAttachment.class); } /** - * Convert an instance of ReportUsersResponseData to an JSON string + * Convert an instance of DmMediaAttachment to an JSON string * * @return JSON string */ diff --git a/src/main/java/com/twitter/clientlib/model/Get2DmConversationsIdDmEventsResponse.java b/src/main/java/com/twitter/clientlib/model/Get2DmConversationsIdDmEventsResponse.java new file mode 100644 index 0000000..9e3440e --- /dev/null +++ b/src/main/java/com/twitter/clientlib/model/Get2DmConversationsIdDmEventsResponse.java @@ -0,0 +1,352 @@ +/* +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.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.twitter.clientlib.model.DmEvent; +import com.twitter.clientlib.model.Expansions; +import com.twitter.clientlib.model.Get2ListsIdFollowersResponseMeta; +import com.twitter.clientlib.model.Problem; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.twitter.clientlib.JSON; + +/** + * Get2DmConversationsIdDmEventsResponse + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class Get2DmConversationsIdDmEventsResponse { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private List data = null; + + public static final String SERIALIZED_NAME_ERRORS = "errors"; + @SerializedName(SERIALIZED_NAME_ERRORS) + private List errors = null; + + public static final String SERIALIZED_NAME_INCLUDES = "includes"; + @SerializedName(SERIALIZED_NAME_INCLUDES) + private Expansions includes; + + public static final String SERIALIZED_NAME_META = "meta"; + @SerializedName(SERIALIZED_NAME_META) + private Get2ListsIdFollowersResponseMeta meta; + + public Get2DmConversationsIdDmEventsResponse() { + } + + public Get2DmConversationsIdDmEventsResponse data(List data) { + + this.data = data; + return this; + } + + public Get2DmConversationsIdDmEventsResponse addDataItem(DmEvent dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List getData() { + return data; + } + + + public void setData(List data) { + this.data = data; + } + + + public Get2DmConversationsIdDmEventsResponse errors(List errors) { + + this.errors = errors; + return this; + } + + public Get2DmConversationsIdDmEventsResponse addErrorsItem(Problem errorsItem) { + if (this.errors == null) { + this.errors = new ArrayList<>(); + } + this.errors.add(errorsItem); + return this; + } + + /** + * Get errors + * @return errors + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List getErrors() { + return errors; + } + + + public void setErrors(List errors) { + this.errors = errors; + } + + + public Get2DmConversationsIdDmEventsResponse includes(Expansions includes) { + + this.includes = includes; + return this; + } + + /** + * Get includes + * @return includes + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public Expansions getIncludes() { + return includes; + } + + + public void setIncludes(Expansions includes) { + this.includes = includes; + } + + + public Get2DmConversationsIdDmEventsResponse meta(Get2ListsIdFollowersResponseMeta meta) { + + this.meta = meta; + return this; + } + + /** + * Get meta + * @return meta + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public Get2ListsIdFollowersResponseMeta getMeta() { + return meta; + } + + + public void setMeta(Get2ListsIdFollowersResponseMeta meta) { + this.meta = meta; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Get2DmConversationsIdDmEventsResponse get2DmConversationsIdDmEventsResponse = (Get2DmConversationsIdDmEventsResponse) o; + return Objects.equals(this.data, get2DmConversationsIdDmEventsResponse.data) && + Objects.equals(this.errors, get2DmConversationsIdDmEventsResponse.errors) && + Objects.equals(this.includes, get2DmConversationsIdDmEventsResponse.includes) && + Objects.equals(this.meta, get2DmConversationsIdDmEventsResponse.meta); + } + + @Override + public int hashCode() { + return Objects.hash(data, errors, includes, meta); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Get2DmConversationsIdDmEventsResponse {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); + sb.append(" includes: ").append(toIndentedString(includes)).append("\n"); + sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("errors"); + openapiFields.add("includes"); + openapiFields.add("meta"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Get2DmConversationsIdDmEventsResponse + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // if (jsonObj == null) { + // if (Get2DmConversationsIdDmEventsResponse.openapiRequiredFields.isEmpty()) { + // return; + // } else { // has required fields + // throw new IllegalArgumentException(String.format("The required field(s) %s in Get2DmConversationsIdDmEventsResponse is not found in the empty JSON string", Get2DmConversationsIdDmEventsResponse.openapiRequiredFields.toString())); + // } + // } + + JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); + if (jsonArraydata != null) { + // ensure the json data is an array + if (!jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + + // validate the optional field `data` (array) + for (int i = 0; i < jsonArraydata.size(); i++) { + DmEvent.validateJsonObject(jsonArraydata.get(i).getAsJsonObject()); + }; + } + JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); + if (jsonArrayerrors != null) { + // ensure the json data is an array + if (!jsonObj.get("errors").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + } + + // validate the optional field `errors` (array) + for (int i = 0; i < jsonArrayerrors.size(); i++) { + Problem.validateJsonObject(jsonArrayerrors.get(i).getAsJsonObject()); + }; + } + // validate the optional field `includes` + if (jsonObj.getAsJsonObject("includes") != null) { + Expansions.validateJsonObject(jsonObj.getAsJsonObject("includes")); + } + // validate the optional field `meta` + if (jsonObj.getAsJsonObject("meta") != null) { + Get2ListsIdFollowersResponseMeta.validateJsonObject(jsonObj.getAsJsonObject("meta")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Get2DmConversationsIdDmEventsResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Get2DmConversationsIdDmEventsResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Get2DmConversationsIdDmEventsResponse.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Get2DmConversationsIdDmEventsResponse value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public Get2DmConversationsIdDmEventsResponse read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Get2DmConversationsIdDmEventsResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of Get2DmConversationsIdDmEventsResponse + * @throws IOException if the JSON string is invalid with respect to Get2DmConversationsIdDmEventsResponse + */ + public static Get2DmConversationsIdDmEventsResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Get2DmConversationsIdDmEventsResponse.class); + } + + /** + * Convert an instance of Get2DmConversationsIdDmEventsResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/twitter/clientlib/model/Get2DmConversationsWithParticipantIdDmEventsResponse.java b/src/main/java/com/twitter/clientlib/model/Get2DmConversationsWithParticipantIdDmEventsResponse.java new file mode 100644 index 0000000..7e1cd9c --- /dev/null +++ b/src/main/java/com/twitter/clientlib/model/Get2DmConversationsWithParticipantIdDmEventsResponse.java @@ -0,0 +1,352 @@ +/* +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.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.twitter.clientlib.model.DmEvent; +import com.twitter.clientlib.model.Expansions; +import com.twitter.clientlib.model.Get2ListsIdFollowersResponseMeta; +import com.twitter.clientlib.model.Problem; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.twitter.clientlib.JSON; + +/** + * Get2DmConversationsWithParticipantIdDmEventsResponse + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class Get2DmConversationsWithParticipantIdDmEventsResponse { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private List data = null; + + public static final String SERIALIZED_NAME_ERRORS = "errors"; + @SerializedName(SERIALIZED_NAME_ERRORS) + private List errors = null; + + public static final String SERIALIZED_NAME_INCLUDES = "includes"; + @SerializedName(SERIALIZED_NAME_INCLUDES) + private Expansions includes; + + public static final String SERIALIZED_NAME_META = "meta"; + @SerializedName(SERIALIZED_NAME_META) + private Get2ListsIdFollowersResponseMeta meta; + + public Get2DmConversationsWithParticipantIdDmEventsResponse() { + } + + public Get2DmConversationsWithParticipantIdDmEventsResponse data(List data) { + + this.data = data; + return this; + } + + public Get2DmConversationsWithParticipantIdDmEventsResponse addDataItem(DmEvent dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List getData() { + return data; + } + + + public void setData(List data) { + this.data = data; + } + + + public Get2DmConversationsWithParticipantIdDmEventsResponse errors(List errors) { + + this.errors = errors; + return this; + } + + public Get2DmConversationsWithParticipantIdDmEventsResponse addErrorsItem(Problem errorsItem) { + if (this.errors == null) { + this.errors = new ArrayList<>(); + } + this.errors.add(errorsItem); + return this; + } + + /** + * Get errors + * @return errors + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List getErrors() { + return errors; + } + + + public void setErrors(List errors) { + this.errors = errors; + } + + + public Get2DmConversationsWithParticipantIdDmEventsResponse includes(Expansions includes) { + + this.includes = includes; + return this; + } + + /** + * Get includes + * @return includes + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public Expansions getIncludes() { + return includes; + } + + + public void setIncludes(Expansions includes) { + this.includes = includes; + } + + + public Get2DmConversationsWithParticipantIdDmEventsResponse meta(Get2ListsIdFollowersResponseMeta meta) { + + this.meta = meta; + return this; + } + + /** + * Get meta + * @return meta + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public Get2ListsIdFollowersResponseMeta getMeta() { + return meta; + } + + + public void setMeta(Get2ListsIdFollowersResponseMeta meta) { + this.meta = meta; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Get2DmConversationsWithParticipantIdDmEventsResponse get2DmConversationsWithParticipantIdDmEventsResponse = (Get2DmConversationsWithParticipantIdDmEventsResponse) o; + return Objects.equals(this.data, get2DmConversationsWithParticipantIdDmEventsResponse.data) && + Objects.equals(this.errors, get2DmConversationsWithParticipantIdDmEventsResponse.errors) && + Objects.equals(this.includes, get2DmConversationsWithParticipantIdDmEventsResponse.includes) && + Objects.equals(this.meta, get2DmConversationsWithParticipantIdDmEventsResponse.meta); + } + + @Override + public int hashCode() { + return Objects.hash(data, errors, includes, meta); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Get2DmConversationsWithParticipantIdDmEventsResponse {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); + sb.append(" includes: ").append(toIndentedString(includes)).append("\n"); + sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("errors"); + openapiFields.add("includes"); + openapiFields.add("meta"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Get2DmConversationsWithParticipantIdDmEventsResponse + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // if (jsonObj == null) { + // if (Get2DmConversationsWithParticipantIdDmEventsResponse.openapiRequiredFields.isEmpty()) { + // return; + // } else { // has required fields + // throw new IllegalArgumentException(String.format("The required field(s) %s in Get2DmConversationsWithParticipantIdDmEventsResponse is not found in the empty JSON string", Get2DmConversationsWithParticipantIdDmEventsResponse.openapiRequiredFields.toString())); + // } + // } + + JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); + if (jsonArraydata != null) { + // ensure the json data is an array + if (!jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + + // validate the optional field `data` (array) + for (int i = 0; i < jsonArraydata.size(); i++) { + DmEvent.validateJsonObject(jsonArraydata.get(i).getAsJsonObject()); + }; + } + JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); + if (jsonArrayerrors != null) { + // ensure the json data is an array + if (!jsonObj.get("errors").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + } + + // validate the optional field `errors` (array) + for (int i = 0; i < jsonArrayerrors.size(); i++) { + Problem.validateJsonObject(jsonArrayerrors.get(i).getAsJsonObject()); + }; + } + // validate the optional field `includes` + if (jsonObj.getAsJsonObject("includes") != null) { + Expansions.validateJsonObject(jsonObj.getAsJsonObject("includes")); + } + // validate the optional field `meta` + if (jsonObj.getAsJsonObject("meta") != null) { + Get2ListsIdFollowersResponseMeta.validateJsonObject(jsonObj.getAsJsonObject("meta")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Get2DmConversationsWithParticipantIdDmEventsResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Get2DmConversationsWithParticipantIdDmEventsResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Get2DmConversationsWithParticipantIdDmEventsResponse.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Get2DmConversationsWithParticipantIdDmEventsResponse value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public Get2DmConversationsWithParticipantIdDmEventsResponse read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Get2DmConversationsWithParticipantIdDmEventsResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of Get2DmConversationsWithParticipantIdDmEventsResponse + * @throws IOException if the JSON string is invalid with respect to Get2DmConversationsWithParticipantIdDmEventsResponse + */ + public static Get2DmConversationsWithParticipantIdDmEventsResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Get2DmConversationsWithParticipantIdDmEventsResponse.class); + } + + /** + * Convert an instance of Get2DmConversationsWithParticipantIdDmEventsResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/twitter/clientlib/model/Get2DmEventsResponse.java b/src/main/java/com/twitter/clientlib/model/Get2DmEventsResponse.java new file mode 100644 index 0000000..b7cee72 --- /dev/null +++ b/src/main/java/com/twitter/clientlib/model/Get2DmEventsResponse.java @@ -0,0 +1,352 @@ +/* +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.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.twitter.clientlib.model.DmEvent; +import com.twitter.clientlib.model.Expansions; +import com.twitter.clientlib.model.Get2ListsIdFollowersResponseMeta; +import com.twitter.clientlib.model.Problem; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.twitter.clientlib.JSON; + +/** + * Get2DmEventsResponse + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class Get2DmEventsResponse { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private List data = null; + + public static final String SERIALIZED_NAME_ERRORS = "errors"; + @SerializedName(SERIALIZED_NAME_ERRORS) + private List errors = null; + + public static final String SERIALIZED_NAME_INCLUDES = "includes"; + @SerializedName(SERIALIZED_NAME_INCLUDES) + private Expansions includes; + + public static final String SERIALIZED_NAME_META = "meta"; + @SerializedName(SERIALIZED_NAME_META) + private Get2ListsIdFollowersResponseMeta meta; + + public Get2DmEventsResponse() { + } + + public Get2DmEventsResponse data(List data) { + + this.data = data; + return this; + } + + public Get2DmEventsResponse addDataItem(DmEvent dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List getData() { + return data; + } + + + public void setData(List data) { + this.data = data; + } + + + public Get2DmEventsResponse errors(List errors) { + + this.errors = errors; + return this; + } + + public Get2DmEventsResponse addErrorsItem(Problem errorsItem) { + if (this.errors == null) { + this.errors = new ArrayList<>(); + } + this.errors.add(errorsItem); + return this; + } + + /** + * Get errors + * @return errors + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List getErrors() { + return errors; + } + + + public void setErrors(List errors) { + this.errors = errors; + } + + + public Get2DmEventsResponse includes(Expansions includes) { + + this.includes = includes; + return this; + } + + /** + * Get includes + * @return includes + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public Expansions getIncludes() { + return includes; + } + + + public void setIncludes(Expansions includes) { + this.includes = includes; + } + + + public Get2DmEventsResponse meta(Get2ListsIdFollowersResponseMeta meta) { + + this.meta = meta; + return this; + } + + /** + * Get meta + * @return meta + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public Get2ListsIdFollowersResponseMeta getMeta() { + return meta; + } + + + public void setMeta(Get2ListsIdFollowersResponseMeta meta) { + this.meta = meta; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Get2DmEventsResponse get2DmEventsResponse = (Get2DmEventsResponse) o; + return Objects.equals(this.data, get2DmEventsResponse.data) && + Objects.equals(this.errors, get2DmEventsResponse.errors) && + Objects.equals(this.includes, get2DmEventsResponse.includes) && + Objects.equals(this.meta, get2DmEventsResponse.meta); + } + + @Override + public int hashCode() { + return Objects.hash(data, errors, includes, meta); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Get2DmEventsResponse {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); + sb.append(" includes: ").append(toIndentedString(includes)).append("\n"); + sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("errors"); + openapiFields.add("includes"); + openapiFields.add("meta"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Get2DmEventsResponse + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // if (jsonObj == null) { + // if (Get2DmEventsResponse.openapiRequiredFields.isEmpty()) { + // return; + // } else { // has required fields + // throw new IllegalArgumentException(String.format("The required field(s) %s in Get2DmEventsResponse is not found in the empty JSON string", Get2DmEventsResponse.openapiRequiredFields.toString())); + // } + // } + + JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); + if (jsonArraydata != null) { + // ensure the json data is an array + if (!jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + + // validate the optional field `data` (array) + for (int i = 0; i < jsonArraydata.size(); i++) { + DmEvent.validateJsonObject(jsonArraydata.get(i).getAsJsonObject()); + }; + } + JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); + if (jsonArrayerrors != null) { + // ensure the json data is an array + if (!jsonObj.get("errors").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + } + + // validate the optional field `errors` (array) + for (int i = 0; i < jsonArrayerrors.size(); i++) { + Problem.validateJsonObject(jsonArrayerrors.get(i).getAsJsonObject()); + }; + } + // validate the optional field `includes` + if (jsonObj.getAsJsonObject("includes") != null) { + Expansions.validateJsonObject(jsonObj.getAsJsonObject("includes")); + } + // validate the optional field `meta` + if (jsonObj.getAsJsonObject("meta") != null) { + Get2ListsIdFollowersResponseMeta.validateJsonObject(jsonObj.getAsJsonObject("meta")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Get2DmEventsResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Get2DmEventsResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Get2DmEventsResponse.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Get2DmEventsResponse value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public Get2DmEventsResponse read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Get2DmEventsResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of Get2DmEventsResponse + * @throws IOException if the JSON string is invalid with respect to Get2DmEventsResponse + */ + public static Get2DmEventsResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Get2DmEventsResponse.class); + } + + /** + * Convert an instance of Get2DmEventsResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/twitter/clientlib/model/TweetCreateRequest.java b/src/main/java/com/twitter/clientlib/model/TweetCreateRequest.java index 2def511..6716b83 100644 --- a/src/main/java/com/twitter/clientlib/model/TweetCreateRequest.java +++ b/src/main/java/com/twitter/clientlib/model/TweetCreateRequest.java @@ -62,6 +62,10 @@ */ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class TweetCreateRequest { + public static final String SERIALIZED_NAME_CARD_URI = "card_uri"; + @SerializedName(SERIALIZED_NAME_CARD_URI) + private String cardUri; + public static final String SERIALIZED_NAME_DIRECT_MESSAGE_DEEP_LINK = "direct_message_deep_link"; @SerializedName(SERIALIZED_NAME_DIRECT_MESSAGE_DEEP_LINK) private String directMessageDeepLink; @@ -78,6 +82,10 @@ public class TweetCreateRequest { @SerializedName(SERIALIZED_NAME_MEDIA) private TweetCreateRequestMedia media; + public static final String SERIALIZED_NAME_NULLCAST = "nullcast"; + @SerializedName(SERIALIZED_NAME_NULLCAST) + private Boolean nullcast = false; + public static final String SERIALIZED_NAME_POLL = "poll"; @SerializedName(SERIALIZED_NAME_POLL) private TweetCreateRequestPoll poll; @@ -148,6 +156,29 @@ public ReplySettingsEnum read(final JsonReader jsonReader) throws IOException { public TweetCreateRequest() { } + public TweetCreateRequest cardUri(String cardUri) { + + this.cardUri = cardUri; + return this; + } + + /** + * Card Uri Parameter. This is mutually exclusive from Quote Tweet Id, Poll, Media, and Direct Message Deep Link. + * @return cardUri + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Card Uri Parameter. This is mutually exclusive from Quote Tweet Id, Poll, Media, and Direct Message Deep Link.") + + public String getCardUri() { + return cardUri; + } + + + public void setCardUri(String cardUri) { + this.cardUri = cardUri; + } + + public TweetCreateRequest directMessageDeepLink(String directMessageDeepLink) { this.directMessageDeepLink = directMessageDeepLink; @@ -240,6 +271,29 @@ public void setMedia(TweetCreateRequestMedia media) { } + public TweetCreateRequest nullcast(Boolean nullcast) { + + this.nullcast = nullcast; + return this; + } + + /** + * Nullcasted (promoted-only) Tweets do not appear in the public timeline and are not served to followers. + * @return nullcast + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Nullcasted (promoted-only) Tweets do not appear in the public timeline and are not served to followers.") + + public Boolean getNullcast() { + return nullcast; + } + + + public void setNullcast(Boolean nullcast) { + this.nullcast = nullcast; + } + + public TweetCreateRequest poll(TweetCreateRequestPoll poll) { this.poll = poll; @@ -365,10 +419,12 @@ public boolean equals(Object o) { return false; } TweetCreateRequest tweetCreateRequest = (TweetCreateRequest) o; - return Objects.equals(this.directMessageDeepLink, tweetCreateRequest.directMessageDeepLink) && + return Objects.equals(this.cardUri, tweetCreateRequest.cardUri) && + Objects.equals(this.directMessageDeepLink, tweetCreateRequest.directMessageDeepLink) && Objects.equals(this.forSuperFollowersOnly, tweetCreateRequest.forSuperFollowersOnly) && Objects.equals(this.geo, tweetCreateRequest.geo) && Objects.equals(this.media, tweetCreateRequest.media) && + Objects.equals(this.nullcast, tweetCreateRequest.nullcast) && Objects.equals(this.poll, tweetCreateRequest.poll) && Objects.equals(this.quoteTweetId, tweetCreateRequest.quoteTweetId) && Objects.equals(this.reply, tweetCreateRequest.reply) && @@ -378,17 +434,19 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(directMessageDeepLink, forSuperFollowersOnly, geo, media, poll, quoteTweetId, reply, replySettings, text); + return Objects.hash(cardUri, directMessageDeepLink, forSuperFollowersOnly, geo, media, nullcast, poll, quoteTweetId, reply, replySettings, text); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class TweetCreateRequest {\n"); + sb.append(" cardUri: ").append(toIndentedString(cardUri)).append("\n"); sb.append(" directMessageDeepLink: ").append(toIndentedString(directMessageDeepLink)).append("\n"); sb.append(" forSuperFollowersOnly: ").append(toIndentedString(forSuperFollowersOnly)).append("\n"); sb.append(" geo: ").append(toIndentedString(geo)).append("\n"); sb.append(" media: ").append(toIndentedString(media)).append("\n"); + sb.append(" nullcast: ").append(toIndentedString(nullcast)).append("\n"); sb.append(" poll: ").append(toIndentedString(poll)).append("\n"); sb.append(" quoteTweetId: ").append(toIndentedString(quoteTweetId)).append("\n"); sb.append(" reply: ").append(toIndentedString(reply)).append("\n"); @@ -416,10 +474,12 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) openapiFields = new HashSet(); + openapiFields.add("card_uri"); openapiFields.add("direct_message_deep_link"); openapiFields.add("for_super_followers_only"); openapiFields.add("geo"); openapiFields.add("media"); + openapiFields.add("nullcast"); openapiFields.add("poll"); openapiFields.add("quote_tweet_id"); openapiFields.add("reply"); @@ -445,6 +505,9 @@ public static void validateJsonObject(JsonObject jsonObj) throws IOException { // } // } + if (jsonObj.get("card_uri") != null && !jsonObj.get("card_uri").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `card_uri` to be a primitive type in the JSON string but got `%s`", jsonObj.get("card_uri").toString())); + } if (jsonObj.get("direct_message_deep_link") != null && !jsonObj.get("direct_message_deep_link").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `direct_message_deep_link` to be a primitive type in the JSON string but got `%s`", jsonObj.get("direct_message_deep_link").toString())); } diff --git a/src/main/java/com/twitter/clientlib/model/TweetCreateRequestMedia.java b/src/main/java/com/twitter/clientlib/model/TweetCreateRequestMedia.java index 14faccf..a0e47e7 100644 --- a/src/main/java/com/twitter/clientlib/model/TweetCreateRequestMedia.java +++ b/src/main/java/com/twitter/clientlib/model/TweetCreateRequestMedia.java @@ -56,9 +56,9 @@ import com.twitter.clientlib.JSON; /** - * Media information being attached to created Tweet. This is mutually exclusive from Quote Tweet Id and Poll. + * Media information being attached to created Tweet. This is mutually exclusive from Quote Tweet Id, Poll, and Card URI. */ -@ApiModel(description = "Media information being attached to created Tweet. This is mutually exclusive from Quote Tweet Id and Poll.") +@ApiModel(description = "Media information being attached to created Tweet. This is mutually exclusive from Quote Tweet Id, Poll, and Card URI.") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class TweetCreateRequestMedia { public static final String SERIALIZED_NAME_MEDIA_IDS = "media_ids"; diff --git a/src/main/java/com/twitter/clientlib/model/TweetCreateRequestPoll.java b/src/main/java/com/twitter/clientlib/model/TweetCreateRequestPoll.java index b573eb4..6d55173 100644 --- a/src/main/java/com/twitter/clientlib/model/TweetCreateRequestPoll.java +++ b/src/main/java/com/twitter/clientlib/model/TweetCreateRequestPoll.java @@ -56,9 +56,9 @@ import com.twitter.clientlib.JSON; /** - * Poll options for a Tweet with a poll. This is mutually exclusive from Media and Quote Tweet Id. + * Poll options for a Tweet with a poll. This is mutually exclusive from Media, Quote Tweet Id, and Card URI. */ -@ApiModel(description = "Poll options for a Tweet with a poll. This is mutually exclusive from Media and Quote Tweet Id.") +@ApiModel(description = "Poll options for a Tweet with a poll. This is mutually exclusive from Media, Quote Tweet Id, and Card URI.") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class TweetCreateRequestPoll { public static final String SERIALIZED_NAME_DURATION_MINUTES = "duration_minutes"; diff --git a/src/main/java/com/twitter/clientlib/model/TweetLabelData.java b/src/main/java/com/twitter/clientlib/model/TweetLabelData.java new file mode 100644 index 0000000..83876c6 --- /dev/null +++ b/src/main/java/com/twitter/clientlib/model/TweetLabelData.java @@ -0,0 +1,297 @@ +/* +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.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.twitter.clientlib.model.TweetNotice; +import com.twitter.clientlib.model.TweetNoticeSchema; +import com.twitter.clientlib.model.TweetUnviewable; +import com.twitter.clientlib.model.TweetUnviewableSchema; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; + +import javax.ws.rs.core.GenericType; + +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.JsonPrimitive; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; + +import com.twitter.clientlib.JSON; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class TweetLabelData extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(TweetLabelData.class.getName()); + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!TweetLabelData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'TweetLabelData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter adapterTweetNoticeSchema = gson.getDelegateAdapter(this, TypeToken.get(TweetNoticeSchema.class)); + final TypeAdapter adapterTweetUnviewableSchema = gson.getDelegateAdapter(this, TypeToken.get(TweetUnviewableSchema.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, TweetLabelData value) throws IOException { + if (value == null || value.getActualInstance() == null) { + elementAdapter.write(out, null); + return; + } + + // check if the actual instance is of the type `TweetNoticeSchema` + if (value.getActualInstance() instanceof TweetNoticeSchema) { + JsonObject obj = adapterTweetNoticeSchema.toJsonTree((TweetNoticeSchema)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + // check if the actual instance is of the type `TweetUnviewableSchema` + if (value.getActualInstance() instanceof TweetUnviewableSchema) { + JsonObject obj = adapterTweetUnviewableSchema.toJsonTree((TweetUnviewableSchema)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + throw new IOException("Failed to serialize as the type doesn't match oneOf schemas: TweetNoticeSchema, TweetUnviewableSchema"); + } + + @Override + public TweetLabelData read(JsonReader in) throws IOException { + Object deserialized = null; + JsonObject jsonObject = elementAdapter.read(in).getAsJsonObject(); + + int match = 0; + ArrayList errorMessages = new ArrayList<>(); + TypeAdapter actualAdapter = elementAdapter; + + // deserialize TweetNoticeSchema + try { + // validate the JSON object to see if any exception is thrown + TweetNoticeSchema.validateJsonObject(jsonObject); + actualAdapter = adapterTweetNoticeSchema; + match++; + log.log(Level.FINER, "Input data matches schema 'TweetNoticeSchema'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format("Deserialization for TweetNoticeSchema failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'TweetNoticeSchema'", e); + } + + // deserialize TweetUnviewableSchema + try { + // validate the JSON object to see if any exception is thrown + TweetUnviewableSchema.validateJsonObject(jsonObject); + actualAdapter = adapterTweetUnviewableSchema; + match++; + log.log(Level.FINER, "Input data matches schema 'TweetUnviewableSchema'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format("Deserialization for TweetUnviewableSchema failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'TweetUnviewableSchema'", e); + } + + if (match == 1) { + TweetLabelData ret = new TweetLabelData(); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonObject)); + return ret; + } + + throw new IOException(String.format("Failed deserialization for TweetLabelData: %d classes match result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", match, errorMessages, jsonObject.toString())); + } + }.nullSafe(); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public TweetLabelData() { + super("oneOf", Boolean.FALSE); + } + + public TweetLabelData(TweetNoticeSchema o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public TweetLabelData(TweetUnviewableSchema o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("TweetNoticeSchema", new GenericType() { + }); + schemas.put("TweetUnviewableSchema", new GenericType() { + }); + } + + @Override + public Map getSchemas() { + return TweetLabelData.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check + * the instance parameter is valid against the oneOf child schemas: + * TweetNoticeSchema, TweetUnviewableSchema + * + * It could be an instance of the 'oneOf' schemas. + * The oneOf child schemas may themselves be a composed schema (allOf, anyOf, oneOf). + */ + @Override + public void setActualInstance(Object instance) { + if (instance instanceof TweetNoticeSchema) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof TweetUnviewableSchema) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be TweetNoticeSchema, TweetUnviewableSchema"); + } + + /** + * Get the actual instance, which can be the following: + * TweetNoticeSchema, TweetUnviewableSchema + * + * @return The actual instance (TweetNoticeSchema, TweetUnviewableSchema) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `TweetNoticeSchema`. If the actual instance is not `TweetNoticeSchema`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `TweetNoticeSchema` + * @throws ClassCastException if the instance is not `TweetNoticeSchema` + */ + public TweetNoticeSchema getTweetNoticeSchema() throws ClassCastException { + return (TweetNoticeSchema)super.getActualInstance(); + } + + /** + * Get the actual instance of `TweetUnviewableSchema`. If the actual instance is not `TweetUnviewableSchema`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `TweetUnviewableSchema` + * @throws ClassCastException if the instance is not `TweetUnviewableSchema` + */ + public TweetUnviewableSchema getTweetUnviewableSchema() throws ClassCastException { + return (TweetUnviewableSchema)super.getActualInstance(); + } + + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to TweetLabelData + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // validate oneOf schemas one by one + int validCount = 0; + ArrayList errorMessages = new ArrayList<>(); + // validate the json string with TweetNoticeSchema + try { + TweetNoticeSchema.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format("Deserialization for TweetNoticeSchema failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with TweetUnviewableSchema + try { + TweetUnviewableSchema.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format("Deserialization for TweetUnviewableSchema failed with `%s`.", e.getMessage())); + // continue to the next one + } + if (validCount != 1) { + throw new IOException(String.format("The JSON string is invalid for TweetLabelData with oneOf schemas: TweetNoticeSchema, TweetUnviewableSchema. %d class(es) match the result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", validCount, errorMessages, jsonObj.toString())); + } + } + + /** + * Create an instance of TweetLabelData given an JSON string + * + * @param jsonString JSON string + * @return An instance of TweetLabelData + * @throws IOException if the JSON string is invalid with respect to TweetLabelData + */ + public static TweetLabelData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, TweetLabelData.class); + } + + /** + * Convert an instance of TweetLabelData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/twitter/clientlib/model/TweetLabelStreamResponse.java b/src/main/java/com/twitter/clientlib/model/TweetLabelStreamResponse.java new file mode 100644 index 0000000..3f748a8 --- /dev/null +++ b/src/main/java/com/twitter/clientlib/model/TweetLabelStreamResponse.java @@ -0,0 +1,299 @@ +/* +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.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.twitter.clientlib.model.Problem; +import com.twitter.clientlib.model.TweetComplianceStreamResponseOneOf1; +import com.twitter.clientlib.model.TweetLabelData; +import com.twitter.clientlib.model.TweetLabelStreamResponseOneOf; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import javax.ws.rs.core.GenericType; + +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.JsonPrimitive; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; + +import com.twitter.clientlib.JSON; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class TweetLabelStreamResponse extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(TweetLabelStreamResponse.class.getName()); + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!TweetLabelStreamResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'TweetLabelStreamResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter adapterTweetComplianceStreamResponseOneOf1 = gson.getDelegateAdapter(this, TypeToken.get(TweetComplianceStreamResponseOneOf1.class)); + final TypeAdapter adapterTweetLabelStreamResponseOneOf = gson.getDelegateAdapter(this, TypeToken.get(TweetLabelStreamResponseOneOf.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, TweetLabelStreamResponse value) throws IOException { + if (value == null || value.getActualInstance() == null) { + elementAdapter.write(out, null); + return; + } + + // check if the actual instance is of the type `TweetComplianceStreamResponseOneOf1` + if (value.getActualInstance() instanceof TweetComplianceStreamResponseOneOf1) { + JsonObject obj = adapterTweetComplianceStreamResponseOneOf1.toJsonTree((TweetComplianceStreamResponseOneOf1)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + // check if the actual instance is of the type `TweetLabelStreamResponseOneOf` + if (value.getActualInstance() instanceof TweetLabelStreamResponseOneOf) { + JsonObject obj = adapterTweetLabelStreamResponseOneOf.toJsonTree((TweetLabelStreamResponseOneOf)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + throw new IOException("Failed to serialize as the type doesn't match oneOf schemas: TweetComplianceStreamResponseOneOf1, TweetLabelStreamResponseOneOf"); + } + + @Override + public TweetLabelStreamResponse read(JsonReader in) throws IOException { + Object deserialized = null; + JsonObject jsonObject = elementAdapter.read(in).getAsJsonObject(); + + int match = 0; + ArrayList errorMessages = new ArrayList<>(); + TypeAdapter actualAdapter = elementAdapter; + + // deserialize TweetComplianceStreamResponseOneOf1 + try { + // validate the JSON object to see if any exception is thrown + TweetComplianceStreamResponseOneOf1.validateJsonObject(jsonObject); + actualAdapter = adapterTweetComplianceStreamResponseOneOf1; + match++; + log.log(Level.FINER, "Input data matches schema 'TweetComplianceStreamResponseOneOf1'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format("Deserialization for TweetComplianceStreamResponseOneOf1 failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'TweetComplianceStreamResponseOneOf1'", e); + } + + // deserialize TweetLabelStreamResponseOneOf + try { + // validate the JSON object to see if any exception is thrown + TweetLabelStreamResponseOneOf.validateJsonObject(jsonObject); + actualAdapter = adapterTweetLabelStreamResponseOneOf; + match++; + log.log(Level.FINER, "Input data matches schema 'TweetLabelStreamResponseOneOf'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format("Deserialization for TweetLabelStreamResponseOneOf failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'TweetLabelStreamResponseOneOf'", e); + } + + if (match == 1) { + TweetLabelStreamResponse ret = new TweetLabelStreamResponse(); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonObject)); + return ret; + } + + throw new IOException(String.format("Failed deserialization for TweetLabelStreamResponse: %d classes match result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", match, errorMessages, jsonObject.toString())); + } + }.nullSafe(); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public TweetLabelStreamResponse() { + super("oneOf", Boolean.FALSE); + } + + public TweetLabelStreamResponse(TweetComplianceStreamResponseOneOf1 o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public TweetLabelStreamResponse(TweetLabelStreamResponseOneOf o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("TweetComplianceStreamResponseOneOf1", new GenericType() { + }); + schemas.put("TweetLabelStreamResponseOneOf", new GenericType() { + }); + } + + @Override + public Map getSchemas() { + return TweetLabelStreamResponse.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check + * the instance parameter is valid against the oneOf child schemas: + * TweetComplianceStreamResponseOneOf1, TweetLabelStreamResponseOneOf + * + * It could be an instance of the 'oneOf' schemas. + * The oneOf child schemas may themselves be a composed schema (allOf, anyOf, oneOf). + */ + @Override + public void setActualInstance(Object instance) { + if (instance instanceof TweetComplianceStreamResponseOneOf1) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof TweetLabelStreamResponseOneOf) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be TweetComplianceStreamResponseOneOf1, TweetLabelStreamResponseOneOf"); + } + + /** + * Get the actual instance, which can be the following: + * TweetComplianceStreamResponseOneOf1, TweetLabelStreamResponseOneOf + * + * @return The actual instance (TweetComplianceStreamResponseOneOf1, TweetLabelStreamResponseOneOf) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `TweetComplianceStreamResponseOneOf1`. If the actual instance is not `TweetComplianceStreamResponseOneOf1`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `TweetComplianceStreamResponseOneOf1` + * @throws ClassCastException if the instance is not `TweetComplianceStreamResponseOneOf1` + */ + public TweetComplianceStreamResponseOneOf1 getTweetComplianceStreamResponseOneOf1() throws ClassCastException { + return (TweetComplianceStreamResponseOneOf1)super.getActualInstance(); + } + + /** + * Get the actual instance of `TweetLabelStreamResponseOneOf`. If the actual instance is not `TweetLabelStreamResponseOneOf`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `TweetLabelStreamResponseOneOf` + * @throws ClassCastException if the instance is not `TweetLabelStreamResponseOneOf` + */ + public TweetLabelStreamResponseOneOf getTweetLabelStreamResponseOneOf() throws ClassCastException { + return (TweetLabelStreamResponseOneOf)super.getActualInstance(); + } + + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to TweetLabelStreamResponse + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // validate oneOf schemas one by one + int validCount = 0; + ArrayList errorMessages = new ArrayList<>(); + // validate the json string with TweetComplianceStreamResponseOneOf1 + try { + TweetComplianceStreamResponseOneOf1.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format("Deserialization for TweetComplianceStreamResponseOneOf1 failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with TweetLabelStreamResponseOneOf + try { + TweetLabelStreamResponseOneOf.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format("Deserialization for TweetLabelStreamResponseOneOf failed with `%s`.", e.getMessage())); + // continue to the next one + } + if (validCount != 1) { + throw new IOException(String.format("The JSON string is invalid for TweetLabelStreamResponse with oneOf schemas: TweetComplianceStreamResponseOneOf1, TweetLabelStreamResponseOneOf. %d class(es) match the result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", validCount, errorMessages, jsonObj.toString())); + } + } + + /** + * Create an instance of TweetLabelStreamResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of TweetLabelStreamResponse + * @throws IOException if the JSON string is invalid with respect to TweetLabelStreamResponse + */ + public static TweetLabelStreamResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, TweetLabelStreamResponse.class); + } + + /** + * Convert an instance of TweetLabelStreamResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/twitter/clientlib/model/ReportUsersResponse.java b/src/main/java/com/twitter/clientlib/model/TweetLabelStreamResponseOneOf.java similarity index 65% rename from src/main/java/com/twitter/clientlib/model/ReportUsersResponse.java rename to src/main/java/com/twitter/clientlib/model/TweetLabelStreamResponseOneOf.java index 23fcce9..99ca26b 100644 --- a/src/main/java/com/twitter/clientlib/model/ReportUsersResponse.java +++ b/src/main/java/com/twitter/clientlib/model/TweetLabelStreamResponseOneOf.java @@ -29,7 +29,7 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.twitter.clientlib.model.ReportUsersResponseData; +import com.twitter.clientlib.model.TweetLabelData; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.io.IOException; @@ -55,18 +55,19 @@ import com.twitter.clientlib.JSON; /** - * ReportUsersResponse + * Tweet Label event. */ +@ApiModel(description = "Tweet Label event.") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") -public class ReportUsersResponse { +public class TweetLabelStreamResponseOneOf { public static final String SERIALIZED_NAME_DATA = "data"; @SerializedName(SERIALIZED_NAME_DATA) - private ReportUsersResponseData data; + private TweetLabelData data; - public ReportUsersResponse() { + public TweetLabelStreamResponseOneOf() { } - public ReportUsersResponse data(ReportUsersResponseData data) { + public TweetLabelStreamResponseOneOf data(TweetLabelData data) { this.data = data; return this; @@ -76,15 +77,15 @@ public ReportUsersResponse data(ReportUsersResponseData data) { * Get data * @return data **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") - public ReportUsersResponseData getData() { + public TweetLabelData getData() { return data; } - public void setData(ReportUsersResponseData data) { + public void setData(TweetLabelData data) { this.data = data; } @@ -98,8 +99,8 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - ReportUsersResponse reportUsersResponse = (ReportUsersResponse) o; - return Objects.equals(this.data, reportUsersResponse.data); + TweetLabelStreamResponseOneOf tweetLabelStreamResponseOneOf = (TweetLabelStreamResponseOneOf) o; + return Objects.equals(this.data, tweetLabelStreamResponseOneOf.data); } @Override @@ -110,7 +111,7 @@ public int hashCode() { @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class ReportUsersResponse {\n"); + sb.append("class TweetLabelStreamResponseOneOf {\n"); sb.append(" data: ").append(toIndentedString(data)).append("\n"); sb.append("}"); return sb.toString(); @@ -138,26 +139,34 @@ private String toIndentedString(Object o) { // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("data"); } /** * Validates the JSON Object and throws an exception if issues found * * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to ReportUsersResponse + * @throws IOException if the JSON Object is invalid with respect to TweetLabelStreamResponseOneOf */ public static void validateJsonObject(JsonObject jsonObj) throws IOException { // if (jsonObj == null) { - // if (ReportUsersResponse.openapiRequiredFields.isEmpty()) { + // if (TweetLabelStreamResponseOneOf.openapiRequiredFields.isEmpty()) { // return; // } else { // has required fields - // throw new IllegalArgumentException(String.format("The required field(s) %s in ReportUsersResponse is not found in the empty JSON string", ReportUsersResponse.openapiRequiredFields.toString())); + // throw new IllegalArgumentException(String.format("The required field(s) %s in TweetLabelStreamResponseOneOf is not found in the empty JSON string", TweetLabelStreamResponseOneOf.openapiRequiredFields.toString())); // } // } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : TweetLabelStreamResponseOneOf.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } // validate the optional field `data` if (jsonObj.getAsJsonObject("data") != null) { - ReportUsersResponseData.validateJsonObject(jsonObj.getAsJsonObject("data")); + TweetLabelData.validateJsonObject(jsonObj.getAsJsonObject("data")); } } @@ -165,22 +174,22 @@ public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!ReportUsersResponse.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'ReportUsersResponse' and its subtypes + if (!TweetLabelStreamResponseOneOf.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'TweetLabelStreamResponseOneOf' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(ReportUsersResponse.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(TweetLabelStreamResponseOneOf.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, ReportUsersResponse value) throws IOException { + public void write(JsonWriter out, TweetLabelStreamResponseOneOf value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); elementAdapter.write(out, obj); } @Override - public ReportUsersResponse read(JsonReader in) throws IOException { + public TweetLabelStreamResponseOneOf read(JsonReader in) throws IOException { JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); validateJsonObject(jsonObj); return thisAdapter.fromJsonTree(jsonObj); @@ -191,18 +200,18 @@ public ReportUsersResponse read(JsonReader in) throws IOException { } /** - * Create an instance of ReportUsersResponse given an JSON string + * Create an instance of TweetLabelStreamResponseOneOf given an JSON string * * @param jsonString JSON string - * @return An instance of ReportUsersResponse - * @throws IOException if the JSON string is invalid with respect to ReportUsersResponse + * @return An instance of TweetLabelStreamResponseOneOf + * @throws IOException if the JSON string is invalid with respect to TweetLabelStreamResponseOneOf */ - public static ReportUsersResponse fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, ReportUsersResponse.class); + public static TweetLabelStreamResponseOneOf fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, TweetLabelStreamResponseOneOf.class); } /** - * Convert an instance of ReportUsersResponse to an JSON string + * Convert an instance of TweetLabelStreamResponseOneOf to an JSON string * * @return JSON string */ diff --git a/src/main/java/com/twitter/clientlib/model/TweetNotice.java b/src/main/java/com/twitter/clientlib/model/TweetNotice.java new file mode 100644 index 0000000..ca84659 --- /dev/null +++ b/src/main/java/com/twitter/clientlib/model/TweetNotice.java @@ -0,0 +1,420 @@ +/* +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.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.twitter.clientlib.model.TweetComplianceSchemaTweet; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.time.OffsetDateTime; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.twitter.clientlib.JSON; + +/** + * TweetNotice + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class TweetNotice { + public static final String SERIALIZED_NAME_APPLICATION = "application"; + @SerializedName(SERIALIZED_NAME_APPLICATION) + private String application; + + public static final String SERIALIZED_NAME_DETAILS = "details"; + @SerializedName(SERIALIZED_NAME_DETAILS) + private String details; + + public static final String SERIALIZED_NAME_EVENT_AT = "event_at"; + @SerializedName(SERIALIZED_NAME_EVENT_AT) + private OffsetDateTime eventAt; + + public static final String SERIALIZED_NAME_EVENT_TYPE = "event_type"; + @SerializedName(SERIALIZED_NAME_EVENT_TYPE) + private String eventType; + + public static final String SERIALIZED_NAME_EXTENDED_DETAILS_URL = "extended_details_url"; + @SerializedName(SERIALIZED_NAME_EXTENDED_DETAILS_URL) + private String extendedDetailsUrl; + + public static final String SERIALIZED_NAME_LABEL_TITLE = "label_title"; + @SerializedName(SERIALIZED_NAME_LABEL_TITLE) + private String labelTitle; + + public static final String SERIALIZED_NAME_TWEET = "tweet"; + @SerializedName(SERIALIZED_NAME_TWEET) + private TweetComplianceSchemaTweet tweet; + + public TweetNotice() { + } + + public TweetNotice application(String application) { + + this.application = application; + return this; + } + + /** + * If the label is being applied or removed. Possible values are ‘apply’ or ‘remove’. + * @return application + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "apply", required = true, value = "If the label is being applied or removed. Possible values are ‘apply’ or ‘remove’.") + + public String getApplication() { + return application; + } + + + public void setApplication(String application) { + this.application = application; + } + + + public TweetNotice details(String details) { + + this.details = details; + return this; + } + + /** + * Information shown on the Tweet label + * @return details + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Information shown on the Tweet label") + + public String getDetails() { + return details; + } + + + public void setDetails(String details) { + this.details = details; + } + + + public TweetNotice eventAt(OffsetDateTime eventAt) { + + this.eventAt = eventAt; + return this; + } + + /** + * Event time. + * @return eventAt + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "2021-07-06T18:40:40Z", required = true, value = "Event time.") + + public OffsetDateTime getEventAt() { + return eventAt; + } + + + public void setEventAt(OffsetDateTime eventAt) { + this.eventAt = eventAt; + } + + + public TweetNotice eventType(String eventType) { + + this.eventType = eventType; + return this; + } + + /** + * The type of label on the Tweet + * @return eventType + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "misleading", required = true, value = "The type of label on the Tweet") + + public String getEventType() { + return eventType; + } + + + public void setEventType(String eventType) { + this.eventType = eventType; + } + + + public TweetNotice extendedDetailsUrl(String extendedDetailsUrl) { + + this.extendedDetailsUrl = extendedDetailsUrl; + return this; + } + + /** + * Link to more information about this kind of label + * @return extendedDetailsUrl + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Link to more information about this kind of label") + + public String getExtendedDetailsUrl() { + return extendedDetailsUrl; + } + + + public void setExtendedDetailsUrl(String extendedDetailsUrl) { + this.extendedDetailsUrl = extendedDetailsUrl; + } + + + public TweetNotice labelTitle(String labelTitle) { + + this.labelTitle = labelTitle; + return this; + } + + /** + * Title/header of the Tweet label + * @return labelTitle + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Title/header of the Tweet label") + + public String getLabelTitle() { + return labelTitle; + } + + + public void setLabelTitle(String labelTitle) { + this.labelTitle = labelTitle; + } + + + public TweetNotice tweet(TweetComplianceSchemaTweet tweet) { + + this.tweet = tweet; + return this; + } + + /** + * Get tweet + * @return tweet + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + + public TweetComplianceSchemaTweet getTweet() { + return tweet; + } + + + public void setTweet(TweetComplianceSchemaTweet tweet) { + this.tweet = tweet; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TweetNotice tweetNotice = (TweetNotice) o; + return Objects.equals(this.application, tweetNotice.application) && + Objects.equals(this.details, tweetNotice.details) && + Objects.equals(this.eventAt, tweetNotice.eventAt) && + Objects.equals(this.eventType, tweetNotice.eventType) && + Objects.equals(this.extendedDetailsUrl, tweetNotice.extendedDetailsUrl) && + Objects.equals(this.labelTitle, tweetNotice.labelTitle) && + Objects.equals(this.tweet, tweetNotice.tweet); + } + + @Override + public int hashCode() { + return Objects.hash(application, details, eventAt, eventType, extendedDetailsUrl, labelTitle, tweet); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TweetNotice {\n"); + sb.append(" application: ").append(toIndentedString(application)).append("\n"); + sb.append(" details: ").append(toIndentedString(details)).append("\n"); + sb.append(" eventAt: ").append(toIndentedString(eventAt)).append("\n"); + sb.append(" eventType: ").append(toIndentedString(eventType)).append("\n"); + sb.append(" extendedDetailsUrl: ").append(toIndentedString(extendedDetailsUrl)).append("\n"); + sb.append(" labelTitle: ").append(toIndentedString(labelTitle)).append("\n"); + sb.append(" tweet: ").append(toIndentedString(tweet)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("application"); + openapiFields.add("details"); + openapiFields.add("event_at"); + openapiFields.add("event_type"); + openapiFields.add("extended_details_url"); + openapiFields.add("label_title"); + openapiFields.add("tweet"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("application"); + openapiRequiredFields.add("event_at"); + openapiRequiredFields.add("event_type"); + openapiRequiredFields.add("tweet"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to TweetNotice + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // if (jsonObj == null) { + // if (TweetNotice.openapiRequiredFields.isEmpty()) { + // return; + // } else { // has required fields + // throw new IllegalArgumentException(String.format("The required field(s) %s in TweetNotice is not found in the empty JSON string", TweetNotice.openapiRequiredFields.toString())); + // } + // } + + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : TweetNotice.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (jsonObj.get("application") != null && !jsonObj.get("application").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `application` to be a primitive type in the JSON string but got `%s`", jsonObj.get("application").toString())); + } + if (jsonObj.get("details") != null && !jsonObj.get("details").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `details` to be a primitive type in the JSON string but got `%s`", jsonObj.get("details").toString())); + } + if (jsonObj.get("event_type") != null && !jsonObj.get("event_type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `event_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event_type").toString())); + } + if (jsonObj.get("extended_details_url") != null && !jsonObj.get("extended_details_url").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `extended_details_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("extended_details_url").toString())); + } + if (jsonObj.get("label_title") != null && !jsonObj.get("label_title").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `label_title` to be a primitive type in the JSON string but got `%s`", jsonObj.get("label_title").toString())); + } + // validate the optional field `tweet` + if (jsonObj.getAsJsonObject("tweet") != null) { + TweetComplianceSchemaTweet.validateJsonObject(jsonObj.getAsJsonObject("tweet")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!TweetNotice.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'TweetNotice' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(TweetNotice.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, TweetNotice value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public TweetNotice read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of TweetNotice given an JSON string + * + * @param jsonString JSON string + * @return An instance of TweetNotice + * @throws IOException if the JSON string is invalid with respect to TweetNotice + */ + public static TweetNotice fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, TweetNotice.class); + } + + /** + * Convert an instance of TweetNotice to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/twitter/clientlib/model/ReportUsersRequest.java b/src/main/java/com/twitter/clientlib/model/TweetNoticeSchema.java similarity index 56% rename from src/main/java/com/twitter/clientlib/model/ReportUsersRequest.java rename to src/main/java/com/twitter/clientlib/model/TweetNoticeSchema.java index 6f3fdfa..353bc38 100644 --- a/src/main/java/com/twitter/clientlib/model/ReportUsersRequest.java +++ b/src/main/java/com/twitter/clientlib/model/TweetNoticeSchema.java @@ -29,11 +29,10 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import com.twitter.clientlib.model.TweetNotice; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.io.IOException; -import java.util.ArrayList; -import java.util.List; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -56,69 +55,37 @@ import com.twitter.clientlib.JSON; /** - * ReportUsersRequest + * TweetNoticeSchema */ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") -public class ReportUsersRequest { - public static final String SERIALIZED_NAME_DESCRIPTION = "description"; - @SerializedName(SERIALIZED_NAME_DESCRIPTION) - private String description; +public class TweetNoticeSchema { + public static final String SERIALIZED_NAME_PUBLIC_TWEET_NOTICE = "public_tweet_notice"; + @SerializedName(SERIALIZED_NAME_PUBLIC_TWEET_NOTICE) + private TweetNotice publicTweetNotice; - public static final String SERIALIZED_NAME_USER_IDS = "user_ids"; - @SerializedName(SERIALIZED_NAME_USER_IDS) - private List userIds = new ArrayList<>(); - - public ReportUsersRequest() { - } - - public ReportUsersRequest description(String description) { - - this.description = description; - return this; - } - - /** - * Get description - * @return description - **/ - @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") - - public String getDescription() { - return description; - } - - - public void setDescription(String description) { - this.description = description; + public TweetNoticeSchema() { } - - public ReportUsersRequest userIds(List userIds) { + public TweetNoticeSchema publicTweetNotice(TweetNotice publicTweetNotice) { - this.userIds = userIds; - return this; - } - - public ReportUsersRequest addUserIdsItem(String userIdsItem) { - this.userIds.add(userIdsItem); + this.publicTweetNotice = publicTweetNotice; return this; } /** - * Get userIds - * @return userIds + * Get publicTweetNotice + * @return publicTweetNotice **/ @javax.annotation.Nonnull @ApiModelProperty(required = true, value = "") - public List getUserIds() { - return userIds; + public TweetNotice getPublicTweetNotice() { + return publicTweetNotice; } - public void setUserIds(List userIds) { - this.userIds = userIds; + public void setPublicTweetNotice(TweetNotice publicTweetNotice) { + this.publicTweetNotice = publicTweetNotice; } @@ -131,22 +98,20 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - ReportUsersRequest reportUsersRequest = (ReportUsersRequest) o; - return Objects.equals(this.description, reportUsersRequest.description) && - Objects.equals(this.userIds, reportUsersRequest.userIds); + TweetNoticeSchema tweetNoticeSchema = (TweetNoticeSchema) o; + return Objects.equals(this.publicTweetNotice, tweetNoticeSchema.publicTweetNotice); } @Override public int hashCode() { - return Objects.hash(description, userIds); + return Objects.hash(publicTweetNotice); } @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class ReportUsersRequest {\n"); - sb.append(" description: ").append(toIndentedString(description)).append("\n"); - sb.append(" userIds: ").append(toIndentedString(userIds)).append("\n"); + sb.append("class TweetNoticeSchema {\n"); + sb.append(" publicTweetNotice: ").append(toIndentedString(publicTweetNotice)).append("\n"); sb.append("}"); return sb.toString(); } @@ -169,43 +134,38 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) openapiFields = new HashSet(); - openapiFields.add("description"); - openapiFields.add("user_ids"); + openapiFields.add("public_tweet_notice"); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(); - openapiRequiredFields.add("description"); - openapiRequiredFields.add("user_ids"); + openapiRequiredFields.add("public_tweet_notice"); } /** * Validates the JSON Object and throws an exception if issues found * * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to ReportUsersRequest + * @throws IOException if the JSON Object is invalid with respect to TweetNoticeSchema */ public static void validateJsonObject(JsonObject jsonObj) throws IOException { // if (jsonObj == null) { - // if (ReportUsersRequest.openapiRequiredFields.isEmpty()) { + // if (TweetNoticeSchema.openapiRequiredFields.isEmpty()) { // return; // } else { // has required fields - // throw new IllegalArgumentException(String.format("The required field(s) %s in ReportUsersRequest is not found in the empty JSON string", ReportUsersRequest.openapiRequiredFields.toString())); + // throw new IllegalArgumentException(String.format("The required field(s) %s in TweetNoticeSchema is not found in the empty JSON string", TweetNoticeSchema.openapiRequiredFields.toString())); // } // } // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : ReportUsersRequest.openapiRequiredFields) { + for (String requiredField : TweetNoticeSchema.openapiRequiredFields) { if (jsonObj.get(requiredField) == null) { throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); } } - if (jsonObj.get("description") != null && !jsonObj.get("description").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); - } - // ensure the json data is an array - if (jsonObj.get("user_ids") != null && !jsonObj.get("user_ids").isJsonArray()) { - throw new IllegalArgumentException(String.format("Expected the field `user_ids` to be an array in the JSON string but got `%s`", jsonObj.get("user_ids").toString())); + // validate the optional field `public_tweet_notice` + if (jsonObj.getAsJsonObject("public_tweet_notice") != null) { + TweetNotice.validateJsonObject(jsonObj.getAsJsonObject("public_tweet_notice")); } } @@ -213,22 +173,22 @@ public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!ReportUsersRequest.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'ReportUsersRequest' and its subtypes + if (!TweetNoticeSchema.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'TweetNoticeSchema' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(ReportUsersRequest.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(TweetNoticeSchema.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, ReportUsersRequest value) throws IOException { + public void write(JsonWriter out, TweetNoticeSchema value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); elementAdapter.write(out, obj); } @Override - public ReportUsersRequest read(JsonReader in) throws IOException { + public TweetNoticeSchema read(JsonReader in) throws IOException { JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); validateJsonObject(jsonObj); return thisAdapter.fromJsonTree(jsonObj); @@ -239,18 +199,18 @@ public ReportUsersRequest read(JsonReader in) throws IOException { } /** - * Create an instance of ReportUsersRequest given an JSON string + * Create an instance of TweetNoticeSchema given an JSON string * * @param jsonString JSON string - * @return An instance of ReportUsersRequest - * @throws IOException if the JSON string is invalid with respect to ReportUsersRequest + * @return An instance of TweetNoticeSchema + * @throws IOException if the JSON string is invalid with respect to TweetNoticeSchema */ - public static ReportUsersRequest fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, ReportUsersRequest.class); + public static TweetNoticeSchema fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, TweetNoticeSchema.class); } /** - * Convert an instance of ReportUsersRequest to an JSON string + * Convert an instance of TweetNoticeSchema to an JSON string * * @return JSON string */ diff --git a/src/main/java/com/twitter/clientlib/model/TweetUnviewable.java b/src/main/java/com/twitter/clientlib/model/TweetUnviewable.java new file mode 100644 index 0000000..cd4a59e --- /dev/null +++ b/src/main/java/com/twitter/clientlib/model/TweetUnviewable.java @@ -0,0 +1,287 @@ +/* +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.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.twitter.clientlib.model.TweetComplianceSchemaTweet; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.time.OffsetDateTime; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.twitter.clientlib.JSON; + +/** + * TweetUnviewable + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class TweetUnviewable { + public static final String SERIALIZED_NAME_APPLICATION = "application"; + @SerializedName(SERIALIZED_NAME_APPLICATION) + private String application; + + public static final String SERIALIZED_NAME_EVENT_AT = "event_at"; + @SerializedName(SERIALIZED_NAME_EVENT_AT) + private OffsetDateTime eventAt; + + public static final String SERIALIZED_NAME_TWEET = "tweet"; + @SerializedName(SERIALIZED_NAME_TWEET) + private TweetComplianceSchemaTweet tweet; + + public TweetUnviewable() { + } + + public TweetUnviewable application(String application) { + + this.application = application; + return this; + } + + /** + * If the label is being applied or removed. Possible values are ‘apply’ or ‘remove’. + * @return application + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "apply", required = true, value = "If the label is being applied or removed. Possible values are ‘apply’ or ‘remove’.") + + public String getApplication() { + return application; + } + + + public void setApplication(String application) { + this.application = application; + } + + + public TweetUnviewable eventAt(OffsetDateTime eventAt) { + + this.eventAt = eventAt; + return this; + } + + /** + * Event time. + * @return eventAt + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "2021-07-06T18:40:40Z", required = true, value = "Event time.") + + public OffsetDateTime getEventAt() { + return eventAt; + } + + + public void setEventAt(OffsetDateTime eventAt) { + this.eventAt = eventAt; + } + + + public TweetUnviewable tweet(TweetComplianceSchemaTweet tweet) { + + this.tweet = tweet; + return this; + } + + /** + * Get tweet + * @return tweet + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + + public TweetComplianceSchemaTweet getTweet() { + return tweet; + } + + + public void setTweet(TweetComplianceSchemaTweet tweet) { + this.tweet = tweet; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TweetUnviewable tweetUnviewable = (TweetUnviewable) o; + return Objects.equals(this.application, tweetUnviewable.application) && + Objects.equals(this.eventAt, tweetUnviewable.eventAt) && + Objects.equals(this.tweet, tweetUnviewable.tweet); + } + + @Override + public int hashCode() { + return Objects.hash(application, eventAt, tweet); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TweetUnviewable {\n"); + sb.append(" application: ").append(toIndentedString(application)).append("\n"); + sb.append(" eventAt: ").append(toIndentedString(eventAt)).append("\n"); + sb.append(" tweet: ").append(toIndentedString(tweet)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("application"); + openapiFields.add("event_at"); + openapiFields.add("tweet"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("application"); + openapiRequiredFields.add("event_at"); + openapiRequiredFields.add("tweet"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to TweetUnviewable + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // if (jsonObj == null) { + // if (TweetUnviewable.openapiRequiredFields.isEmpty()) { + // return; + // } else { // has required fields + // throw new IllegalArgumentException(String.format("The required field(s) %s in TweetUnviewable is not found in the empty JSON string", TweetUnviewable.openapiRequiredFields.toString())); + // } + // } + + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : TweetUnviewable.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (jsonObj.get("application") != null && !jsonObj.get("application").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `application` to be a primitive type in the JSON string but got `%s`", jsonObj.get("application").toString())); + } + // validate the optional field `tweet` + if (jsonObj.getAsJsonObject("tweet") != null) { + TweetComplianceSchemaTweet.validateJsonObject(jsonObj.getAsJsonObject("tweet")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!TweetUnviewable.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'TweetUnviewable' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(TweetUnviewable.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, TweetUnviewable value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public TweetUnviewable read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of TweetUnviewable given an JSON string + * + * @param jsonString JSON string + * @return An instance of TweetUnviewable + * @throws IOException if the JSON string is invalid with respect to TweetUnviewable + */ + public static TweetUnviewable fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, TweetUnviewable.class); + } + + /** + * Convert an instance of TweetUnviewable to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/twitter/clientlib/model/TweetUnviewableSchema.java b/src/main/java/com/twitter/clientlib/model/TweetUnviewableSchema.java new file mode 100644 index 0000000..949ad37 --- /dev/null +++ b/src/main/java/com/twitter/clientlib/model/TweetUnviewableSchema.java @@ -0,0 +1,221 @@ +/* +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.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.twitter.clientlib.model.TweetUnviewable; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.twitter.clientlib.JSON; + +/** + * TweetUnviewableSchema + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class TweetUnviewableSchema { + public static final String SERIALIZED_NAME_PUBLIC_TWEET_UNVIEWABLE = "public_tweet_unviewable"; + @SerializedName(SERIALIZED_NAME_PUBLIC_TWEET_UNVIEWABLE) + private TweetUnviewable publicTweetUnviewable; + + public TweetUnviewableSchema() { + } + + public TweetUnviewableSchema publicTweetUnviewable(TweetUnviewable publicTweetUnviewable) { + + this.publicTweetUnviewable = publicTweetUnviewable; + return this; + } + + /** + * Get publicTweetUnviewable + * @return publicTweetUnviewable + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + + public TweetUnviewable getPublicTweetUnviewable() { + return publicTweetUnviewable; + } + + + public void setPublicTweetUnviewable(TweetUnviewable publicTweetUnviewable) { + this.publicTweetUnviewable = publicTweetUnviewable; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TweetUnviewableSchema tweetUnviewableSchema = (TweetUnviewableSchema) o; + return Objects.equals(this.publicTweetUnviewable, tweetUnviewableSchema.publicTweetUnviewable); + } + + @Override + public int hashCode() { + return Objects.hash(publicTweetUnviewable); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TweetUnviewableSchema {\n"); + sb.append(" publicTweetUnviewable: ").append(toIndentedString(publicTweetUnviewable)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("public_tweet_unviewable"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("public_tweet_unviewable"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to TweetUnviewableSchema + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // if (jsonObj == null) { + // if (TweetUnviewableSchema.openapiRequiredFields.isEmpty()) { + // return; + // } else { // has required fields + // throw new IllegalArgumentException(String.format("The required field(s) %s in TweetUnviewableSchema is not found in the empty JSON string", TweetUnviewableSchema.openapiRequiredFields.toString())); + // } + // } + + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : TweetUnviewableSchema.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // validate the optional field `public_tweet_unviewable` + if (jsonObj.getAsJsonObject("public_tweet_unviewable") != null) { + TweetUnviewable.validateJsonObject(jsonObj.getAsJsonObject("public_tweet_unviewable")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!TweetUnviewableSchema.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'TweetUnviewableSchema' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(TweetUnviewableSchema.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, TweetUnviewableSchema value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public TweetUnviewableSchema read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of TweetUnviewableSchema given an JSON string + * + * @param jsonString JSON string + * @return An instance of TweetUnviewableSchema + * @throws IOException if the JSON string is invalid with respect to TweetUnviewableSchema + */ + public static TweetUnviewableSchema fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, TweetUnviewableSchema.class); + } + + /** + * Convert an instance of TweetUnviewableSchema to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/test/java/com/twitter/clientlib/api/ComplianceApiTest.java b/src/test/java/com/twitter/clientlib/api/ComplianceApiTest.java index e4290dd..d0b023e 100644 --- a/src/test/java/com/twitter/clientlib/api/ComplianceApiTest.java +++ b/src/test/java/com/twitter/clientlib/api/ComplianceApiTest.java @@ -33,6 +33,7 @@ import com.twitter.clientlib.model.Problem; import java.util.Set; import com.twitter.clientlib.model.TweetComplianceStreamResponse; +import com.twitter.clientlib.model.TweetLabelStreamResponse; import com.twitter.clientlib.model.UserComplianceStreamResponse; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -108,6 +109,27 @@ public void getTweetsComplianceStreamTest() throws ApiException { } + /** + * Tweets Label stream + * + * Streams 100% of labeling events applied to Tweets + * + * @throws ApiException if the Api call fails + */ + @Test + public void getTweetsLabelStreamTest() throws ApiException { + Integer backfillMinutes = null; + OffsetDateTime startTime = null; + OffsetDateTime endTime = null; + InputStream response = apiInstance.compliance().getTweetsLabelStream() + .backfillMinutes(backfillMinutes) + .startTime(startTime) + .endTime(endTime) + .execute(); + // TODO: test validations + } + + /** * Users Compliance stream * diff --git a/src/test/java/com/twitter/clientlib/api/DirectMessagesApiTest.java b/src/test/java/com/twitter/clientlib/api/DirectMessagesApiTest.java new file mode 100644 index 0000000..4f8afd8 --- /dev/null +++ b/src/test/java/com/twitter/clientlib/api/DirectMessagesApiTest.java @@ -0,0 +1,201 @@ +/* +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.TwitterCredentialsBearer; +import com.twitter.clientlib.ApiException; +import com.twitter.clientlib.model.CreateDmConversationRequest; +import com.twitter.clientlib.model.CreateDmEventResponse; +import com.twitter.clientlib.model.CreateMessageRequest; +import com.twitter.clientlib.model.Error; +import com.twitter.clientlib.model.Get2DmConversationsIdDmEventsResponse; +import com.twitter.clientlib.model.Get2DmConversationsWithParticipantIdDmEventsResponse; +import com.twitter.clientlib.model.Get2DmEventsResponse; +import com.twitter.clientlib.model.Problem; +import java.util.Set; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.io.InputStream; + +/** + * API tests for DirectMessagesApi + */ +@Disabled +public class DirectMessagesApiTest { + + private final TwitterApi apiInstance = new TwitterApi(new TwitterCredentialsBearer(System.getenv("TWITTER_BEARER_TOKEN"))); + // TODO set credentials + + /** + * Send a new message to a DM Conversation + * + * Creates a new message for a DM Conversation specified by DM Conversation ID + * + * @throws ApiException if the Api call fails + */ + @Test + public void dmConversationByIdEventIdCreateTest() throws ApiException { + CreateMessageRequest createMessageRequest = null; + String dmConversationId = null; + CreateDmEventResponse response = apiInstance.directMessages().dmConversationByIdEventIdCreate(dmConversationId) + .createMessageRequest(createMessageRequest) + .execute(); + // TODO: test validations + } + + + /** + * Create a new DM Conversation + * + * Creates a new DM Conversation. + * + * @throws ApiException if the Api call fails + */ + @Test + public void dmConversationIdCreateTest() throws ApiException { + CreateDmConversationRequest createDmConversationRequest = null; + CreateDmEventResponse response = apiInstance.directMessages().dmConversationIdCreate() + .createDmConversationRequest(createDmConversationRequest) + .execute(); + // TODO: test validations + } + + + /** + * Send a new message to a user + * + * Creates a new message for a DM Conversation with a participant user by ID + * + * @throws ApiException if the Api call fails + */ + @Test + public void dmConversationWithUserEventIdCreateTest() throws ApiException { + CreateMessageRequest createMessageRequest = null; + String participantId = null; + CreateDmEventResponse response = apiInstance.directMessages().dmConversationWithUserEventIdCreate(participantId) + .createMessageRequest(createMessageRequest) + .execute(); + // TODO: test validations + } + + + /** + * Get DM Events for a DM Conversation + * + * Returns DM Events for a DM Conversation + * + * @throws ApiException if the Api call fails + */ + @Test + public void getDmConversationsIdDmEventsTest() throws ApiException { + String id = null; + Integer maxResults = null; + String paginationToken = null; + Set eventTypes = null; + Set dmEventFields = null; + Set expansions = null; + Set mediaFields = null; + Set userFields = null; + Set tweetFields = null; + Get2DmConversationsIdDmEventsResponse response = apiInstance.directMessages().getDmConversationsIdDmEvents(id) + .maxResults(maxResults) + .paginationToken(paginationToken) + .eventTypes(eventTypes) + .dmEventFields(dmEventFields) + .expansions(expansions) + .mediaFields(mediaFields) + .userFields(userFields) + .tweetFields(tweetFields) + .execute(); + // TODO: test validations + } + + + /** + * Get DM Events for a DM Conversation + * + * Returns DM Events for a DM Conversation + * + * @throws ApiException if the Api call fails + */ + @Test + public void getDmConversationsWithParticipantIdDmEventsTest() throws ApiException { + String participantId = null; + Integer maxResults = null; + String paginationToken = null; + Set eventTypes = null; + Set dmEventFields = null; + Set expansions = null; + Set mediaFields = null; + Set userFields = null; + Set tweetFields = null; + Get2DmConversationsWithParticipantIdDmEventsResponse response = apiInstance.directMessages().getDmConversationsWithParticipantIdDmEvents(participantId) + .maxResults(maxResults) + .paginationToken(paginationToken) + .eventTypes(eventTypes) + .dmEventFields(dmEventFields) + .expansions(expansions) + .mediaFields(mediaFields) + .userFields(userFields) + .tweetFields(tweetFields) + .execute(); + // TODO: test validations + } + + + /** + * Get recent DM Events + * + * Returns recent DM Events across DM conversations + * + * @throws ApiException if the Api call fails + */ + @Test + public void getDmEventsTest() throws ApiException { + Integer maxResults = null; + String paginationToken = null; + Set eventTypes = null; + Set dmEventFields = null; + Set expansions = null; + Set mediaFields = null; + Set userFields = null; + Set tweetFields = null; + Get2DmEventsResponse response = apiInstance.directMessages().getDmEvents() + .maxResults(maxResults) + .paginationToken(paginationToken) + .eventTypes(eventTypes) + .dmEventFields(dmEventFields) + .expansions(expansions) + .mediaFields(mediaFields) + .userFields(userFields) + .tweetFields(tweetFields) + .execute(); + // TODO: test validations + } + +} diff --git a/src/test/java/com/twitter/clientlib/model/CreateAttachmentsMessageRequestTest.java b/src/test/java/com/twitter/clientlib/model/CreateAttachmentsMessageRequestTest.java new file mode 100644 index 0000000..6e457fd --- /dev/null +++ b/src/test/java/com/twitter/clientlib/model/CreateAttachmentsMessageRequestTest.java @@ -0,0 +1,70 @@ +/* +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.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.twitter.clientlib.model.DmMediaAttachment; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + + +/** + * Model tests for CreateAttachmentsMessageRequest + */ +public class CreateAttachmentsMessageRequestTest { + private final CreateAttachmentsMessageRequest model = new CreateAttachmentsMessageRequest(); + + /** + * Model tests for CreateAttachmentsMessageRequest + */ + @Test + public void testCreateAttachmentsMessageRequest() { + // TODO: test CreateAttachmentsMessageRequest + } + + /** + * Test the property 'attachments' + */ + @Test + public void attachmentsTest() { + // TODO: test attachments + } + + /** + * Test the property 'text' + */ + @Test + public void textTest() { + // TODO: test text + } + +} diff --git a/src/test/java/com/twitter/clientlib/model/CreateDmConversationRequestTest.java b/src/test/java/com/twitter/clientlib/model/CreateDmConversationRequestTest.java new file mode 100644 index 0000000..479b778 --- /dev/null +++ b/src/test/java/com/twitter/clientlib/model/CreateDmConversationRequestTest.java @@ -0,0 +1,78 @@ +/* +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.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.twitter.clientlib.model.CreateMessageRequest; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + + +/** + * Model tests for CreateDmConversationRequest + */ +public class CreateDmConversationRequestTest { + private final CreateDmConversationRequest model = new CreateDmConversationRequest(); + + /** + * Model tests for CreateDmConversationRequest + */ + @Test + public void testCreateDmConversationRequest() { + // TODO: test CreateDmConversationRequest + } + + /** + * Test the property 'conversationType' + */ + @Test + public void conversationTypeTest() { + // TODO: test conversationType + } + + /** + * Test the property 'message' + */ + @Test + public void messageTest() { + // TODO: test message + } + + /** + * Test the property 'participantIds' + */ + @Test + public void participantIdsTest() { + // TODO: test participantIds + } + +} diff --git a/src/test/java/com/twitter/clientlib/model/CreateDmEventResponseDataTest.java b/src/test/java/com/twitter/clientlib/model/CreateDmEventResponseDataTest.java new file mode 100644 index 0000000..9df7ce1 --- /dev/null +++ b/src/test/java/com/twitter/clientlib/model/CreateDmEventResponseDataTest.java @@ -0,0 +1,67 @@ +/* +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.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + + +/** + * Model tests for CreateDmEventResponseData + */ +public class CreateDmEventResponseDataTest { + private final CreateDmEventResponseData model = new CreateDmEventResponseData(); + + /** + * Model tests for CreateDmEventResponseData + */ + @Test + public void testCreateDmEventResponseData() { + // TODO: test CreateDmEventResponseData + } + + /** + * Test the property 'dmConversationId' + */ + @Test + public void dmConversationIdTest() { + // TODO: test dmConversationId + } + + /** + * Test the property 'dmEventId' + */ + @Test + public void dmEventIdTest() { + // TODO: test dmEventId + } + +} diff --git a/src/test/java/com/twitter/clientlib/model/ProblemErrorsTest.java b/src/test/java/com/twitter/clientlib/model/CreateDmEventResponseTest.java similarity index 75% rename from src/test/java/com/twitter/clientlib/model/ProblemErrorsTest.java rename to src/test/java/com/twitter/clientlib/model/CreateDmEventResponseTest.java index 6037476..9043818 100644 --- a/src/test/java/com/twitter/clientlib/model/ProblemErrorsTest.java +++ b/src/test/java/com/twitter/clientlib/model/CreateDmEventResponseTest.java @@ -27,6 +27,7 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import com.twitter.clientlib.model.CreateDmEventResponseData; import com.twitter.clientlib.model.Problem; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -38,17 +39,25 @@ /** - * Model tests for ProblemErrors + * Model tests for CreateDmEventResponse */ -public class ProblemErrorsTest { - private final ProblemErrors model = new ProblemErrors(); +public class CreateDmEventResponseTest { + private final CreateDmEventResponse model = new CreateDmEventResponse(); /** - * Model tests for ProblemErrors + * Model tests for CreateDmEventResponse */ @Test - public void testProblemErrors() { - // TODO: test ProblemErrors + public void testCreateDmEventResponse() { + // TODO: test CreateDmEventResponse + } + + /** + * Test the property 'data' + */ + @Test + public void dataTest() { + // TODO: test data } /** diff --git a/src/test/java/com/twitter/clientlib/model/CreateMessageRequestTest.java b/src/test/java/com/twitter/clientlib/model/CreateMessageRequestTest.java new file mode 100644 index 0000000..213f4e3 --- /dev/null +++ b/src/test/java/com/twitter/clientlib/model/CreateMessageRequestTest.java @@ -0,0 +1,72 @@ +/* +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.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.twitter.clientlib.model.CreateAttachmentsMessageRequest; +import com.twitter.clientlib.model.CreateTextMessageRequest; +import com.twitter.clientlib.model.DmMediaAttachment; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + + +/** + * Model tests for CreateMessageRequest + */ +public class CreateMessageRequestTest { + private final CreateMessageRequest model = new CreateMessageRequest(); + + /** + * Model tests for CreateMessageRequest + */ + @Test + public void testCreateMessageRequest() { + // TODO: test CreateMessageRequest + } + + /** + * Test the property 'attachments' + */ + @Test + public void attachmentsTest() { + // TODO: test attachments + } + + /** + * Test the property 'text' + */ + @Test + public void textTest() { + // TODO: test text + } + +} diff --git a/src/test/java/com/twitter/clientlib/model/CreateTextMessageRequestTest.java b/src/test/java/com/twitter/clientlib/model/CreateTextMessageRequestTest.java new file mode 100644 index 0000000..5d97274 --- /dev/null +++ b/src/test/java/com/twitter/clientlib/model/CreateTextMessageRequestTest.java @@ -0,0 +1,70 @@ +/* +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.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.twitter.clientlib.model.DmMediaAttachment; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + + +/** + * Model tests for CreateTextMessageRequest + */ +public class CreateTextMessageRequestTest { + private final CreateTextMessageRequest model = new CreateTextMessageRequest(); + + /** + * Model tests for CreateTextMessageRequest + */ + @Test + public void testCreateTextMessageRequest() { + // TODO: test CreateTextMessageRequest + } + + /** + * Test the property 'attachments' + */ + @Test + public void attachmentsTest() { + // TODO: test attachments + } + + /** + * Test the property 'text' + */ + @Test + public void textTest() { + // TODO: test text + } + +} diff --git a/src/test/java/com/twitter/clientlib/model/ReportUsersRequestTest.java b/src/test/java/com/twitter/clientlib/model/DmEventAttachmentsTest.java similarity index 73% rename from src/test/java/com/twitter/clientlib/model/ReportUsersRequestTest.java rename to src/test/java/com/twitter/clientlib/model/DmEventAttachmentsTest.java index 1881368..90deac5 100644 --- a/src/test/java/com/twitter/clientlib/model/ReportUsersRequestTest.java +++ b/src/test/java/com/twitter/clientlib/model/DmEventAttachmentsTest.java @@ -37,33 +37,33 @@ /** - * Model tests for ReportUsersRequest + * Model tests for DmEventAttachments */ -public class ReportUsersRequestTest { - private final ReportUsersRequest model = new ReportUsersRequest(); +public class DmEventAttachmentsTest { + private final DmEventAttachments model = new DmEventAttachments(); /** - * Model tests for ReportUsersRequest + * Model tests for DmEventAttachments */ @Test - public void testReportUsersRequest() { - // TODO: test ReportUsersRequest + public void testDmEventAttachments() { + // TODO: test DmEventAttachments } /** - * Test the property 'description' + * Test the property 'cardIds' */ @Test - public void descriptionTest() { - // TODO: test description + public void cardIdsTest() { + // TODO: test cardIds } /** - * Test the property 'userIds' + * Test the property 'mediaKeys' */ @Test - public void userIdsTest() { - // TODO: test userIds + public void mediaKeysTest() { + // TODO: test mediaKeys } } diff --git a/src/test/java/com/twitter/clientlib/model/DmEventTest.java b/src/test/java/com/twitter/clientlib/model/DmEventTest.java new file mode 100644 index 0000000..7362b22 --- /dev/null +++ b/src/test/java/com/twitter/clientlib/model/DmEventTest.java @@ -0,0 +1,128 @@ +/* +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.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.twitter.clientlib.model.DmEventAttachments; +import com.twitter.clientlib.model.TweetEditComplianceObjectSchemaTweet; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.List; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + + +/** + * Model tests for DmEvent + */ +public class DmEventTest { + private final DmEvent model = new DmEvent(); + + /** + * Model tests for DmEvent + */ + @Test + public void testDmEvent() { + // TODO: test DmEvent + } + + /** + * Test the property 'attachments' + */ + @Test + public void attachmentsTest() { + // TODO: test attachments + } + + /** + * Test the property 'createdAt' + */ + @Test + public void createdAtTest() { + // TODO: test createdAt + } + + /** + * Test the property 'dmConversationId' + */ + @Test + public void dmConversationIdTest() { + // TODO: test dmConversationId + } + + /** + * Test the property 'eventType' + */ + @Test + public void eventTypeTest() { + // TODO: test eventType + } + + /** + * Test the property 'id' + */ + @Test + public void idTest() { + // TODO: test id + } + + /** + * Test the property 'participantIds' + */ + @Test + public void participantIdsTest() { + // TODO: test participantIds + } + + /** + * Test the property 'referencedTweets' + */ + @Test + public void referencedTweetsTest() { + // TODO: test referencedTweets + } + + /** + * Test the property 'senderId' + */ + @Test + public void senderIdTest() { + // TODO: test senderId + } + + /** + * Test the property 'text' + */ + @Test + public void textTest() { + // TODO: test text + } + +} diff --git a/src/test/java/com/twitter/clientlib/model/ReportUsersResponseDataTest.java b/src/test/java/com/twitter/clientlib/model/DmMediaAttachmentTest.java similarity index 76% rename from src/test/java/com/twitter/clientlib/model/ReportUsersResponseDataTest.java rename to src/test/java/com/twitter/clientlib/model/DmMediaAttachmentTest.java index 8e96373..1ce7637 100644 --- a/src/test/java/com/twitter/clientlib/model/ReportUsersResponseDataTest.java +++ b/src/test/java/com/twitter/clientlib/model/DmMediaAttachmentTest.java @@ -35,25 +35,25 @@ /** - * Model tests for ReportUsersResponseData + * Model tests for DmMediaAttachment */ -public class ReportUsersResponseDataTest { - private final ReportUsersResponseData model = new ReportUsersResponseData(); +public class DmMediaAttachmentTest { + private final DmMediaAttachment model = new DmMediaAttachment(); /** - * Model tests for ReportUsersResponseData + * Model tests for DmMediaAttachment */ @Test - public void testReportUsersResponseData() { - // TODO: test ReportUsersResponseData + public void testDmMediaAttachment() { + // TODO: test DmMediaAttachment } /** - * Test the property 'id' + * Test the property 'mediaId' */ @Test - public void idTest() { - // TODO: test id + public void mediaIdTest() { + // TODO: test mediaId } } diff --git a/src/test/java/com/twitter/clientlib/model/Get2DmConversationsIdDmEventsResponseTest.java b/src/test/java/com/twitter/clientlib/model/Get2DmConversationsIdDmEventsResponseTest.java new file mode 100644 index 0000000..32d98d8 --- /dev/null +++ b/src/test/java/com/twitter/clientlib/model/Get2DmConversationsIdDmEventsResponseTest.java @@ -0,0 +1,89 @@ +/* +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.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.twitter.clientlib.model.DmEvent; +import com.twitter.clientlib.model.Expansions; +import com.twitter.clientlib.model.Get2ListsIdFollowersResponseMeta; +import com.twitter.clientlib.model.Problem; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + + +/** + * Model tests for Get2DmConversationsIdDmEventsResponse + */ +public class Get2DmConversationsIdDmEventsResponseTest { + private final Get2DmConversationsIdDmEventsResponse model = new Get2DmConversationsIdDmEventsResponse(); + + /** + * Model tests for Get2DmConversationsIdDmEventsResponse + */ + @Test + public void testGet2DmConversationsIdDmEventsResponse() { + // TODO: test Get2DmConversationsIdDmEventsResponse + } + + /** + * Test the property 'data' + */ + @Test + public void dataTest() { + // TODO: test data + } + + /** + * Test the property 'errors' + */ + @Test + public void errorsTest() { + // TODO: test errors + } + + /** + * Test the property 'includes' + */ + @Test + public void includesTest() { + // TODO: test includes + } + + /** + * Test the property 'meta' + */ + @Test + public void metaTest() { + // TODO: test meta + } + +} diff --git a/src/test/java/com/twitter/clientlib/model/Get2DmConversationsWithParticipantIdDmEventsResponseTest.java b/src/test/java/com/twitter/clientlib/model/Get2DmConversationsWithParticipantIdDmEventsResponseTest.java new file mode 100644 index 0000000..fe39564 --- /dev/null +++ b/src/test/java/com/twitter/clientlib/model/Get2DmConversationsWithParticipantIdDmEventsResponseTest.java @@ -0,0 +1,89 @@ +/* +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.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.twitter.clientlib.model.DmEvent; +import com.twitter.clientlib.model.Expansions; +import com.twitter.clientlib.model.Get2ListsIdFollowersResponseMeta; +import com.twitter.clientlib.model.Problem; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + + +/** + * Model tests for Get2DmConversationsWithParticipantIdDmEventsResponse + */ +public class Get2DmConversationsWithParticipantIdDmEventsResponseTest { + private final Get2DmConversationsWithParticipantIdDmEventsResponse model = new Get2DmConversationsWithParticipantIdDmEventsResponse(); + + /** + * Model tests for Get2DmConversationsWithParticipantIdDmEventsResponse + */ + @Test + public void testGet2DmConversationsWithParticipantIdDmEventsResponse() { + // TODO: test Get2DmConversationsWithParticipantIdDmEventsResponse + } + + /** + * Test the property 'data' + */ + @Test + public void dataTest() { + // TODO: test data + } + + /** + * Test the property 'errors' + */ + @Test + public void errorsTest() { + // TODO: test errors + } + + /** + * Test the property 'includes' + */ + @Test + public void includesTest() { + // TODO: test includes + } + + /** + * Test the property 'meta' + */ + @Test + public void metaTest() { + // TODO: test meta + } + +} diff --git a/src/test/java/com/twitter/clientlib/model/Get2DmEventsResponseTest.java b/src/test/java/com/twitter/clientlib/model/Get2DmEventsResponseTest.java new file mode 100644 index 0000000..fcdefbc --- /dev/null +++ b/src/test/java/com/twitter/clientlib/model/Get2DmEventsResponseTest.java @@ -0,0 +1,89 @@ +/* +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.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.twitter.clientlib.model.DmEvent; +import com.twitter.clientlib.model.Expansions; +import com.twitter.clientlib.model.Get2ListsIdFollowersResponseMeta; +import com.twitter.clientlib.model.Problem; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + + +/** + * Model tests for Get2DmEventsResponse + */ +public class Get2DmEventsResponseTest { + private final Get2DmEventsResponse model = new Get2DmEventsResponse(); + + /** + * Model tests for Get2DmEventsResponse + */ + @Test + public void testGet2DmEventsResponse() { + // TODO: test Get2DmEventsResponse + } + + /** + * Test the property 'data' + */ + @Test + public void dataTest() { + // TODO: test data + } + + /** + * Test the property 'errors' + */ + @Test + public void errorsTest() { + // TODO: test errors + } + + /** + * Test the property 'includes' + */ + @Test + public void includesTest() { + // TODO: test includes + } + + /** + * Test the property 'meta' + */ + @Test + public void metaTest() { + // TODO: test meta + } + +} diff --git a/src/test/java/com/twitter/clientlib/model/TweetCreateRequestTest.java b/src/test/java/com/twitter/clientlib/model/TweetCreateRequestTest.java index 7aaf86f..3ba1622 100644 --- a/src/test/java/com/twitter/clientlib/model/TweetCreateRequestTest.java +++ b/src/test/java/com/twitter/clientlib/model/TweetCreateRequestTest.java @@ -52,6 +52,14 @@ public void testTweetCreateRequest() { // TODO: test TweetCreateRequest } + /** + * Test the property 'cardUri' + */ + @Test + public void cardUriTest() { + // TODO: test cardUri + } + /** * Test the property 'directMessageDeepLink' */ @@ -84,6 +92,14 @@ public void mediaTest() { // TODO: test media } + /** + * Test the property 'nullcast' + */ + @Test + public void nullcastTest() { + // TODO: test nullcast + } + /** * Test the property 'poll' */ diff --git a/src/test/java/com/twitter/clientlib/model/TweetLabelDataTest.java b/src/test/java/com/twitter/clientlib/model/TweetLabelDataTest.java new file mode 100644 index 0000000..071279e --- /dev/null +++ b/src/test/java/com/twitter/clientlib/model/TweetLabelDataTest.java @@ -0,0 +1,71 @@ +/* +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.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.twitter.clientlib.model.TweetNotice; +import com.twitter.clientlib.model.TweetNoticeSchema; +import com.twitter.clientlib.model.TweetUnviewable; +import com.twitter.clientlib.model.TweetUnviewableSchema; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + + +/** + * Model tests for TweetLabelData + */ +public class TweetLabelDataTest { + private final TweetLabelData model = new TweetLabelData(); + + /** + * Model tests for TweetLabelData + */ + @Test + public void testTweetLabelData() { + // TODO: test TweetLabelData + } + + /** + * Test the property 'publicTweetNotice' + */ + @Test + public void publicTweetNoticeTest() { + // TODO: test publicTweetNotice + } + + /** + * Test the property 'publicTweetUnviewable' + */ + @Test + public void publicTweetUnviewableTest() { + // TODO: test publicTweetUnviewable + } + +} diff --git a/src/test/java/com/twitter/clientlib/model/ReportUsersResponseTest.java b/src/test/java/com/twitter/clientlib/model/TweetLabelStreamResponseOneOfTest.java similarity index 77% rename from src/test/java/com/twitter/clientlib/model/ReportUsersResponseTest.java rename to src/test/java/com/twitter/clientlib/model/TweetLabelStreamResponseOneOfTest.java index 7ede841..b68dc47 100644 --- a/src/test/java/com/twitter/clientlib/model/ReportUsersResponseTest.java +++ b/src/test/java/com/twitter/clientlib/model/TweetLabelStreamResponseOneOfTest.java @@ -27,7 +27,7 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.twitter.clientlib.model.ReportUsersResponseData; +import com.twitter.clientlib.model.TweetLabelData; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.io.IOException; @@ -36,17 +36,17 @@ /** - * Model tests for ReportUsersResponse + * Model tests for TweetLabelStreamResponseOneOf */ -public class ReportUsersResponseTest { - private final ReportUsersResponse model = new ReportUsersResponse(); +public class TweetLabelStreamResponseOneOfTest { + private final TweetLabelStreamResponseOneOf model = new TweetLabelStreamResponseOneOf(); /** - * Model tests for ReportUsersResponse + * Model tests for TweetLabelStreamResponseOneOf */ @Test - public void testReportUsersResponse() { - // TODO: test ReportUsersResponse + public void testTweetLabelStreamResponseOneOf() { + // TODO: test TweetLabelStreamResponseOneOf } /** diff --git a/src/test/java/com/twitter/clientlib/model/TweetLabelStreamResponseTest.java b/src/test/java/com/twitter/clientlib/model/TweetLabelStreamResponseTest.java new file mode 100644 index 0000000..b5abded --- /dev/null +++ b/src/test/java/com/twitter/clientlib/model/TweetLabelStreamResponseTest.java @@ -0,0 +1,73 @@ +/* +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.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.twitter.clientlib.model.Problem; +import com.twitter.clientlib.model.TweetComplianceStreamResponseOneOf1; +import com.twitter.clientlib.model.TweetLabelData; +import com.twitter.clientlib.model.TweetLabelStreamResponseOneOf; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + + +/** + * Model tests for TweetLabelStreamResponse + */ +public class TweetLabelStreamResponseTest { + private final TweetLabelStreamResponse model = new TweetLabelStreamResponse(); + + /** + * Model tests for TweetLabelStreamResponse + */ + @Test + public void testTweetLabelStreamResponse() { + // TODO: test TweetLabelStreamResponse + } + + /** + * Test the property 'data' + */ + @Test + public void dataTest() { + // TODO: test data + } + + /** + * Test the property 'errors' + */ + @Test + public void errorsTest() { + // TODO: test errors + } + +} diff --git a/src/test/java/com/twitter/clientlib/model/TweetNoticeSchemaTest.java b/src/test/java/com/twitter/clientlib/model/TweetNoticeSchemaTest.java new file mode 100644 index 0000000..86d37dc --- /dev/null +++ b/src/test/java/com/twitter/clientlib/model/TweetNoticeSchemaTest.java @@ -0,0 +1,60 @@ +/* +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.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.twitter.clientlib.model.TweetNotice; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + + +/** + * Model tests for TweetNoticeSchema + */ +public class TweetNoticeSchemaTest { + private final TweetNoticeSchema model = new TweetNoticeSchema(); + + /** + * Model tests for TweetNoticeSchema + */ + @Test + public void testTweetNoticeSchema() { + // TODO: test TweetNoticeSchema + } + + /** + * Test the property 'publicTweetNotice' + */ + @Test + public void publicTweetNoticeTest() { + // TODO: test publicTweetNotice + } + +} diff --git a/src/test/java/com/twitter/clientlib/model/TweetNoticeTest.java b/src/test/java/com/twitter/clientlib/model/TweetNoticeTest.java new file mode 100644 index 0000000..ab295b2 --- /dev/null +++ b/src/test/java/com/twitter/clientlib/model/TweetNoticeTest.java @@ -0,0 +1,109 @@ +/* +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.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.twitter.clientlib.model.TweetComplianceSchemaTweet; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + + +/** + * Model tests for TweetNotice + */ +public class TweetNoticeTest { + private final TweetNotice model = new TweetNotice(); + + /** + * Model tests for TweetNotice + */ + @Test + public void testTweetNotice() { + // TODO: test TweetNotice + } + + /** + * Test the property 'application' + */ + @Test + public void applicationTest() { + // TODO: test application + } + + /** + * Test the property 'details' + */ + @Test + public void detailsTest() { + // TODO: test details + } + + /** + * Test the property 'eventAt' + */ + @Test + public void eventAtTest() { + // TODO: test eventAt + } + + /** + * Test the property 'eventType' + */ + @Test + public void eventTypeTest() { + // TODO: test eventType + } + + /** + * Test the property 'extendedDetailsUrl' + */ + @Test + public void extendedDetailsUrlTest() { + // TODO: test extendedDetailsUrl + } + + /** + * Test the property 'labelTitle' + */ + @Test + public void labelTitleTest() { + // TODO: test labelTitle + } + + /** + * Test the property 'tweet' + */ + @Test + public void tweetTest() { + // TODO: test tweet + } + +} diff --git a/src/test/java/com/twitter/clientlib/model/TweetUnviewableSchemaTest.java b/src/test/java/com/twitter/clientlib/model/TweetUnviewableSchemaTest.java new file mode 100644 index 0000000..fa97d76 --- /dev/null +++ b/src/test/java/com/twitter/clientlib/model/TweetUnviewableSchemaTest.java @@ -0,0 +1,60 @@ +/* +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.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.twitter.clientlib.model.TweetUnviewable; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + + +/** + * Model tests for TweetUnviewableSchema + */ +public class TweetUnviewableSchemaTest { + private final TweetUnviewableSchema model = new TweetUnviewableSchema(); + + /** + * Model tests for TweetUnviewableSchema + */ + @Test + public void testTweetUnviewableSchema() { + // TODO: test TweetUnviewableSchema + } + + /** + * Test the property 'publicTweetUnviewable' + */ + @Test + public void publicTweetUnviewableTest() { + // TODO: test publicTweetUnviewable + } + +} diff --git a/src/test/java/com/twitter/clientlib/model/TweetUnviewableTest.java b/src/test/java/com/twitter/clientlib/model/TweetUnviewableTest.java new file mode 100644 index 0000000..ebdc685 --- /dev/null +++ b/src/test/java/com/twitter/clientlib/model/TweetUnviewableTest.java @@ -0,0 +1,77 @@ +/* +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.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.twitter.clientlib.model.TweetComplianceSchemaTweet; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + + +/** + * Model tests for TweetUnviewable + */ +public class TweetUnviewableTest { + private final TweetUnviewable model = new TweetUnviewable(); + + /** + * Model tests for TweetUnviewable + */ + @Test + public void testTweetUnviewable() { + // TODO: test TweetUnviewable + } + + /** + * Test the property 'application' + */ + @Test + public void applicationTest() { + // TODO: test application + } + + /** + * Test the property 'eventAt' + */ + @Test + public void eventAtTest() { + // TODO: test eventAt + } + + /** + * Test the property 'tweet' + */ + @Test + public void tweetTest() { + // TODO: test tweet + } + +}