diff --git a/README.md b/README.md index f79c2fd..6540e87 100644 --- a/README.md +++ b/README.md @@ -37,21 +37,21 @@ Then add the dependencies you need: com.fastcomments client - 3.1.0 + 3.1.1 com.fastcomments core - 3.1.0 + 3.1.1 com.fastcomments pubsub - 3.1.0 + 3.1.1 ``` @@ -70,13 +70,13 @@ repositories { dependencies { // API Client - implementation "com.fastcomments:client:3.1.0" + implementation "com.fastcomments:client:3.1.1" // Core Library (includes SSO) - implementation "com.fastcomments:core:3.1.0" + implementation "com.fastcomments:core:3.1.1" // PubSub Library (for live events) - implementation "com.fastcomments:pubsub:3.1.0" + implementation "com.fastcomments:pubsub:3.1.1" } ``` diff --git a/client/.openapi-generator/FILES b/client/.openapi-generator/FILES index 0b97f8a..23f278f 100644 --- a/client/.openapi-generator/FILES +++ b/client/.openapi-generator/FILES @@ -210,6 +210,7 @@ docs/GetPendingWebhookEventCountResponse.md docs/GetPendingWebhookEventsResponse.md docs/GetPollResponse.md docs/GetPollVoteResponse.md +docs/GetPollVoterNamesSuccessResponse.md docs/GetPollVotesResponse.md docs/GetPublicFeedPostsResponse.md docs/GetPublicPagesResponse.md @@ -312,6 +313,7 @@ docs/PendingCommentToSyncOutbound.md docs/PickCommentPollOptionsOrTotalVotesOrClosesAt.md docs/PollCreationMode.md docs/PollPrivacy.md +docs/PollVoterEntry.md docs/PollVotingMode.md docs/PostRemoveCommentApiResponse.md docs/PreBanSummary.md @@ -420,6 +422,8 @@ docs/UserSessionInfo.md docs/UsersListLocation.md docs/VoteBodyParams.md docs/VoteDeleteResponse.md +docs/VotePollBody.md +docs/VotePollResponse.md docs/VoteResponse.md docs/VoteResponseUser.md docs/VoteStyle.md @@ -661,6 +665,7 @@ src/main/java/com/fastcomments/model/GetPendingWebhookEventCountResponse.java src/main/java/com/fastcomments/model/GetPendingWebhookEventsResponse.java src/main/java/com/fastcomments/model/GetPollResponse.java src/main/java/com/fastcomments/model/GetPollVoteResponse.java +src/main/java/com/fastcomments/model/GetPollVoterNamesSuccessResponse.java src/main/java/com/fastcomments/model/GetPollVotesResponse.java src/main/java/com/fastcomments/model/GetPublicFeedPostsResponse.java src/main/java/com/fastcomments/model/GetPublicPagesResponse.java @@ -762,6 +767,7 @@ src/main/java/com/fastcomments/model/PendingCommentToSyncOutbound.java src/main/java/com/fastcomments/model/PickCommentPollOptionsOrTotalVotesOrClosesAt.java src/main/java/com/fastcomments/model/PollCreationMode.java src/main/java/com/fastcomments/model/PollPrivacy.java +src/main/java/com/fastcomments/model/PollVoterEntry.java src/main/java/com/fastcomments/model/PollVotingMode.java src/main/java/com/fastcomments/model/PostRemoveCommentApiResponse.java src/main/java/com/fastcomments/model/PreBanSummary.java @@ -869,6 +875,8 @@ src/main/java/com/fastcomments/model/UserSessionInfo.java src/main/java/com/fastcomments/model/UsersListLocation.java src/main/java/com/fastcomments/model/VoteBodyParams.java src/main/java/com/fastcomments/model/VoteDeleteResponse.java +src/main/java/com/fastcomments/model/VotePollBody.java +src/main/java/com/fastcomments/model/VotePollResponse.java src/main/java/com/fastcomments/model/VoteResponse.java src/main/java/com/fastcomments/model/VoteResponseUser.java src/main/java/com/fastcomments/model/VoteStyle.java @@ -1083,6 +1091,7 @@ src/test/java/com/fastcomments/model/GetPendingWebhookEventCountResponseTest.jav src/test/java/com/fastcomments/model/GetPendingWebhookEventsResponseTest.java src/test/java/com/fastcomments/model/GetPollResponseTest.java src/test/java/com/fastcomments/model/GetPollVoteResponseTest.java +src/test/java/com/fastcomments/model/GetPollVoterNamesSuccessResponseTest.java src/test/java/com/fastcomments/model/GetPollVotesResponseTest.java src/test/java/com/fastcomments/model/GetPublicFeedPostsResponseTest.java src/test/java/com/fastcomments/model/GetPublicPagesResponseTest.java @@ -1184,6 +1193,7 @@ src/test/java/com/fastcomments/model/PendingCommentToSyncOutboundTest.java src/test/java/com/fastcomments/model/PickCommentPollOptionsOrTotalVotesOrClosesAtTest.java src/test/java/com/fastcomments/model/PollCreationModeTest.java src/test/java/com/fastcomments/model/PollPrivacyTest.java +src/test/java/com/fastcomments/model/PollVoterEntryTest.java src/test/java/com/fastcomments/model/PollVotingModeTest.java src/test/java/com/fastcomments/model/PostRemoveCommentApiResponseTest.java src/test/java/com/fastcomments/model/PreBanSummaryTest.java @@ -1291,6 +1301,8 @@ src/test/java/com/fastcomments/model/UserTest.java src/test/java/com/fastcomments/model/UsersListLocationTest.java src/test/java/com/fastcomments/model/VoteBodyParamsTest.java src/test/java/com/fastcomments/model/VoteDeleteResponseTest.java +src/test/java/com/fastcomments/model/VotePollBodyTest.java +src/test/java/com/fastcomments/model/VotePollResponseTest.java src/test/java/com/fastcomments/model/VoteResponseTest.java src/test/java/com/fastcomments/model/VoteResponseUserTest.java src/test/java/com/fastcomments/model/VoteStyleTest.java diff --git a/client/README.md b/client/README.md index 5bf4402..fab1d76 100644 --- a/client/README.md +++ b/client/README.md @@ -40,7 +40,7 @@ Add this dependency to your project's POM: com.fastcomments client - 3.1.0 + 3.1.1 compile ``` @@ -56,7 +56,7 @@ Add this dependency to your project's build file: } dependencies { - implementation "com.fastcomments:client:3.1.0" + implementation "com.fastcomments:client:3.1.1" } ``` @@ -70,7 +70,7 @@ mvn clean package Then manually install the following JARs: -* `target/client-3.1.0.jar` +* `target/client-3.1.1.jar` * `target/lib/*.jar` ## Getting Started @@ -326,6 +326,7 @@ Class | Method | HTTP request | Description *PublicApi* | [**getOfflineUsers**](docs/PublicApi.md#getOfflineUsers) | **GET** /pages/{tenantId}/users/offline | *PublicApi* | [**getOnlineUsers**](docs/PublicApi.md#getOnlineUsers) | **GET** /pages/{tenantId}/users/online | *PublicApi* | [**getPagesPublic**](docs/PublicApi.md#getPagesPublic) | **GET** /pages/{tenantId} | +*PublicApi* | [**getPollVoters**](docs/PublicApi.md#getPollVoters) | **GET** /polls/{tenantId}/{commentId}/voters | *PublicApi* | [**getTranslations**](docs/PublicApi.md#getTranslations) | **GET** /translations/{namespace}/{component} | *PublicApi* | [**getUserNotificationCount**](docs/PublicApi.md#getUserNotificationCount) | **GET** /user-notifications/get-count | *PublicApi* | [**getUserNotifications**](docs/PublicApi.md#getUserNotifications) | **GET** /user-notifications | @@ -353,6 +354,7 @@ Class | Method | HTTP request | Description *PublicApi* | [**updateUserNotificationStatus**](docs/PublicApi.md#updateUserNotificationStatus) | **POST** /user-notifications/{notificationId}/mark/{newStatus} | *PublicApi* | [**uploadImage**](docs/PublicApi.md#uploadImage) | **POST** /upload-image/{tenantId} | *PublicApi* | [**voteComment**](docs/PublicApi.md#voteComment) | **POST** /comments/{tenantId}/{commentId}/vote | +*PublicApi* | [**votePoll**](docs/PublicApi.md#votePoll) | **PUT** /polls/{tenantId}/{commentId}/vote | ## Documentation for Models @@ -561,6 +563,7 @@ Class | Method | HTTP request | Description - [GetPendingWebhookEventsResponse](docs/GetPendingWebhookEventsResponse.md) - [GetPollResponse](docs/GetPollResponse.md) - [GetPollVoteResponse](docs/GetPollVoteResponse.md) + - [GetPollVoterNamesSuccessResponse](docs/GetPollVoterNamesSuccessResponse.md) - [GetPollVotesResponse](docs/GetPollVotesResponse.md) - [GetPublicFeedPostsResponse](docs/GetPublicFeedPostsResponse.md) - [GetPublicPagesResponse](docs/GetPublicPagesResponse.md) @@ -662,6 +665,7 @@ Class | Method | HTTP request | Description - [PickCommentPollOptionsOrTotalVotesOrClosesAt](docs/PickCommentPollOptionsOrTotalVotesOrClosesAt.md) - [PollCreationMode](docs/PollCreationMode.md) - [PollPrivacy](docs/PollPrivacy.md) + - [PollVoterEntry](docs/PollVoterEntry.md) - [PollVotingMode](docs/PollVotingMode.md) - [PostRemoveCommentApiResponse](docs/PostRemoveCommentApiResponse.md) - [PreBanSummary](docs/PreBanSummary.md) @@ -769,6 +773,8 @@ Class | Method | HTTP request | Description - [UsersListLocation](docs/UsersListLocation.md) - [VoteBodyParams](docs/VoteBodyParams.md) - [VoteDeleteResponse](docs/VoteDeleteResponse.md) + - [VotePollBody](docs/VotePollBody.md) + - [VotePollResponse](docs/VotePollResponse.md) - [VoteResponse](docs/VoteResponse.md) - [VoteResponseUser](docs/VoteResponseUser.md) - [VoteStyle](docs/VoteStyle.md) diff --git a/client/api/openapi.yaml b/client/api/openapi.yaml index 102d1d8..2d73d98 100644 --- a/client/api/openapi.yaml +++ b/client/api/openapi.yaml @@ -935,6 +935,137 @@ paths: - Public x-accepts: - application/json + /polls/{tenantId}/{commentId}/vote: + put: + operationId: VotePoll + parameters: + - explode: false + in: path + name: tenantId + required: true + schema: + type: string + style: simple + - explode: false + in: path + name: commentId + required: true + schema: + type: string + style: simple + - explode: true + in: query + name: urlId + required: false + schema: + type: string + style: form + - explode: true + in: query + name: broadcastId + required: false + schema: + type: string + style: form + - explode: true + in: query + name: sso + required: false + schema: + type: string + style: form + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/VotePollBody" + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/VotePollResponse" + description: Ok + default: + content: + application/json: + schema: + $ref: "#/components/schemas/APIError" + description: Error + security: [] + tags: + - Public + x-content-type: application/json + x-accepts: + - application/json + /polls/{tenantId}/{commentId}/voters: + get: + description: "Who voted for which option. Anonymous polls never answer, admins-only\ + \ polls answer only for an admin or moderator." + operationId: GetPollVoters + parameters: + - explode: false + in: path + name: tenantId + required: true + schema: + type: string + style: simple + - explode: false + in: path + name: commentId + required: true + schema: + type: string + style: simple + - explode: true + in: query + name: urlId + required: false + schema: + type: string + style: form + - explode: true + in: query + name: page + required: false + schema: + format: int32 + type: integer + style: form + - explode: true + in: query + name: search + required: false + schema: + type: string + style: form + - explode: true + in: query + name: sso + required: false + schema: + type: string + style: form + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/GetPollVoterNamesSuccessResponse" + description: Ok + default: + content: + application/json: + schema: + $ref: "#/components/schemas/APIError" + description: Error + security: [] + tags: + - Public + x-accepts: + - application/json /page-reacts/v1/likes/{tenantId}: delete: operationId: DeleteV1PageReact @@ -12663,6 +12794,179 @@ components: - status - users type: object + CommentPollOption: + additionalProperties: false + example: + votes: 0 + id: id + label: label + properties: + id: + type: string + label: + type: string + votes: + format: int32 + type: integer + required: + - id + - label + - votes + type: object + PollPrivacy: + description: |- + Who may see which voter picked which option. Chosen by the poll's author when they build the poll, so it + lives on the poll itself rather than in the widget config. Anonymous is the default and is never stored on + the poll or sent to the client, so an unset value means Anonymous. + enum: + - 0 + - 1 + - 2 + type: integer + CommentPoll: + additionalProperties: false + description: A poll attached to a comment. Vote counts are denormalized here; + individual votes live in PollVote. + example: + question: question + totalVotes: 6 + options: + - votes: 0 + id: id + label: label + - votes: 0 + id: id + label: label + privacy: "" + closesAt: 2000-01-23T04:56:07.000+00:00 + requireVoteToSeeResults: true + properties: + question: + type: string + options: + items: + $ref: "#/components/schemas/CommentPollOption" + type: array + totalVotes: + format: int32 + type: integer + closesAt: + format: date-time + nullable: true + type: string + privacy: + allOf: + - $ref: "#/components/schemas/PollPrivacy" + nullable: true + requireVoteToSeeResults: + nullable: true + type: boolean + required: + - options + - question + - totalVotes + type: object + VotePollResponse: + additionalProperties: false + example: + myPollVotes: + - myPollVotes + - myPollVotes + voterId: voterId + poll: + question: question + totalVotes: 6 + options: + - votes: 0 + id: id + label: label + - votes: 0 + id: id + label: label + privacy: "" + closesAt: 2000-01-23T04:56:07.000+00:00 + requireVoteToSeeResults: true + status: success + properties: + status: + $ref: "#/components/schemas/APIStatus" + poll: + $ref: "#/components/schemas/CommentPoll" + myPollVotes: + items: + type: string + type: array + voterId: + type: string + required: + - myPollVotes + - poll + - status + - voterId + type: object + VotePollBody: + additionalProperties: false + example: + optionId: optionId + properties: + optionId: + type: string + required: + - optionId + type: object + PollVoterEntry: + additionalProperties: false + example: + optionLabel: optionLabel + name: name + properties: + name: + type: string + optionLabel: + type: string + required: + - name + - optionLabel + type: object + GetPollVoterNamesSuccessResponse: + additionalProperties: false + example: + total: 1 + voters: + - optionLabel: optionLabel + name: name + - optionLabel: optionLabel + name: name + hasMore: true + pageSize: 6 + page: 0 + status: success + properties: + status: + $ref: "#/components/schemas/APIStatus" + voters: + items: + $ref: "#/components/schemas/PollVoterEntry" + type: array + page: + format: int32 + type: integer + pageSize: + format: int32 + type: integer + total: + format: int32 + type: integer + hasMore: + type: boolean + required: + - hasMore + - page + - pageSize + - status + - total + - voters + type: object PageReactUser: example: displayName: displayName @@ -15929,78 +16233,6 @@ components: - urlIdRaw - verificationId type: object - CommentPollOption: - additionalProperties: false - example: - votes: 0 - id: id - label: label - properties: - id: - type: string - label: - type: string - votes: - format: int32 - type: integer - required: - - id - - label - - votes - type: object - PollPrivacy: - description: |- - Who may see which voter picked which option. Chosen by the poll's author when they build the poll, so it - lives on the poll itself rather than in the widget config. Anonymous is the default and is never stored on - the poll or sent to the client, so an unset value means Anonymous. - enum: - - 0 - - 1 - - 2 - type: integer - CommentPoll: - additionalProperties: false - description: A poll attached to a comment. Vote counts are denormalized here; - individual votes live in PollVote. - example: - question: question - totalVotes: 6 - options: - - votes: 0 - id: id - label: label - - votes: 0 - id: id - label: label - privacy: "" - closesAt: 2000-01-23T04:56:07.000+00:00 - requireVoteToSeeResults: true - properties: - question: - type: string - options: - items: - $ref: "#/components/schemas/CommentPollOption" - type: array - totalVotes: - format: int32 - type: integer - closesAt: - format: date-time - nullable: true - type: string - privacy: - allOf: - - $ref: "#/components/schemas/PollPrivacy" - nullable: true - requireVoteToSeeResults: - nullable: true - type: boolean - required: - - options - - question - - totalVotes - type: object FDomain: type: string PubSubCommentBase: @@ -16443,6 +16675,7 @@ components: rating: 7.061401241503109 commenterLink: commenterLink isVotedDown: true + poll: "" commentHTML: commentHTML approved: true isDeleted: true @@ -16575,6 +16808,10 @@ components: items: type: string type: array + poll: + allOf: + - $ref: "#/components/schemas/CommentPoll" + nullable: true requiresVerification: type: boolean editKey: @@ -16812,6 +17049,7 @@ components: rating: 7.061401241503109 commenterLink: commenterLink isVotedDown: true + poll: "" commentHTML: commentHTML approved: true isDeleted: true @@ -16876,6 +17114,7 @@ components: rating: 7.061401241503109 commenterLink: commenterLink isVotedDown: true + poll: "" commentHTML: commentHTML approved: true isDeleted: true @@ -16985,6 +17224,7 @@ components: rating: 7.061401241503109 commenterLink: commenterLink isVotedDown: true + poll: "" commentHTML: commentHTML approved: true isDeleted: true diff --git a/client/build.gradle b/client/build.gradle index c7efbfd..2eaff38 100644 --- a/client/build.gradle +++ b/client/build.gradle @@ -4,7 +4,7 @@ apply plugin: 'java' apply plugin: 'com.diffplug.spotless' group = 'com.fastcomments' -version = '3.1.0' +version = '3.1.1' buildscript { repositories { diff --git a/client/build.sbt b/client/build.sbt index ef4427f..154c40b 100644 --- a/client/build.sbt +++ b/client/build.sbt @@ -2,7 +2,7 @@ lazy val root = (project in file(".")). settings( organization := "com.fastcomments", name := "client", - version := "3.1.0", + version := "3.1.1", scalaVersion := "2.11.12", scalacOptions ++= Seq("-feature"), compile / javacOptions ++= Seq("-Xlint:deprecation"), diff --git a/client/docs/GetPollVoterNamesSuccessResponse.md b/client/docs/GetPollVoterNamesSuccessResponse.md new file mode 100644 index 0000000..4169b54 --- /dev/null +++ b/client/docs/GetPollVoterNamesSuccessResponse.md @@ -0,0 +1,18 @@ + + +# GetPollVoterNamesSuccessResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**status** | **APIStatus** | | | +|**voters** | [**List<PollVoterEntry>**](PollVoterEntry.md) | | | +|**page** | **Integer** | | | +|**pageSize** | **Integer** | | | +|**total** | **Integer** | | | +|**hasMore** | **Boolean** | | | + + + diff --git a/client/docs/PollVoterEntry.md b/client/docs/PollVoterEntry.md new file mode 100644 index 0000000..af8642c --- /dev/null +++ b/client/docs/PollVoterEntry.md @@ -0,0 +1,14 @@ + + +# PollVoterEntry + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**name** | **String** | | | +|**optionLabel** | **String** | | | + + + diff --git a/client/docs/PublicApi.md b/client/docs/PublicApi.md index b003389..d0b921e 100644 --- a/client/docs/PublicApi.md +++ b/client/docs/PublicApi.md @@ -31,6 +31,7 @@ All URIs are relative to *https://fastcomments.com* | [**getOfflineUsers**](PublicApi.md#getOfflineUsers) | **GET** /pages/{tenantId}/users/offline | | | [**getOnlineUsers**](PublicApi.md#getOnlineUsers) | **GET** /pages/{tenantId}/users/online | | | [**getPagesPublic**](PublicApi.md#getPagesPublic) | **GET** /pages/{tenantId} | | +| [**getPollVoters**](PublicApi.md#getPollVoters) | **GET** /polls/{tenantId}/{commentId}/voters | | | [**getTranslations**](PublicApi.md#getTranslations) | **GET** /translations/{namespace}/{component} | | | [**getUserNotificationCount**](PublicApi.md#getUserNotificationCount) | **GET** /user-notifications/get-count | | | [**getUserNotifications**](PublicApi.md#getUserNotifications) | **GET** /user-notifications | | @@ -58,6 +59,7 @@ All URIs are relative to *https://fastcomments.com* | [**updateUserNotificationStatus**](PublicApi.md#updateUserNotificationStatus) | **POST** /user-notifications/{notificationId}/mark/{newStatus} | | | [**uploadImage**](PublicApi.md#uploadImage) | **POST** /upload-image/{tenantId} | | | [**voteComment**](PublicApi.md#voteComment) | **POST** /comments/{tenantId}/{commentId}/vote | | +| [**votePoll**](PublicApi.md#votePoll) | **PUT** /polls/{tenantId}/{commentId}/vote | | @@ -2009,6 +2011,84 @@ No authorization required | **200** | Ok | - | | **0** | Error | - | + +# **getPollVoters** +> GetPollVoterNamesSuccessResponse getPollVoters(tenantId, commentId).urlId(urlId).page(page).search(search).sso(sso).execute(); + + + +Who voted for which option. Anonymous polls never answer, admins-only polls answer only for an admin or moderator. + +### Example +```java +// Import classes: +import com.fastcomments.invoker.ApiClient; +import com.fastcomments.invoker.ApiException; +import com.fastcomments.invoker.Configuration; +import com.fastcomments.invoker.models.*; +import com.fastcomments.api.PublicApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://fastcomments.com"); + + PublicApi apiInstance = new PublicApi(defaultClient); + String tenantId = "tenantId_example"; // String | + String commentId = "commentId_example"; // String | + String urlId = "urlId_example"; // String | + Integer page = 56; // Integer | + String search = "search_example"; // String | + String sso = "sso_example"; // String | + try { + GetPollVoterNamesSuccessResponse result = apiInstance.getPollVoters(tenantId, commentId) + .urlId(urlId) + .page(page) + .search(search) + .sso(sso) + .execute(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PublicApi#getPollVoters"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **tenantId** | **String**| | | +| **commentId** | **String**| | | +| **urlId** | **String**| | [optional] | +| **page** | **Integer**| | [optional] | +| **search** | **String**| | [optional] | +| **sso** | **String**| | [optional] | + +### Return type + +[**GetPollVoterNamesSuccessResponse**](GetPollVoterNamesSuccessResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Ok | - | +| **0** | Error | - | + # **getTranslations** > GetTranslationsResponse getTranslations(namespace, component).locale(locale).useFullTranslationIds(useFullTranslationIds).execute(); @@ -3934,3 +4014,78 @@ No authorization required | **200** | Ok | - | | **0** | Error | - | + +# **votePoll** +> VotePollResponse votePoll(tenantId, commentId, votePollBody).urlId(urlId).broadcastId(broadcastId).sso(sso).execute(); + + + +### Example +```java +// Import classes: +import com.fastcomments.invoker.ApiClient; +import com.fastcomments.invoker.ApiException; +import com.fastcomments.invoker.Configuration; +import com.fastcomments.invoker.models.*; +import com.fastcomments.api.PublicApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://fastcomments.com"); + + PublicApi apiInstance = new PublicApi(defaultClient); + String tenantId = "tenantId_example"; // String | + String commentId = "commentId_example"; // String | + VotePollBody votePollBody = new VotePollBody(); // VotePollBody | + String urlId = "urlId_example"; // String | + String broadcastId = "broadcastId_example"; // String | + String sso = "sso_example"; // String | + try { + VotePollResponse result = apiInstance.votePoll(tenantId, commentId, votePollBody) + .urlId(urlId) + .broadcastId(broadcastId) + .sso(sso) + .execute(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PublicApi#votePoll"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **tenantId** | **String**| | | +| **commentId** | **String**| | | +| **votePollBody** | [**VotePollBody**](VotePollBody.md)| | | +| **urlId** | **String**| | [optional] | +| **broadcastId** | **String**| | [optional] | +| **sso** | **String**| | [optional] | + +### Return type + +[**VotePollResponse**](VotePollResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Ok | - | +| **0** | Error | - | + diff --git a/client/docs/PublicComment.md b/client/docs/PublicComment.md index 81124b0..a9016af 100644 --- a/client/docs/PublicComment.md +++ b/client/docs/PublicComment.md @@ -33,6 +33,7 @@ |**isSpam** | **Boolean** | | [optional] | |**anonUserId** | **String** | | [optional] | |**feedbackIds** | **List<String>** | | [optional] | +|**poll** | [**CommentPoll**](CommentPoll.md) | | [optional] | |**requiresVerification** | **Boolean** | | [optional] | |**editKey** | **String** | | [optional] | |**approved** | **Boolean** | | [optional] | diff --git a/client/docs/PublicCommentBase.md b/client/docs/PublicCommentBase.md index bd29691..cbfea15 100644 --- a/client/docs/PublicCommentBase.md +++ b/client/docs/PublicCommentBase.md @@ -33,6 +33,7 @@ |**isSpam** | **Boolean** | | [optional] | |**anonUserId** | **String** | | [optional] | |**feedbackIds** | **List<String>** | | [optional] | +|**poll** | [**CommentPoll**](CommentPoll.md) | | [optional] | |**requiresVerification** | **Boolean** | | [optional] | |**editKey** | **String** | | [optional] | |**approved** | **Boolean** | | [optional] | diff --git a/client/docs/VotePollBody.md b/client/docs/VotePollBody.md new file mode 100644 index 0000000..4cb8acf --- /dev/null +++ b/client/docs/VotePollBody.md @@ -0,0 +1,13 @@ + + +# VotePollBody + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**optionId** | **String** | | | + + + diff --git a/client/docs/VotePollResponse.md b/client/docs/VotePollResponse.md new file mode 100644 index 0000000..ae63cfc --- /dev/null +++ b/client/docs/VotePollResponse.md @@ -0,0 +1,16 @@ + + +# VotePollResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**status** | **APIStatus** | | | +|**poll** | [**CommentPoll**](CommentPoll.md) | | | +|**myPollVotes** | **List<String>** | | | +|**voterId** | **String** | | | + + + diff --git a/client/pom.xml b/client/pom.xml index 97686aa..e479ab4 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -5,7 +5,7 @@ client jar client - 3.1.0 + 3.1.1 https://fastcomments.com FastComments API Client - A SDK for interacting with the FastComments API diff --git a/client/src/main/java/com/fastcomments/api/PublicApi.java b/client/src/main/java/com/fastcomments/api/PublicApi.java index 8c7b8e8..54058ab 100644 --- a/client/src/main/java/com/fastcomments/api/PublicApi.java +++ b/client/src/main/java/com/fastcomments/api/PublicApi.java @@ -49,6 +49,7 @@ import com.fastcomments.model.GetGifsSearchResponse; import com.fastcomments.model.GetGifsTrendingResponse; import com.fastcomments.model.GetMyNotificationsResponse; +import com.fastcomments.model.GetPollVoterNamesSuccessResponse; import com.fastcomments.model.GetPublicPagesResponse; import com.fastcomments.model.GetTranslationsResponse; import com.fastcomments.model.GetUserNotificationCountResponse; @@ -83,6 +84,8 @@ import com.fastcomments.model.UserReactsResponse; import com.fastcomments.model.VoteBodyParams; import com.fastcomments.model.VoteDeleteResponse; +import com.fastcomments.model.VotePollBody; +import com.fastcomments.model.VotePollResponse; import com.fastcomments.model.VoteResponse; import java.lang.reflect.Type; @@ -6150,6 +6153,243 @@ public okhttp3.Call executeAsync(final ApiCallback _call public APIgetPagesPublicRequest getPagesPublic(@javax.annotation.Nonnull String tenantId) { return new APIgetPagesPublicRequest(tenantId); } + private okhttp3.Call getPollVotersCall(@javax.annotation.Nonnull String tenantId, @javax.annotation.Nonnull String commentId, @javax.annotation.Nullable String urlId, @javax.annotation.Nullable Integer page, @javax.annotation.Nullable String search, @javax.annotation.Nullable String sso, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/polls/{tenantId}/{commentId}/voters" + .replace("{" + "tenantId" + "}", localVarApiClient.escapeString(tenantId.toString())) + .replace("{" + "commentId" + "}", localVarApiClient.escapeString(commentId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (urlId != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("urlId", urlId)); + } + + if (page != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("page", page)); + } + + if (search != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("search", search)); + } + + if (sso != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("sso", sso)); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getPollVotersValidateBeforeCall(@javax.annotation.Nonnull String tenantId, @javax.annotation.Nonnull String commentId, @javax.annotation.Nullable String urlId, @javax.annotation.Nullable Integer page, @javax.annotation.Nullable String search, @javax.annotation.Nullable String sso, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'tenantId' is set + if (tenantId == null) { + throw new ApiException("Missing the required parameter 'tenantId' when calling getPollVoters(Async)"); + } + + // verify the required parameter 'commentId' is set + if (commentId == null) { + throw new ApiException("Missing the required parameter 'commentId' when calling getPollVoters(Async)"); + } + + return getPollVotersCall(tenantId, commentId, urlId, page, search, sso, _callback); + + } + + + private ApiResponse getPollVotersWithHttpInfo(@javax.annotation.Nonnull String tenantId, @javax.annotation.Nonnull String commentId, @javax.annotation.Nullable String urlId, @javax.annotation.Nullable Integer page, @javax.annotation.Nullable String search, @javax.annotation.Nullable String sso) throws ApiException { + okhttp3.Call localVarCall = getPollVotersValidateBeforeCall(tenantId, commentId, urlId, page, search, sso, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + private okhttp3.Call getPollVotersAsync(@javax.annotation.Nonnull String tenantId, @javax.annotation.Nonnull String commentId, @javax.annotation.Nullable String urlId, @javax.annotation.Nullable Integer page, @javax.annotation.Nullable String search, @javax.annotation.Nullable String sso, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getPollVotersValidateBeforeCall(tenantId, commentId, urlId, page, search, sso, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + public class APIgetPollVotersRequest { + @javax.annotation.Nonnull + private final String tenantId; + @javax.annotation.Nonnull + private final String commentId; + @javax.annotation.Nullable + private String urlId; + @javax.annotation.Nullable + private Integer page; + @javax.annotation.Nullable + private String search; + @javax.annotation.Nullable + private String sso; + + private APIgetPollVotersRequest(@javax.annotation.Nonnull String tenantId, @javax.annotation.Nonnull String commentId) { + this.tenantId = tenantId; + this.commentId = commentId; + } + + /** + * Set urlId + * @param urlId (optional) + * @return APIgetPollVotersRequest + */ + public APIgetPollVotersRequest urlId(@javax.annotation.Nullable String urlId) { + this.urlId = urlId; + return this; + } + + /** + * Set page + * @param page (optional) + * @return APIgetPollVotersRequest + */ + public APIgetPollVotersRequest page(@javax.annotation.Nullable Integer page) { + this.page = page; + return this; + } + + /** + * Set search + * @param search (optional) + * @return APIgetPollVotersRequest + */ + public APIgetPollVotersRequest search(@javax.annotation.Nullable String search) { + this.search = search; + return this; + } + + /** + * Set sso + * @param sso (optional) + * @return APIgetPollVotersRequest + */ + public APIgetPollVotersRequest sso(@javax.annotation.Nullable String sso) { + this.sso = sso; + return this; + } + + /** + * Build call for getPollVoters + * @param _callback ApiCallback API callback + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Ok -
0 Error -
+ */ + public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException { + return getPollVotersCall(tenantId, commentId, urlId, page, search, sso, _callback); + } + + /** + * Execute getPollVoters request + * @return GetPollVoterNamesSuccessResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Ok -
0 Error -
+ */ + public GetPollVoterNamesSuccessResponse execute() throws ApiException { + ApiResponse localVarResp = getPollVotersWithHttpInfo(tenantId, commentId, urlId, page, search, sso); + return localVarResp.getData(); + } + + /** + * Execute getPollVoters request with HTTP info returned + * @return ApiResponse<GetPollVoterNamesSuccessResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Ok -
0 Error -
+ */ + public ApiResponse executeWithHttpInfo() throws ApiException { + return getPollVotersWithHttpInfo(tenantId, commentId, urlId, page, search, sso); + } + + /** + * Execute getPollVoters 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 + + + + + +
Response Details
Status Code Description Response Headers
200 Ok -
0 Error -
+ */ + public okhttp3.Call executeAsync(final ApiCallback _callback) throws ApiException { + return getPollVotersAsync(tenantId, commentId, urlId, page, search, sso, _callback); + } + } + + /** + * + * Who voted for which option. Anonymous polls never answer, admins-only polls answer only for an admin or moderator. + * @param tenantId (required) + * @param commentId (required) + * @return APIgetPollVotersRequest + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Ok -
0 Error -
+ */ + public APIgetPollVotersRequest getPollVoters(@javax.annotation.Nonnull String tenantId, @javax.annotation.Nonnull String commentId) { + return new APIgetPollVotersRequest(tenantId, commentId); + } private okhttp3.Call getTranslationsCall(@javax.annotation.Nonnull String namespace, @javax.annotation.Nonnull String component, @javax.annotation.Nullable String locale, @javax.annotation.Nullable Boolean useFullTranslationIds, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers @@ -11910,4 +12150,235 @@ public okhttp3.Call executeAsync(final ApiCallback _callback) thro public APIvoteCommentRequest voteComment(@javax.annotation.Nonnull String tenantId, @javax.annotation.Nonnull String commentId, @javax.annotation.Nonnull String urlId, @javax.annotation.Nonnull String broadcastId, @javax.annotation.Nonnull VoteBodyParams voteBodyParams) { return new APIvoteCommentRequest(tenantId, commentId, urlId, broadcastId, voteBodyParams); } + private okhttp3.Call votePollCall(@javax.annotation.Nonnull String tenantId, @javax.annotation.Nonnull String commentId, @javax.annotation.Nonnull VotePollBody votePollBody, @javax.annotation.Nullable String urlId, @javax.annotation.Nullable String broadcastId, @javax.annotation.Nullable String sso, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = votePollBody; + + // create path and map variables + String localVarPath = "/polls/{tenantId}/{commentId}/vote" + .replace("{" + "tenantId" + "}", localVarApiClient.escapeString(tenantId.toString())) + .replace("{" + "commentId" + "}", localVarApiClient.escapeString(commentId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (urlId != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("urlId", urlId)); + } + + if (broadcastId != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("broadcastId", broadcastId)); + } + + if (sso != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("sso", sso)); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call votePollValidateBeforeCall(@javax.annotation.Nonnull String tenantId, @javax.annotation.Nonnull String commentId, @javax.annotation.Nonnull VotePollBody votePollBody, @javax.annotation.Nullable String urlId, @javax.annotation.Nullable String broadcastId, @javax.annotation.Nullable String sso, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'tenantId' is set + if (tenantId == null) { + throw new ApiException("Missing the required parameter 'tenantId' when calling votePoll(Async)"); + } + + // verify the required parameter 'commentId' is set + if (commentId == null) { + throw new ApiException("Missing the required parameter 'commentId' when calling votePoll(Async)"); + } + + // verify the required parameter 'votePollBody' is set + if (votePollBody == null) { + throw new ApiException("Missing the required parameter 'votePollBody' when calling votePoll(Async)"); + } + + return votePollCall(tenantId, commentId, votePollBody, urlId, broadcastId, sso, _callback); + + } + + + private ApiResponse votePollWithHttpInfo(@javax.annotation.Nonnull String tenantId, @javax.annotation.Nonnull String commentId, @javax.annotation.Nonnull VotePollBody votePollBody, @javax.annotation.Nullable String urlId, @javax.annotation.Nullable String broadcastId, @javax.annotation.Nullable String sso) throws ApiException { + okhttp3.Call localVarCall = votePollValidateBeforeCall(tenantId, commentId, votePollBody, urlId, broadcastId, sso, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + private okhttp3.Call votePollAsync(@javax.annotation.Nonnull String tenantId, @javax.annotation.Nonnull String commentId, @javax.annotation.Nonnull VotePollBody votePollBody, @javax.annotation.Nullable String urlId, @javax.annotation.Nullable String broadcastId, @javax.annotation.Nullable String sso, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = votePollValidateBeforeCall(tenantId, commentId, votePollBody, urlId, broadcastId, sso, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + public class APIvotePollRequest { + @javax.annotation.Nonnull + private final String tenantId; + @javax.annotation.Nonnull + private final String commentId; + @javax.annotation.Nonnull + private final VotePollBody votePollBody; + @javax.annotation.Nullable + private String urlId; + @javax.annotation.Nullable + private String broadcastId; + @javax.annotation.Nullable + private String sso; + + private APIvotePollRequest(@javax.annotation.Nonnull String tenantId, @javax.annotation.Nonnull String commentId, @javax.annotation.Nonnull VotePollBody votePollBody) { + this.tenantId = tenantId; + this.commentId = commentId; + this.votePollBody = votePollBody; + } + + /** + * Set urlId + * @param urlId (optional) + * @return APIvotePollRequest + */ + public APIvotePollRequest urlId(@javax.annotation.Nullable String urlId) { + this.urlId = urlId; + return this; + } + + /** + * Set broadcastId + * @param broadcastId (optional) + * @return APIvotePollRequest + */ + public APIvotePollRequest broadcastId(@javax.annotation.Nullable String broadcastId) { + this.broadcastId = broadcastId; + return this; + } + + /** + * Set sso + * @param sso (optional) + * @return APIvotePollRequest + */ + public APIvotePollRequest sso(@javax.annotation.Nullable String sso) { + this.sso = sso; + return this; + } + + /** + * Build call for votePoll + * @param _callback ApiCallback API callback + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Ok -
0 Error -
+ */ + public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException { + return votePollCall(tenantId, commentId, votePollBody, urlId, broadcastId, sso, _callback); + } + + /** + * Execute votePoll request + * @return VotePollResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Ok -
0 Error -
+ */ + public VotePollResponse execute() throws ApiException { + ApiResponse localVarResp = votePollWithHttpInfo(tenantId, commentId, votePollBody, urlId, broadcastId, sso); + return localVarResp.getData(); + } + + /** + * Execute votePoll request with HTTP info returned + * @return ApiResponse<VotePollResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Ok -
0 Error -
+ */ + public ApiResponse executeWithHttpInfo() throws ApiException { + return votePollWithHttpInfo(tenantId, commentId, votePollBody, urlId, broadcastId, sso); + } + + /** + * Execute votePoll 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 + + + + + +
Response Details
Status Code Description Response Headers
200 Ok -
0 Error -
+ */ + public okhttp3.Call executeAsync(final ApiCallback _callback) throws ApiException { + return votePollAsync(tenantId, commentId, votePollBody, urlId, broadcastId, sso, _callback); + } + } + + /** + * + * + * @param tenantId (required) + * @param commentId (required) + * @param votePollBody (required) + * @return APIvotePollRequest + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Ok -
0 Error -
+ */ + public APIvotePollRequest votePoll(@javax.annotation.Nonnull String tenantId, @javax.annotation.Nonnull String commentId, @javax.annotation.Nonnull VotePollBody votePollBody) { + return new APIvotePollRequest(tenantId, commentId, votePollBody); + } } diff --git a/client/src/main/java/com/fastcomments/invoker/ApiClient.java b/client/src/main/java/com/fastcomments/invoker/ApiClient.java index 82f32ae..df79615 100644 --- a/client/src/main/java/com/fastcomments/invoker/ApiClient.java +++ b/client/src/main/java/com/fastcomments/invoker/ApiClient.java @@ -147,7 +147,7 @@ protected void init() { json = new JSON(); // Set default User-Agent. - setUserAgent("OpenAPI-Generator/3.1.0/java"); + setUserAgent("OpenAPI-Generator/3.1.1/java"); authentications = new HashMap(); } diff --git a/client/src/main/java/com/fastcomments/invoker/Configuration.java b/client/src/main/java/com/fastcomments/invoker/Configuration.java index 108e2e2..2b2d995 100644 --- a/client/src/main/java/com/fastcomments/invoker/Configuration.java +++ b/client/src/main/java/com/fastcomments/invoker/Configuration.java @@ -19,7 +19,7 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.23.0-SNAPSHOT") public class Configuration { - public static final String VERSION = "3.1.0"; + public static final String VERSION = "3.1.1"; private static final AtomicReference defaultApiClient = new AtomicReference<>(); private static volatile Supplier apiClientFactory = ApiClient::new; diff --git a/client/src/main/java/com/fastcomments/invoker/JSON.java b/client/src/main/java/com/fastcomments/invoker/JSON.java index e8521c6..5121c43 100644 --- a/client/src/main/java/com/fastcomments/invoker/JSON.java +++ b/client/src/main/java/com/fastcomments/invoker/JSON.java @@ -287,6 +287,7 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new com.fastcomments.model.GetPendingWebhookEventsResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.fastcomments.model.GetPollResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.fastcomments.model.GetPollVoteResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.fastcomments.model.GetPollVoterNamesSuccessResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.fastcomments.model.GetPollVotesResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.fastcomments.model.GetPublicFeedPostsResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.fastcomments.model.GetPublicPagesResponse.CustomTypeAdapterFactory()); @@ -372,6 +373,7 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new com.fastcomments.model.PatchSSOUserAPIResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.fastcomments.model.PendingCommentToSyncOutbound.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.fastcomments.model.PickCommentPollOptionsOrTotalVotesOrClosesAt.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.fastcomments.model.PollVoterEntry.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.fastcomments.model.PostRemoveCommentApiResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.fastcomments.model.PreBanSummary.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.fastcomments.model.PubSubComment.CustomTypeAdapterFactory()); @@ -466,6 +468,8 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new com.fastcomments.model.UserSessionInfo.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.fastcomments.model.VoteBodyParams.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.fastcomments.model.VoteDeleteResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.fastcomments.model.VotePollBody.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.fastcomments.model.VotePollResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.fastcomments.model.VoteResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.fastcomments.model.VoteResponseUser.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.fastcomments.model.WebhookComment.CustomTypeAdapterFactory()); diff --git a/client/src/main/java/com/fastcomments/model/GetPollVoterNamesSuccessResponse.java b/client/src/main/java/com/fastcomments/model/GetPollVoterNamesSuccessResponse.java new file mode 100644 index 0000000..d4bedcc --- /dev/null +++ b/client/src/main/java/com/fastcomments/model/GetPollVoterNamesSuccessResponse.java @@ -0,0 +1,360 @@ +/* + * fastcomments + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.0 + * Contact: support@fastcomments.com + * + * 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.fastcomments.model; + +import java.util.Objects; +import com.fastcomments.model.APIStatus; +import com.fastcomments.model.PollVoterEntry; +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 java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +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 com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.fastcomments.invoker.JSON; + +/** + * GetPollVoterNamesSuccessResponse + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.23.0-SNAPSHOT") +public class GetPollVoterNamesSuccessResponse { + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + @javax.annotation.Nonnull + private APIStatus status; + + public static final String SERIALIZED_NAME_VOTERS = "voters"; + @SerializedName(SERIALIZED_NAME_VOTERS) + @javax.annotation.Nonnull + private List voters = new ArrayList<>(); + + public static final String SERIALIZED_NAME_PAGE = "page"; + @SerializedName(SERIALIZED_NAME_PAGE) + @javax.annotation.Nonnull + private Integer page; + + public static final String SERIALIZED_NAME_PAGE_SIZE = "pageSize"; + @SerializedName(SERIALIZED_NAME_PAGE_SIZE) + @javax.annotation.Nonnull + private Integer pageSize; + + public static final String SERIALIZED_NAME_TOTAL = "total"; + @SerializedName(SERIALIZED_NAME_TOTAL) + @javax.annotation.Nonnull + private Integer total; + + public static final String SERIALIZED_NAME_HAS_MORE = "hasMore"; + @SerializedName(SERIALIZED_NAME_HAS_MORE) + @javax.annotation.Nonnull + private Boolean hasMore; + + public GetPollVoterNamesSuccessResponse() { + } + + public GetPollVoterNamesSuccessResponse status(@javax.annotation.Nonnull APIStatus status) { + this.status = status; + return this; + } + + /** + * Get status + * @return status + */ + @javax.annotation.Nonnull + public APIStatus getStatus() { + return status; + } + + public void setStatus(@javax.annotation.Nonnull APIStatus status) { + this.status = status; + } + + + public GetPollVoterNamesSuccessResponse voters(@javax.annotation.Nonnull List voters) { + this.voters = voters; + return this; + } + + public GetPollVoterNamesSuccessResponse addVotersItem(PollVoterEntry votersItem) { + if (this.voters == null) { + this.voters = new ArrayList<>(); + } + this.voters.add(votersItem); + return this; + } + + /** + * Get voters + * @return voters + */ + @javax.annotation.Nonnull + public List getVoters() { + return voters; + } + + public void setVoters(@javax.annotation.Nonnull List voters) { + this.voters = voters; + } + + + public GetPollVoterNamesSuccessResponse page(@javax.annotation.Nonnull Integer page) { + this.page = page; + return this; + } + + /** + * Get page + * @return page + */ + @javax.annotation.Nonnull + public Integer getPage() { + return page; + } + + public void setPage(@javax.annotation.Nonnull Integer page) { + this.page = page; + } + + + public GetPollVoterNamesSuccessResponse pageSize(@javax.annotation.Nonnull Integer pageSize) { + this.pageSize = pageSize; + return this; + } + + /** + * Get pageSize + * @return pageSize + */ + @javax.annotation.Nonnull + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(@javax.annotation.Nonnull Integer pageSize) { + this.pageSize = pageSize; + } + + + public GetPollVoterNamesSuccessResponse total(@javax.annotation.Nonnull Integer total) { + this.total = total; + return this; + } + + /** + * Get total + * @return total + */ + @javax.annotation.Nonnull + public Integer getTotal() { + return total; + } + + public void setTotal(@javax.annotation.Nonnull Integer total) { + this.total = total; + } + + + public GetPollVoterNamesSuccessResponse hasMore(@javax.annotation.Nonnull Boolean hasMore) { + this.hasMore = hasMore; + return this; + } + + /** + * Get hasMore + * @return hasMore + */ + @javax.annotation.Nonnull + public Boolean getHasMore() { + return hasMore; + } + + public void setHasMore(@javax.annotation.Nonnull Boolean hasMore) { + this.hasMore = hasMore; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetPollVoterNamesSuccessResponse getPollVoterNamesSuccessResponse = (GetPollVoterNamesSuccessResponse) o; + return Objects.equals(this.status, getPollVoterNamesSuccessResponse.status) && + Objects.equals(this.voters, getPollVoterNamesSuccessResponse.voters) && + Objects.equals(this.page, getPollVoterNamesSuccessResponse.page) && + Objects.equals(this.pageSize, getPollVoterNamesSuccessResponse.pageSize) && + Objects.equals(this.total, getPollVoterNamesSuccessResponse.total) && + Objects.equals(this.hasMore, getPollVoterNamesSuccessResponse.hasMore); + } + + @Override + public int hashCode() { + return Objects.hash(status, voters, page, pageSize, total, hasMore); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GetPollVoterNamesSuccessResponse {\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" voters: ").append(toIndentedString(voters)).append("\n"); + sb.append(" page: ").append(toIndentedString(page)).append("\n"); + sb.append(" pageSize: ").append(toIndentedString(pageSize)).append("\n"); + sb.append(" total: ").append(toIndentedString(total)).append("\n"); + sb.append(" hasMore: ").append(toIndentedString(hasMore)).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) { + return o == null ? "null" : 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(Arrays.asList("status", "voters", "page", "pageSize", "total", "hasMore")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("status", "voters", "page", "pageSize", "total", "hasMore")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to GetPollVoterNamesSuccessResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!GetPollVoterNamesSuccessResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in GetPollVoterNamesSuccessResponse is not found in the empty JSON string", GetPollVoterNamesSuccessResponse.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!GetPollVoterNamesSuccessResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetPollVoterNamesSuccessResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : GetPollVoterNamesSuccessResponse.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `status` + APIStatus.validateJsonElement(jsonObj.get("status")); + if (jsonObj.get("voters") != null) { + if (!jsonObj.get("voters").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `voters` to be an array in the JSON string but got `%s`", jsonObj.get("voters").toString())); + } + JsonArray jsonArrayvoters = jsonObj.getAsJsonArray("voters"); + // validate the required field `voters` (array) + for (int i = 0; i < jsonArrayvoters.size(); i++) { + PollVoterEntry.validateJsonElement(jsonArrayvoters.get(i)); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!GetPollVoterNamesSuccessResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'GetPollVoterNamesSuccessResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(GetPollVoterNamesSuccessResponse.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, GetPollVoterNamesSuccessResponse value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public GetPollVoterNamesSuccessResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of GetPollVoterNamesSuccessResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of GetPollVoterNamesSuccessResponse + * @throws IOException if the JSON string is invalid with respect to GetPollVoterNamesSuccessResponse + */ + public static GetPollVoterNamesSuccessResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, GetPollVoterNamesSuccessResponse.class); + } + + /** + * Convert an instance of GetPollVoterNamesSuccessResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/client/src/main/java/com/fastcomments/model/PollVoterEntry.java b/client/src/main/java/com/fastcomments/model/PollVoterEntry.java new file mode 100644 index 0000000..21194f9 --- /dev/null +++ b/client/src/main/java/com/fastcomments/model/PollVoterEntry.java @@ -0,0 +1,238 @@ +/* + * fastcomments + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.0 + * Contact: support@fastcomments.com + * + * 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.fastcomments.model; + +import java.util.Objects; +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 java.io.IOException; +import java.util.Arrays; + +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 com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.fastcomments.invoker.JSON; + +/** + * PollVoterEntry + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.23.0-SNAPSHOT") +public class PollVoterEntry { + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public static final String SERIALIZED_NAME_OPTION_LABEL = "optionLabel"; + @SerializedName(SERIALIZED_NAME_OPTION_LABEL) + @javax.annotation.Nonnull + private String optionLabel; + + public PollVoterEntry() { + } + + public PollVoterEntry name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public PollVoterEntry optionLabel(@javax.annotation.Nonnull String optionLabel) { + this.optionLabel = optionLabel; + return this; + } + + /** + * Get optionLabel + * @return optionLabel + */ + @javax.annotation.Nonnull + public String getOptionLabel() { + return optionLabel; + } + + public void setOptionLabel(@javax.annotation.Nonnull String optionLabel) { + this.optionLabel = optionLabel; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PollVoterEntry pollVoterEntry = (PollVoterEntry) o; + return Objects.equals(this.name, pollVoterEntry.name) && + Objects.equals(this.optionLabel, pollVoterEntry.optionLabel); + } + + @Override + public int hashCode() { + return Objects.hash(name, optionLabel); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PollVoterEntry {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" optionLabel: ").append(toIndentedString(optionLabel)).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) { + return o == null ? "null" : 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(Arrays.asList("name", "optionLabel")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("name", "optionLabel")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to PollVoterEntry + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!PollVoterEntry.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in PollVoterEntry is not found in the empty JSON string", PollVoterEntry.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!PollVoterEntry.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PollVoterEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : PollVoterEntry.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if (!jsonObj.get("optionLabel").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `optionLabel` to be a primitive type in the JSON string but got `%s`", jsonObj.get("optionLabel").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PollVoterEntry.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PollVoterEntry' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(PollVoterEntry.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, PollVoterEntry value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public PollVoterEntry read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of PollVoterEntry given an JSON string + * + * @param jsonString JSON string + * @return An instance of PollVoterEntry + * @throws IOException if the JSON string is invalid with respect to PollVoterEntry + */ + public static PollVoterEntry fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, PollVoterEntry.class); + } + + /** + * Convert an instance of PollVoterEntry to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/client/src/main/java/com/fastcomments/model/PublicComment.java b/client/src/main/java/com/fastcomments/model/PublicComment.java index 52b2825..d88c9b2 100644 --- a/client/src/main/java/com/fastcomments/model/PublicComment.java +++ b/client/src/main/java/com/fastcomments/model/PublicComment.java @@ -14,6 +14,7 @@ package com.fastcomments.model; import java.util.Objects; +import com.fastcomments.model.CommentPoll; import com.fastcomments.model.CommentUserBadgeInfo; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -184,6 +185,11 @@ public class PublicComment { @javax.annotation.Nullable private List feedbackIds = new ArrayList<>(); + public static final String SERIALIZED_NAME_POLL = "poll"; + @SerializedName(SERIALIZED_NAME_POLL) + @javax.annotation.Nullable + private CommentPoll poll; + public static final String SERIALIZED_NAME_REQUIRES_VERIFICATION = "requiresVerification"; @SerializedName(SERIALIZED_NAME_REQUIRES_VERIFICATION) @javax.annotation.Nullable @@ -767,6 +773,25 @@ public void setFeedbackIds(@javax.annotation.Nullable List feedbackIds) } + public PublicComment poll(@javax.annotation.Nullable CommentPoll poll) { + this.poll = poll; + return this; + } + + /** + * Get poll + * @return poll + */ + @javax.annotation.Nullable + public CommentPoll getPoll() { + return poll; + } + + public void setPoll(@javax.annotation.Nullable CommentPoll poll) { + this.poll = poll; + } + + public PublicComment requiresVerification(@javax.annotation.Nullable Boolean requiresVerification) { this.requiresVerification = requiresVerification; return this; @@ -1129,6 +1154,7 @@ public boolean equals(Object o) { Objects.equals(this.isSpam, publicComment.isSpam) && Objects.equals(this.anonUserId, publicComment.anonUserId) && Objects.equals(this.feedbackIds, publicComment.feedbackIds) && + Objects.equals(this.poll, publicComment.poll) && Objects.equals(this.requiresVerification, publicComment.requiresVerification) && Objects.equals(this.editKey, publicComment.editKey) && Objects.equals(this.approved, publicComment.approved) && @@ -1148,7 +1174,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(id, userId, commenterName, commenterLink, commentHTML, parentId, date, votes, votesUp, votesDown, verified, avatarSrc, hasImages, isByAdmin, isByModerator, isPinned, isLocked, displayLabel, rating, badges, viewCount, isDeleted, isDeletedUser, isSpam, anonUserId, feedbackIds, requiresVerification, editKey, approved, isUnread, myPollVotes, myVoteId, isVotedDown, isVotedUp, hasChildren, nestedChildrenCount, childCount, children, isFlagged, isBlocked, additionalProperties); + return Objects.hash(id, userId, commenterName, commenterLink, commentHTML, parentId, date, votes, votesUp, votesDown, verified, avatarSrc, hasImages, isByAdmin, isByModerator, isPinned, isLocked, displayLabel, rating, badges, viewCount, isDeleted, isDeletedUser, isSpam, anonUserId, feedbackIds, poll, requiresVerification, editKey, approved, isUnread, myPollVotes, myVoteId, isVotedDown, isVotedUp, hasChildren, nestedChildrenCount, childCount, children, isFlagged, isBlocked, additionalProperties); } @Override @@ -1181,6 +1207,7 @@ public String toString() { sb.append(" isSpam: ").append(toIndentedString(isSpam)).append("\n"); sb.append(" anonUserId: ").append(toIndentedString(anonUserId)).append("\n"); sb.append(" feedbackIds: ").append(toIndentedString(feedbackIds)).append("\n"); + sb.append(" poll: ").append(toIndentedString(poll)).append("\n"); sb.append(" requiresVerification: ").append(toIndentedString(requiresVerification)).append("\n"); sb.append(" editKey: ").append(toIndentedString(editKey)).append("\n"); sb.append(" approved: ").append(toIndentedString(approved)).append("\n"); @@ -1214,7 +1241,7 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("_id", "userId", "commenterName", "commenterLink", "commentHTML", "parentId", "date", "votes", "votesUp", "votesDown", "verified", "avatarSrc", "hasImages", "isByAdmin", "isByModerator", "isPinned", "isLocked", "displayLabel", "rating", "badges", "viewCount", "isDeleted", "isDeletedUser", "isSpam", "anonUserId", "feedbackIds", "requiresVerification", "editKey", "approved", "isUnread", "myPollVotes", "myVoteId", "isVotedDown", "isVotedUp", "hasChildren", "nestedChildrenCount", "childCount", "children", "isFlagged", "isBlocked")); + openapiFields = new HashSet(Arrays.asList("_id", "userId", "commenterName", "commenterLink", "commentHTML", "parentId", "date", "votes", "votesUp", "votesDown", "verified", "avatarSrc", "hasImages", "isByAdmin", "isByModerator", "isPinned", "isLocked", "displayLabel", "rating", "badges", "viewCount", "isDeleted", "isDeletedUser", "isSpam", "anonUserId", "feedbackIds", "poll", "requiresVerification", "editKey", "approved", "isUnread", "myPollVotes", "myVoteId", "isVotedDown", "isVotedUp", "hasChildren", "nestedChildrenCount", "childCount", "children", "isFlagged", "isBlocked")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(Arrays.asList("_id", "commenterName", "commentHTML", "date", "verified")); @@ -1285,6 +1312,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonObj.get("feedbackIds") != null && !jsonObj.get("feedbackIds").isJsonNull() && !jsonObj.get("feedbackIds").isJsonArray()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `feedbackIds` to be an array in the JSON string but got `%s`", jsonObj.get("feedbackIds").toString())); } + // validate the optional field `poll` + if (jsonObj.get("poll") != null && !jsonObj.get("poll").isJsonNull()) { + CommentPoll.validateJsonElement(jsonObj.get("poll")); + } if ((jsonObj.get("editKey") != null && !jsonObj.get("editKey").isJsonNull()) && !jsonObj.get("editKey").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `editKey` to be a primitive type in the JSON string but got `%s`", jsonObj.get("editKey").toString())); } diff --git a/client/src/main/java/com/fastcomments/model/PublicCommentBase.java b/client/src/main/java/com/fastcomments/model/PublicCommentBase.java index e92d730..6aad3ac 100644 --- a/client/src/main/java/com/fastcomments/model/PublicCommentBase.java +++ b/client/src/main/java/com/fastcomments/model/PublicCommentBase.java @@ -14,6 +14,7 @@ package com.fastcomments.model; import java.util.Objects; +import com.fastcomments.model.CommentPoll; import com.fastcomments.model.CommentUserBadgeInfo; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -184,6 +185,11 @@ public class PublicCommentBase { @javax.annotation.Nullable private List feedbackIds = new ArrayList<>(); + public static final String SERIALIZED_NAME_POLL = "poll"; + @SerializedName(SERIALIZED_NAME_POLL) + @javax.annotation.Nullable + private CommentPoll poll; + public static final String SERIALIZED_NAME_REQUIRES_VERIFICATION = "requiresVerification"; @SerializedName(SERIALIZED_NAME_REQUIRES_VERIFICATION) @javax.annotation.Nullable @@ -712,6 +718,25 @@ public void setFeedbackIds(@javax.annotation.Nullable List feedbackIds) } + public PublicCommentBase poll(@javax.annotation.Nullable CommentPoll poll) { + this.poll = poll; + return this; + } + + /** + * Get poll + * @return poll + */ + @javax.annotation.Nullable + public CommentPoll getPoll() { + return poll; + } + + public void setPoll(@javax.annotation.Nullable CommentPoll poll) { + this.poll = poll; + } + + public PublicCommentBase requiresVerification(@javax.annotation.Nullable Boolean requiresVerification) { this.requiresVerification = requiresVerification; return this; @@ -805,6 +830,7 @@ public boolean equals(Object o) { Objects.equals(this.isSpam, publicCommentBase.isSpam) && Objects.equals(this.anonUserId, publicCommentBase.anonUserId) && Objects.equals(this.feedbackIds, publicCommentBase.feedbackIds) && + Objects.equals(this.poll, publicCommentBase.poll) && Objects.equals(this.requiresVerification, publicCommentBase.requiresVerification) && Objects.equals(this.editKey, publicCommentBase.editKey) && Objects.equals(this.approved, publicCommentBase.approved); @@ -812,7 +838,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(id, userId, commenterName, commenterLink, commentHTML, parentId, date, votes, votesUp, votesDown, verified, avatarSrc, hasImages, isByAdmin, isByModerator, isPinned, isLocked, displayLabel, rating, badges, viewCount, isDeleted, isDeletedUser, isSpam, anonUserId, feedbackIds, requiresVerification, editKey, approved); + return Objects.hash(id, userId, commenterName, commenterLink, commentHTML, parentId, date, votes, votesUp, votesDown, verified, avatarSrc, hasImages, isByAdmin, isByModerator, isPinned, isLocked, displayLabel, rating, badges, viewCount, isDeleted, isDeletedUser, isSpam, anonUserId, feedbackIds, poll, requiresVerification, editKey, approved); } @Override @@ -845,6 +871,7 @@ public String toString() { sb.append(" isSpam: ").append(toIndentedString(isSpam)).append("\n"); sb.append(" anonUserId: ").append(toIndentedString(anonUserId)).append("\n"); sb.append(" feedbackIds: ").append(toIndentedString(feedbackIds)).append("\n"); + sb.append(" poll: ").append(toIndentedString(poll)).append("\n"); sb.append(" requiresVerification: ").append(toIndentedString(requiresVerification)).append("\n"); sb.append(" editKey: ").append(toIndentedString(editKey)).append("\n"); sb.append(" approved: ").append(toIndentedString(approved)).append("\n"); @@ -866,7 +893,7 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("_id", "userId", "commenterName", "commenterLink", "commentHTML", "parentId", "date", "votes", "votesUp", "votesDown", "verified", "avatarSrc", "hasImages", "isByAdmin", "isByModerator", "isPinned", "isLocked", "displayLabel", "rating", "badges", "viewCount", "isDeleted", "isDeletedUser", "isSpam", "anonUserId", "feedbackIds", "requiresVerification", "editKey", "approved")); + openapiFields = new HashSet(Arrays.asList("_id", "userId", "commenterName", "commenterLink", "commentHTML", "parentId", "date", "votes", "votesUp", "votesDown", "verified", "avatarSrc", "hasImages", "isByAdmin", "isByModerator", "isPinned", "isLocked", "displayLabel", "rating", "badges", "viewCount", "isDeleted", "isDeletedUser", "isSpam", "anonUserId", "feedbackIds", "poll", "requiresVerification", "editKey", "approved")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(Arrays.asList("_id", "commenterName", "commentHTML", "date", "verified")); @@ -945,6 +972,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonObj.get("feedbackIds") != null && !jsonObj.get("feedbackIds").isJsonNull() && !jsonObj.get("feedbackIds").isJsonArray()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `feedbackIds` to be an array in the JSON string but got `%s`", jsonObj.get("feedbackIds").toString())); } + // validate the optional field `poll` + if (jsonObj.get("poll") != null && !jsonObj.get("poll").isJsonNull()) { + CommentPoll.validateJsonElement(jsonObj.get("poll")); + } if ((jsonObj.get("editKey") != null && !jsonObj.get("editKey").isJsonNull()) && !jsonObj.get("editKey").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `editKey` to be a primitive type in the JSON string but got `%s`", jsonObj.get("editKey").toString())); } diff --git a/client/src/main/java/com/fastcomments/model/VotePollBody.java b/client/src/main/java/com/fastcomments/model/VotePollBody.java new file mode 100644 index 0000000..887f22e --- /dev/null +++ b/client/src/main/java/com/fastcomments/model/VotePollBody.java @@ -0,0 +1,209 @@ +/* + * fastcomments + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.0 + * Contact: support@fastcomments.com + * + * 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.fastcomments.model; + +import java.util.Objects; +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 java.io.IOException; +import java.util.Arrays; + +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 com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.fastcomments.invoker.JSON; + +/** + * VotePollBody + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.23.0-SNAPSHOT") +public class VotePollBody { + public static final String SERIALIZED_NAME_OPTION_ID = "optionId"; + @SerializedName(SERIALIZED_NAME_OPTION_ID) + @javax.annotation.Nonnull + private String optionId; + + public VotePollBody() { + } + + public VotePollBody optionId(@javax.annotation.Nonnull String optionId) { + this.optionId = optionId; + return this; + } + + /** + * Get optionId + * @return optionId + */ + @javax.annotation.Nonnull + public String getOptionId() { + return optionId; + } + + public void setOptionId(@javax.annotation.Nonnull String optionId) { + this.optionId = optionId; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + VotePollBody votePollBody = (VotePollBody) o; + return Objects.equals(this.optionId, votePollBody.optionId); + } + + @Override + public int hashCode() { + return Objects.hash(optionId); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class VotePollBody {\n"); + sb.append(" optionId: ").append(toIndentedString(optionId)).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) { + return o == null ? "null" : 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(Arrays.asList("optionId")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("optionId")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to VotePollBody + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!VotePollBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in VotePollBody is not found in the empty JSON string", VotePollBody.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!VotePollBody.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `VotePollBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : VotePollBody.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("optionId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `optionId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("optionId").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!VotePollBody.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'VotePollBody' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(VotePollBody.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, VotePollBody value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public VotePollBody read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of VotePollBody given an JSON string + * + * @param jsonString JSON string + * @return An instance of VotePollBody + * @throws IOException if the JSON string is invalid with respect to VotePollBody + */ + public static VotePollBody fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, VotePollBody.class); + } + + /** + * Convert an instance of VotePollBody to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/client/src/main/java/com/fastcomments/model/VotePollResponse.java b/client/src/main/java/com/fastcomments/model/VotePollResponse.java new file mode 100644 index 0000000..ecec26b --- /dev/null +++ b/client/src/main/java/com/fastcomments/model/VotePollResponse.java @@ -0,0 +1,309 @@ +/* + * fastcomments + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.0 + * Contact: support@fastcomments.com + * + * 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.fastcomments.model; + +import java.util.Objects; +import com.fastcomments.model.APIStatus; +import com.fastcomments.model.CommentPoll; +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 java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +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 com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.fastcomments.invoker.JSON; + +/** + * VotePollResponse + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.23.0-SNAPSHOT") +public class VotePollResponse { + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + @javax.annotation.Nonnull + private APIStatus status; + + public static final String SERIALIZED_NAME_POLL = "poll"; + @SerializedName(SERIALIZED_NAME_POLL) + @javax.annotation.Nonnull + private CommentPoll poll; + + public static final String SERIALIZED_NAME_MY_POLL_VOTES = "myPollVotes"; + @SerializedName(SERIALIZED_NAME_MY_POLL_VOTES) + @javax.annotation.Nonnull + private List myPollVotes = new ArrayList<>(); + + public static final String SERIALIZED_NAME_VOTER_ID = "voterId"; + @SerializedName(SERIALIZED_NAME_VOTER_ID) + @javax.annotation.Nonnull + private String voterId; + + public VotePollResponse() { + } + + public VotePollResponse status(@javax.annotation.Nonnull APIStatus status) { + this.status = status; + return this; + } + + /** + * Get status + * @return status + */ + @javax.annotation.Nonnull + public APIStatus getStatus() { + return status; + } + + public void setStatus(@javax.annotation.Nonnull APIStatus status) { + this.status = status; + } + + + public VotePollResponse poll(@javax.annotation.Nonnull CommentPoll poll) { + this.poll = poll; + return this; + } + + /** + * Get poll + * @return poll + */ + @javax.annotation.Nonnull + public CommentPoll getPoll() { + return poll; + } + + public void setPoll(@javax.annotation.Nonnull CommentPoll poll) { + this.poll = poll; + } + + + public VotePollResponse myPollVotes(@javax.annotation.Nonnull List myPollVotes) { + this.myPollVotes = myPollVotes; + return this; + } + + public VotePollResponse addMyPollVotesItem(String myPollVotesItem) { + if (this.myPollVotes == null) { + this.myPollVotes = new ArrayList<>(); + } + this.myPollVotes.add(myPollVotesItem); + return this; + } + + /** + * Get myPollVotes + * @return myPollVotes + */ + @javax.annotation.Nonnull + public List getMyPollVotes() { + return myPollVotes; + } + + public void setMyPollVotes(@javax.annotation.Nonnull List myPollVotes) { + this.myPollVotes = myPollVotes; + } + + + public VotePollResponse voterId(@javax.annotation.Nonnull String voterId) { + this.voterId = voterId; + return this; + } + + /** + * Get voterId + * @return voterId + */ + @javax.annotation.Nonnull + public String getVoterId() { + return voterId; + } + + public void setVoterId(@javax.annotation.Nonnull String voterId) { + this.voterId = voterId; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + VotePollResponse votePollResponse = (VotePollResponse) o; + return Objects.equals(this.status, votePollResponse.status) && + Objects.equals(this.poll, votePollResponse.poll) && + Objects.equals(this.myPollVotes, votePollResponse.myPollVotes) && + Objects.equals(this.voterId, votePollResponse.voterId); + } + + @Override + public int hashCode() { + return Objects.hash(status, poll, myPollVotes, voterId); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class VotePollResponse {\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" poll: ").append(toIndentedString(poll)).append("\n"); + sb.append(" myPollVotes: ").append(toIndentedString(myPollVotes)).append("\n"); + sb.append(" voterId: ").append(toIndentedString(voterId)).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) { + return o == null ? "null" : 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(Arrays.asList("status", "poll", "myPollVotes", "voterId")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("status", "poll", "myPollVotes", "voterId")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to VotePollResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!VotePollResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in VotePollResponse is not found in the empty JSON string", VotePollResponse.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!VotePollResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `VotePollResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : VotePollResponse.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `status` + APIStatus.validateJsonElement(jsonObj.get("status")); + // validate the required field `poll` + CommentPoll.validateJsonElement(jsonObj.get("poll")); + // ensure the required json array is present + if (jsonObj.get("myPollVotes") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("myPollVotes").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `myPollVotes` to be an array in the JSON string but got `%s`", jsonObj.get("myPollVotes").toString())); + } + if (!jsonObj.get("voterId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `voterId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("voterId").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!VotePollResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'VotePollResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(VotePollResponse.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, VotePollResponse value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public VotePollResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of VotePollResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of VotePollResponse + * @throws IOException if the JSON string is invalid with respect to VotePollResponse + */ + public static VotePollResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, VotePollResponse.class); + } + + /** + * Convert an instance of VotePollResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/client/src/test/java/com/fastcomments/api/PublicApiTest.java b/client/src/test/java/com/fastcomments/api/PublicApiTest.java index 0b62d34..09f38a4 100644 --- a/client/src/test/java/com/fastcomments/api/PublicApiTest.java +++ b/client/src/test/java/com/fastcomments/api/PublicApiTest.java @@ -36,6 +36,7 @@ import com.fastcomments.model.GetGifsSearchResponse; import com.fastcomments.model.GetGifsTrendingResponse; import com.fastcomments.model.GetMyNotificationsResponse; +import com.fastcomments.model.GetPollVoterNamesSuccessResponse; import com.fastcomments.model.GetPublicPagesResponse; import com.fastcomments.model.GetTranslationsResponse; import com.fastcomments.model.GetUserNotificationCountResponse; @@ -70,6 +71,8 @@ import com.fastcomments.model.UserReactsResponse; import com.fastcomments.model.VoteBodyParams; import com.fastcomments.model.VoteDeleteResponse; +import com.fastcomments.model.VotePollBody; +import com.fastcomments.model.VotePollResponse; import com.fastcomments.model.VoteResponse; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -587,6 +590,28 @@ public void getPagesPublicTest() throws ApiException { // TODO: test validations } + /** + * Who voted for which option. Anonymous polls never answer, admins-only polls answer only for an admin or moderator. + * + * @throws ApiException if the Api call fails + */ + @Test + public void getPollVotersTest() throws ApiException { + String tenantId = null; + String commentId = null; + String urlId = null; + Integer page = null; + String search = null; + String sso = null; + GetPollVoterNamesSuccessResponse response = api.getPollVoters(tenantId, commentId) + .urlId(urlId) + .page(page) + .search(search) + .sso(sso) + .execute(); + // TODO: test validations + } + /** * @throws ApiException if the Api call fails */ @@ -1041,4 +1066,23 @@ public void voteCommentTest() throws ApiException { // TODO: test validations } + /** + * @throws ApiException if the Api call fails + */ + @Test + public void votePollTest() throws ApiException { + String tenantId = null; + String commentId = null; + VotePollBody votePollBody = null; + String urlId = null; + String broadcastId = null; + String sso = null; + VotePollResponse response = api.votePoll(tenantId, commentId, votePollBody) + .urlId(urlId) + .broadcastId(broadcastId) + .sso(sso) + .execute(); + // TODO: test validations + } + } diff --git a/client/src/test/java/com/fastcomments/model/GetPollVoterNamesSuccessResponseTest.java b/client/src/test/java/com/fastcomments/model/GetPollVoterNamesSuccessResponseTest.java new file mode 100644 index 0000000..1276961 --- /dev/null +++ b/client/src/test/java/com/fastcomments/model/GetPollVoterNamesSuccessResponseTest.java @@ -0,0 +1,92 @@ +/* + * fastcomments + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.0 + * Contact: support@fastcomments.com + * + * 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.fastcomments.model; + +import com.fastcomments.model.APIStatus; +import com.fastcomments.model.PollVoterEntry; +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 java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for GetPollVoterNamesSuccessResponse + */ +public class GetPollVoterNamesSuccessResponseTest { + private final GetPollVoterNamesSuccessResponse model = new GetPollVoterNamesSuccessResponse(); + + /** + * Model tests for GetPollVoterNamesSuccessResponse + */ + @Test + public void testGetPollVoterNamesSuccessResponse() { + // TODO: test GetPollVoterNamesSuccessResponse + } + + /** + * Test the property 'status' + */ + @Test + public void statusTest() { + // TODO: test status + } + + /** + * Test the property 'voters' + */ + @Test + public void votersTest() { + // TODO: test voters + } + + /** + * Test the property 'page' + */ + @Test + public void pageTest() { + // TODO: test page + } + + /** + * Test the property 'pageSize' + */ + @Test + public void pageSizeTest() { + // TODO: test pageSize + } + + /** + * Test the property 'total' + */ + @Test + public void totalTest() { + // TODO: test total + } + + /** + * Test the property 'hasMore' + */ + @Test + public void hasMoreTest() { + // TODO: test hasMore + } + +} diff --git a/client/src/test/java/com/fastcomments/model/PollVoterEntryTest.java b/client/src/test/java/com/fastcomments/model/PollVoterEntryTest.java new file mode 100644 index 0000000..3fb7e3a --- /dev/null +++ b/client/src/test/java/com/fastcomments/model/PollVoterEntryTest.java @@ -0,0 +1,56 @@ +/* + * fastcomments + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.0 + * Contact: support@fastcomments.com + * + * 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.fastcomments.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 java.io.IOException; +import java.util.Arrays; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for PollVoterEntry + */ +public class PollVoterEntryTest { + private final PollVoterEntry model = new PollVoterEntry(); + + /** + * Model tests for PollVoterEntry + */ + @Test + public void testPollVoterEntry() { + // TODO: test PollVoterEntry + } + + /** + * Test the property 'name' + */ + @Test + public void nameTest() { + // TODO: test name + } + + /** + * Test the property 'optionLabel' + */ + @Test + public void optionLabelTest() { + // TODO: test optionLabel + } + +} diff --git a/client/src/test/java/com/fastcomments/model/PublicCommentBaseTest.java b/client/src/test/java/com/fastcomments/model/PublicCommentBaseTest.java index 2875600..2535567 100644 --- a/client/src/test/java/com/fastcomments/model/PublicCommentBaseTest.java +++ b/client/src/test/java/com/fastcomments/model/PublicCommentBaseTest.java @@ -13,6 +13,7 @@ package com.fastcomments.model; +import com.fastcomments.model.CommentPoll; import com.fastcomments.model.CommentUserBadgeInfo; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -249,6 +250,14 @@ public void feedbackIdsTest() { // TODO: test feedbackIds } + /** + * Test the property 'poll' + */ + @Test + public void pollTest() { + // TODO: test poll + } + /** * Test the property 'requiresVerification' */ diff --git a/client/src/test/java/com/fastcomments/model/PublicCommentTest.java b/client/src/test/java/com/fastcomments/model/PublicCommentTest.java index 1d2f918..93ea258 100644 --- a/client/src/test/java/com/fastcomments/model/PublicCommentTest.java +++ b/client/src/test/java/com/fastcomments/model/PublicCommentTest.java @@ -13,6 +13,7 @@ package com.fastcomments.model; +import com.fastcomments.model.CommentPoll; import com.fastcomments.model.CommentUserBadgeInfo; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -249,6 +250,14 @@ public void feedbackIdsTest() { // TODO: test feedbackIds } + /** + * Test the property 'poll' + */ + @Test + public void pollTest() { + // TODO: test poll + } + /** * Test the property 'requiresVerification' */ diff --git a/client/src/test/java/com/fastcomments/model/VotePollBodyTest.java b/client/src/test/java/com/fastcomments/model/VotePollBodyTest.java new file mode 100644 index 0000000..be5f65b --- /dev/null +++ b/client/src/test/java/com/fastcomments/model/VotePollBodyTest.java @@ -0,0 +1,48 @@ +/* + * fastcomments + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.0 + * Contact: support@fastcomments.com + * + * 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.fastcomments.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 java.io.IOException; +import java.util.Arrays; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for VotePollBody + */ +public class VotePollBodyTest { + private final VotePollBody model = new VotePollBody(); + + /** + * Model tests for VotePollBody + */ + @Test + public void testVotePollBody() { + // TODO: test VotePollBody + } + + /** + * Test the property 'optionId' + */ + @Test + public void optionIdTest() { + // TODO: test optionId + } + +} diff --git a/client/src/test/java/com/fastcomments/model/VotePollResponseTest.java b/client/src/test/java/com/fastcomments/model/VotePollResponseTest.java new file mode 100644 index 0000000..04a9e2f --- /dev/null +++ b/client/src/test/java/com/fastcomments/model/VotePollResponseTest.java @@ -0,0 +1,76 @@ +/* + * fastcomments + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.0 + * Contact: support@fastcomments.com + * + * 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.fastcomments.model; + +import com.fastcomments.model.APIStatus; +import com.fastcomments.model.CommentPoll; +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 java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for VotePollResponse + */ +public class VotePollResponseTest { + private final VotePollResponse model = new VotePollResponse(); + + /** + * Model tests for VotePollResponse + */ + @Test + public void testVotePollResponse() { + // TODO: test VotePollResponse + } + + /** + * Test the property 'status' + */ + @Test + public void statusTest() { + // TODO: test status + } + + /** + * Test the property 'poll' + */ + @Test + public void pollTest() { + // TODO: test poll + } + + /** + * Test the property 'myPollVotes' + */ + @Test + public void myPollVotesTest() { + // TODO: test myPollVotes + } + + /** + * Test the property 'voterId' + */ + @Test + public void voterIdTest() { + // TODO: test voterId + } + +} diff --git a/config.json b/config.json index 364b84e..7e2a301 100644 --- a/config.json +++ b/config.json @@ -1,7 +1,7 @@ { "groupId": "com.fastcomments", "artifactId": "client", - "artifactVersion": "3.1.0", + "artifactVersion": "3.1.1", "packageName": "com.fastcomments", "apiPackage": "com.fastcomments.api", "modelPackage": "com.fastcomments.model", diff --git a/openapi.json b/openapi.json index 37ce568..fe7924f 100644 --- a/openapi.json +++ b/openapi.json @@ -1319,6 +1319,171 @@ ], "type": "object" }, + "CommentPollOption": { + "properties": { + "id": { + "type": "string" + }, + "label": { + "type": "string" + }, + "votes": { + "type": "integer", + "format": "int32" + } + }, + "required": [ + "id", + "label", + "votes" + ], + "type": "object", + "additionalProperties": false + }, + "PollPrivacy": { + "description": "Who may see which voter picked which option. Chosen by the poll's author when they build the poll, so it\nlives on the poll itself rather than in the widget config. Anonymous is the default and is never stored on\nthe poll or sent to the client, so an unset value means Anonymous.", + "enum": [ + 0, + 1, + 2 + ], + "type": "integer" + }, + "CommentPoll": { + "description": "A poll attached to a comment. Vote counts are denormalized here; individual votes live in PollVote.", + "properties": { + "question": { + "type": "string" + }, + "options": { + "items": { + "$ref": "#/components/schemas/CommentPollOption" + }, + "type": "array" + }, + "totalVotes": { + "type": "integer", + "format": "int32" + }, + "closesAt": { + "type": "string", + "format": "date-time", + "nullable": true + }, + "privacy": { + "allOf": [ + { + "$ref": "#/components/schemas/PollPrivacy" + } + ], + "nullable": true + }, + "requireVoteToSeeResults": { + "type": "boolean", + "nullable": true + } + }, + "required": [ + "question", + "options", + "totalVotes" + ], + "type": "object", + "additionalProperties": false + }, + "VotePollResponse": { + "properties": { + "status": { + "$ref": "#/components/schemas/APIStatus" + }, + "poll": { + "$ref": "#/components/schemas/CommentPoll" + }, + "myPollVotes": { + "items": { + "type": "string" + }, + "type": "array" + }, + "voterId": { + "type": "string" + } + }, + "required": [ + "status", + "poll", + "myPollVotes", + "voterId" + ], + "type": "object", + "additionalProperties": false + }, + "VotePollBody": { + "properties": { + "optionId": { + "type": "string" + } + }, + "required": [ + "optionId" + ], + "type": "object", + "additionalProperties": false + }, + "PollVoterEntry": { + "properties": { + "name": { + "type": "string" + }, + "optionLabel": { + "type": "string" + } + }, + "required": [ + "name", + "optionLabel" + ], + "type": "object", + "additionalProperties": false + }, + "GetPollVoterNamesSuccessResponse": { + "properties": { + "status": { + "$ref": "#/components/schemas/APIStatus" + }, + "voters": { + "items": { + "$ref": "#/components/schemas/PollVoterEntry" + }, + "type": "array" + }, + "page": { + "type": "integer", + "format": "int32" + }, + "pageSize": { + "type": "integer", + "format": "int32" + }, + "total": { + "type": "integer", + "format": "int32" + }, + "hasMore": { + "type": "boolean" + } + }, + "required": [ + "status", + "voters", + "page", + "pageSize", + "total", + "hasMore" + ], + "type": "object", + "additionalProperties": false + }, "PageReactUser": { "properties": { "avatarSrc": { @@ -3947,78 +4112,6 @@ "type": "object", "additionalProperties": false }, - "CommentPollOption": { - "properties": { - "id": { - "type": "string" - }, - "label": { - "type": "string" - }, - "votes": { - "type": "integer", - "format": "int32" - } - }, - "required": [ - "id", - "label", - "votes" - ], - "type": "object", - "additionalProperties": false - }, - "PollPrivacy": { - "description": "Who may see which voter picked which option. Chosen by the poll's author when they build the poll, so it\nlives on the poll itself rather than in the widget config. Anonymous is the default and is never stored on\nthe poll or sent to the client, so an unset value means Anonymous.", - "enum": [ - 0, - 1, - 2 - ], - "type": "integer" - }, - "CommentPoll": { - "description": "A poll attached to a comment. Vote counts are denormalized here; individual votes live in PollVote.", - "properties": { - "question": { - "type": "string" - }, - "options": { - "items": { - "$ref": "#/components/schemas/CommentPollOption" - }, - "type": "array" - }, - "totalVotes": { - "type": "integer", - "format": "int32" - }, - "closesAt": { - "type": "string", - "format": "date-time", - "nullable": true - }, - "privacy": { - "allOf": [ - { - "$ref": "#/components/schemas/PollPrivacy" - } - ], - "nullable": true - }, - "requireVoteToSeeResults": { - "type": "boolean", - "nullable": true - } - }, - "required": [ - "question", - "options", - "totalVotes" - ], - "type": "object", - "additionalProperties": false - }, "FDomain": { "type": "string" }, @@ -4695,6 +4788,14 @@ }, "type": "array" }, + "poll": { + "allOf": [ + { + "$ref": "#/components/schemas/CommentPoll" + } + ], + "nullable": true + }, "requiresVerification": { "type": "boolean" }, @@ -14352,6 +14453,172 @@ ] } }, + "/polls/{tenantId}/{commentId}/vote": { + "put": { + "operationId": "VotePoll", + "responses": { + "200": { + "description": "Ok", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/VotePollResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIError" + } + } + } + } + }, + "tags": [ + "Public" + ], + "security": [], + "parameters": [ + { + "in": "path", + "name": "tenantId", + "required": true, + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "commentId", + "required": true, + "schema": { + "type": "string" + } + }, + { + "in": "query", + "name": "urlId", + "required": false, + "schema": { + "type": "string" + } + }, + { + "in": "query", + "name": "broadcastId", + "required": false, + "schema": { + "type": "string" + } + }, + { + "in": "query", + "name": "sso", + "required": false, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/VotePollBody" + } + } + } + } + } + }, + "/polls/{tenantId}/{commentId}/voters": { + "get": { + "operationId": "GetPollVoters", + "responses": { + "200": { + "description": "Ok", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetPollVoterNamesSuccessResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIError" + } + } + } + } + }, + "description": "Who voted for which option. Anonymous polls never answer, admins-only polls answer only for an admin or moderator.", + "tags": [ + "Public" + ], + "security": [], + "parameters": [ + { + "in": "path", + "name": "tenantId", + "required": true, + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "commentId", + "required": true, + "schema": { + "type": "string" + } + }, + { + "in": "query", + "name": "urlId", + "required": false, + "schema": { + "type": "string" + } + }, + { + "in": "query", + "name": "page", + "required": false, + "schema": { + "format": "int32", + "type": "integer" + } + }, + { + "in": "query", + "name": "search", + "required": false, + "schema": { + "type": "string" + } + }, + { + "in": "query", + "name": "sso", + "required": false, + "schema": { + "type": "string" + } + } + ] + } + }, "/page-reacts/v1/likes/{tenantId}": { "get": { "operationId": "GetV1PageLikes", diff --git a/pubsub/README.md b/pubsub/README.md index c22fb0c..4516d8c 100644 --- a/pubsub/README.md +++ b/pubsub/README.md @@ -32,7 +32,7 @@ Then add the dependency: com.fastcomments pubsub - 3.1.0 + 3.1.1 ``` @@ -52,7 +52,7 @@ repositories { Then add the dependency: ```groovy -implementation 'com.fastcomments:pubsub:3.1.0' +implementation 'com.fastcomments:pubsub:3.1.1' ``` ## Key Components